ok
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
"name": "groovebrew-mockup",
|
"name": "groovebrew-mockup",
|
||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
"homepage": "https://kedaimaster.com",
|
"homepage": "https://dev.kedaimaster.com",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@emotion/react": "^11.13.3",
|
"@emotion/react": "^11.13.3",
|
||||||
"@emotion/styled": "^11.13.0",
|
"@emotion/styled": "^11.13.0",
|
||||||
|
|||||||
@@ -36,18 +36,29 @@ const CreateCouponPage = () => {
|
|||||||
|
|
||||||
if (result.success) {
|
if (result.success) {
|
||||||
setCouponDetails(result.coupon);
|
setCouponDetails(result.coupon);
|
||||||
const secretKey = 'xixixi666'; // Your AES-256 key (32 characters)
|
const secretKey = 'xixixi666'; // AES-256 key (32 characters)
|
||||||
|
|
||||||
// Encrypt couponCode inline
|
// Encrypt the coupon code inline
|
||||||
const encryptedCouponCode = CryptoJS.AES.encrypt(result.coupon.code, secretKey).toString();
|
const encryptedCouponCode = CryptoJS.AES.encrypt(result.coupon.code, secretKey).toString();
|
||||||
setCouponUrl(encryptedCouponCode)
|
|
||||||
console.log(encryptedCouponCode)
|
// Convert the encrypted code to Base64 URL-safe encoding
|
||||||
|
const base64UrlSafe = encryptedCouponCode.replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/, '');
|
||||||
|
|
||||||
|
// Store the Base64 URL-safe encrypted coupon code in the query parameter
|
||||||
|
const encodedCouponCode = encodeURIComponent(base64UrlSafe); // Ensure it's safely encoded for URL use
|
||||||
|
const urlWithCoupon = `https://dev.coupon.kedaimaster.com/coupon?c=${encodedCouponCode}`;
|
||||||
|
|
||||||
|
// Optionally, set the URL to use with the coupon
|
||||||
|
setCouponUrl(urlWithCoupon);
|
||||||
|
console.log(urlWithCoupon);
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
} else {
|
} else {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={styles.linktreePage}>
|
<div className={styles.linktreePage}>
|
||||||
<div className={styles.dashboardContainer}>
|
<div className={styles.dashboardContainer}>
|
||||||
@@ -67,7 +78,7 @@ const CreateCouponPage = () => {
|
|||||||
/>
|
/>
|
||||||
<button
|
<button
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
navigator.clipboard.writeText('https://dev.coupon.kedaimaster.com/coupon?c=' + couponUrl)
|
navigator.clipboard.writeText(couponUrl)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
// Optional: Show a message that the text has been copied
|
// Optional: Show a message that the text has been copied
|
||||||
alert("Coupon URL copied to clipboard!");
|
alert("Coupon URL copied to clipboard!");
|
||||||
|
|||||||
@@ -19,45 +19,47 @@ const LinktreePage = ({ data, setModal }) => {
|
|||||||
const [couponDetails, setCouponDetails] = useState(null);
|
const [couponDetails, setCouponDetails] = useState(null);
|
||||||
|
|
||||||
// Detect query params on component mount
|
// Detect query params on component mount
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (couponCode !== '') return;
|
if (couponCode !== '') return; // Prevent repeated code
|
||||||
|
|
||||||
const modal = queryParams.get('modal');
|
const modal = queryParams.get('modal');
|
||||||
const code = queryParams.get('c');
|
const encryptedCode = queryParams.get('c'); // Encrypted coupon code in query
|
||||||
|
|
||||||
console.log(code)
|
console.log(encryptedCode);
|
||||||
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
|
||||||
if(code) setModal('join', {c: code})
|
if (encryptedCode) setModal('join', { c: encryptedCode });
|
||||||
else setModal('join')
|
else setModal('join');
|
||||||
}
|
}
|
||||||
|
|
||||||
setIsOnlyClaimCoupon(true)
|
setIsOnlyClaimCoupon(true);
|
||||||
setIsUsingCoupon(true); // Automatically switch to the coupon input state
|
setIsUsingCoupon(true); // Automatically switch to the coupon input state
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
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
|
||||||
if(code) setModal('claim-coupon', {c: code})
|
if (encryptedCode) setModal('claim-coupon', { c: encryptedCode });
|
||||||
else setModal('claim-coupon')
|
else setModal('claim-coupon');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (code) {
|
|
||||||
// Your AES-256 key (ensure this is kept secret and secure!)
|
if (encryptedCode) {
|
||||||
|
// AES-256 key (ensure this is kept secret and secure!)
|
||||||
const secretKey = 'xixixi666'; // 32 characters for AES-256
|
const secretKey = 'xixixi666'; // 32 characters for AES-256
|
||||||
|
|
||||||
// Decrypt the couponCode
|
// Decode and decrypt the coupon code
|
||||||
const decryptedBytes = CryptoJS.AES.decrypt(code, secretKey);
|
const decodedCouponCode = decodeURIComponent(encryptedCode); // Decode the encrypted code from the URL
|
||||||
|
const decryptedBytes = CryptoJS.AES.decrypt(decodedCouponCode, secretKey);
|
||||||
const decryptedCode = decryptedBytes.toString(CryptoJS.enc.Utf8);
|
const decryptedCode = decryptedBytes.toString(CryptoJS.enc.Utf8);
|
||||||
console.log(decryptedCode)
|
|
||||||
|
console.log(decryptedCode);
|
||||||
setCouponCode(decryptedCode);
|
setCouponCode(decryptedCode);
|
||||||
setIsUsingCoupon(true); // Automatically switch to the coupon input state
|
setIsUsingCoupon(true); // Automatically switch to the coupon input state
|
||||||
handleCheckCoupon(decryptedCode); // Automatically check the coupon code
|
handleCheckCoupon(decryptedCode); // Automatically check the coupon code
|
||||||
}
|
}
|
||||||
}, [queryParams]);
|
}, [queryParams]);
|
||||||
|
|
||||||
// Handle manual coupon code check
|
// Handle manual coupon code check
|
||||||
const handleCheckCoupon = async (code = couponCode) => {
|
const handleCheckCoupon = async (code = couponCode) => {
|
||||||
const result = await checkCoupon(code); // Call the helper
|
const result = await checkCoupon(code); // Call the helper
|
||||||
|
|||||||
Reference in New Issue
Block a user