ok
This commit is contained in:
6
package-lock.json
generated
6
package-lock.json
generated
@@ -15,6 +15,7 @@
|
|||||||
"@testing-library/react": "^13.4.0",
|
"@testing-library/react": "^13.4.0",
|
||||||
"@testing-library/user-event": "^13.5.0",
|
"@testing-library/user-event": "^13.5.0",
|
||||||
"caniuse-lite": "^1.0.30001690",
|
"caniuse-lite": "^1.0.30001690",
|
||||||
|
"crypto-js": "^4.2.0",
|
||||||
"html-to-image": "^1.11.11",
|
"html-to-image": "^1.11.11",
|
||||||
"html2canvas": "^1.4.1",
|
"html2canvas": "^1.4.1",
|
||||||
"jsqr": "^1.4.0",
|
"jsqr": "^1.4.0",
|
||||||
@@ -7194,6 +7195,11 @@
|
|||||||
"node": ">= 8"
|
"node": ">= 8"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/crypto-js": {
|
||||||
|
"version": "4.2.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/crypto-js/-/crypto-js-4.2.0.tgz",
|
||||||
|
"integrity": "sha512-KALDyEYgpY+Rlob/iriUtjV6d5Eq+Y191A5g4UqLAi8CyGP9N1+FdVbkc1SxKc2r4YAYqG8JzO2KGL+AizD70Q=="
|
||||||
|
},
|
||||||
"node_modules/crypto-random-string": {
|
"node_modules/crypto-random-string": {
|
||||||
"version": "2.0.0",
|
"version": "2.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/crypto-random-string/-/crypto-random-string-2.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/crypto-random-string/-/crypto-random-string-2.0.0.tgz",
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
"@testing-library/react": "^13.4.0",
|
"@testing-library/react": "^13.4.0",
|
||||||
"@testing-library/user-event": "^13.5.0",
|
"@testing-library/user-event": "^13.5.0",
|
||||||
"caniuse-lite": "^1.0.30001690",
|
"caniuse-lite": "^1.0.30001690",
|
||||||
|
"crypto-js": "^4.2.0",
|
||||||
"html-to-image": "^1.11.11",
|
"html-to-image": "^1.11.11",
|
||||||
"html2canvas": "^1.4.1",
|
"html2canvas": "^1.4.1",
|
||||||
"jsqr": "^1.4.0",
|
"jsqr": "^1.4.0",
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ import styles from './Join.module.css'; // Import the module.css file
|
|||||||
import { checkCoupon, logCouponForUser } from '../helpers/couponHelpers'; // Import the new helper
|
import { checkCoupon, logCouponForUser } from '../helpers/couponHelpers'; // Import the new helper
|
||||||
import Coupon from '../components/Coupon';
|
import Coupon from '../components/Coupon';
|
||||||
|
|
||||||
|
import CryptoJS from 'crypto-js';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
getLocalStorage,
|
getLocalStorage,
|
||||||
} from "../helpers/localStorageHelpers";
|
} from "../helpers/localStorageHelpers";
|
||||||
@@ -20,15 +22,15 @@ const LinktreePage = ({ data, setModal }) => {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (couponCode !== '') return;
|
if (couponCode !== '') return;
|
||||||
const modal = queryParams.get('modal');
|
const modal = queryParams.get('modal');
|
||||||
const code = queryParams.get('couponCode');
|
const code = queryParams.get('c');
|
||||||
|
|
||||||
console.log(code)
|
console.log(code)
|
||||||
if (modal == 'claim-coupon') {
|
if (modal == 'claim-coupon') {
|
||||||
if (!getLocalStorage('auth')) {
|
if (!getLocalStorage('auth')) {
|
||||||
|
|
||||||
// Preserve the couponCode query param while navigating to the claim-coupon modal
|
// Preserve the couponCode query param while navigating to the claim-coupon modal
|
||||||
const newUrl = `?modal=join${code ? `&couponCode=${code}` : ''}`;
|
if(code) setModal('join', {c: code})
|
||||||
window.location.href = newUrl; // This will update the URL and reload the page
|
else setModal('join')
|
||||||
}
|
}
|
||||||
|
|
||||||
setIsOnlyClaimCoupon(true)
|
setIsOnlyClaimCoupon(true)
|
||||||
@@ -38,14 +40,21 @@ const LinktreePage = ({ data, setModal }) => {
|
|||||||
if (getLocalStorage('auth')) {
|
if (getLocalStorage('auth')) {
|
||||||
|
|
||||||
// Preserve the couponCode query param while navigating to the claim-coupon modal
|
// Preserve the couponCode query param while navigating to the claim-coupon modal
|
||||||
const newUrl = `?modal=claim-coupon${code ? `&couponCode=${code}` : ''}`;
|
if(code) setModal('claim-coupon', {c: code})
|
||||||
window.location.href = newUrl; // This will update the URL and reload the page
|
else setModal('claim-coupon')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (code) {
|
if (code) {
|
||||||
setCouponCode(code);
|
// Your AES-256 key (ensure this is kept secret and secure!)
|
||||||
|
const secretKey = 'xixixi666'; // 32 characters for AES-256
|
||||||
|
|
||||||
|
// Decrypt the couponCode
|
||||||
|
const decryptedBytes = CryptoJS.AES.decrypt(code, secretKey);
|
||||||
|
const decryptedCode = decryptedBytes.toString(CryptoJS.enc.Utf8);
|
||||||
|
console.log(decryptedCode)
|
||||||
|
setCouponCode(decryptedCode);
|
||||||
setIsUsingCoupon(true); // Automatically switch to the coupon input state
|
setIsUsingCoupon(true); // Automatically switch to the coupon input state
|
||||||
handleCheckCoupon(code); // Automatically check the coupon code
|
handleCheckCoupon(decryptedCode); // Automatically check the coupon code
|
||||||
}
|
}
|
||||||
}, [queryParams]);
|
}, [queryParams]);
|
||||||
|
|
||||||
@@ -162,8 +171,14 @@ const LinktreePage = ({ data, setModal }) => {
|
|||||||
style={{ width: '266px' }}
|
style={{ width: '266px' }}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
if (!isOnlyClaimCoupon) {
|
if (!isOnlyClaimCoupon) {
|
||||||
|
|
||||||
|
const secretKey = 'xixixi666'; // Your AES-256 key (32 characters)
|
||||||
|
|
||||||
|
// Encrypt couponCode inline
|
||||||
|
const encryptedCouponCode = CryptoJS.AES.encrypt(couponCode, secretKey).toString();
|
||||||
|
|
||||||
// If it's only claiming a coupon, trigger claim logic
|
// If it's only claiming a coupon, trigger claim logic
|
||||||
setModal('create_user', { codeStatus: 200, couponCode });
|
setModal('create_user', { codeStatus: 200, c: encryptedCouponCode });
|
||||||
} else {
|
} else {
|
||||||
// Otherwise, handle the coupon for user creation
|
// Otherwise, handle the coupon for user creation
|
||||||
handleLogCouponForUser();
|
handleLogCouponForUser();
|
||||||
@@ -188,7 +203,7 @@ const LinktreePage = ({ data, setModal }) => {
|
|||||||
>
|
>
|
||||||
Sudah punya akun bisnis?
|
Sudah punya akun bisnis?
|
||||||
</a>
|
</a>
|
||||||
}
|
}
|
||||||
<a
|
<a
|
||||||
href="https://linktr.ee/discover/trending"
|
href="https://linktr.ee/discover/trending"
|
||||||
target="_blank"
|
target="_blank"
|
||||||
|
|||||||
@@ -114,7 +114,7 @@ const App = ({ forCafe = true, cafeId = -1,
|
|||||||
const [selectedCafeId, setSelectedCafeId] = useState(cafeId);
|
const [selectedCafeId, setSelectedCafeId] = useState(cafeId);
|
||||||
const [analytics, setAnalytics] = useState({});
|
const [analytics, setAnalytics] = useState({});
|
||||||
const [loading, setLoading] = useState(true);
|
const [loading, setLoading] = useState(true);
|
||||||
const [filter, setFilter] = useState("yesterday");
|
const [filter, setFilter] = useState("monthly");
|
||||||
const [circularFilter, setCircularFilter] = useState("item");
|
const [circularFilter, setCircularFilter] = useState("item");
|
||||||
const [graphFilter, setGraphFilter] = useState("income");
|
const [graphFilter, setGraphFilter] = useState("income");
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user