diff --git a/package.json b/package.json index 5b8a6e9..6c9f4e8 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "groovebrew-mockup", "version": "0.1.0", "private": true, - "homepage": "https://kedaimaster.com", + "homepage": "https://dev.kedaimaster.com", "dependencies": { "@emotion/react": "^11.13.3", "@emotion/styled": "^11.13.0", diff --git a/src/pages/CreateCoupon.js b/src/pages/CreateCoupon.js index 6dfd5a6..ebffb06 100644 --- a/src/pages/CreateCoupon.js +++ b/src/pages/CreateCoupon.js @@ -30,23 +30,34 @@ const CreateCouponPage = () => { const handleSubmit = async (e) => { e.preventDefault(); setLoading(true); - + // Call the helper function to create the coupon const result = await createCoupon(discountType, discountValue, discountPeriods, codeExpectation); - + if (result.success) { setCouponDetails(result.coupon); - const secretKey = 'xixixi666'; // Your AES-256 key (32 characters) - - // Encrypt couponCode inline + const secretKey = 'xixixi666'; // AES-256 key (32 characters) + + // Encrypt the coupon code inline 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); } else { setLoading(false); } }; + + return (
@@ -67,7 +78,7 @@ const CreateCouponPage = () => { />