setIsConfigCafeIdentityName(false)} // Close the config modal
style={{
@@ -636,8 +638,10 @@ const SetPaymentQr = ({ shop }) => {
{
+ setCafeIdentifyNameDefault(cafeIdentifyNameUpdate)
// Handle save functionality here
setIsConfigCafeIdentityName(false); // Close after saving
+
}}
style={{
backgroundColor: '#303034',
@@ -951,7 +955,7 @@ const styles = {
},
qrCodeContainer: {
backgroundColor: '#999999',
- borderRadius: '20px',
+ borderRadius: '8px',
position: "relative",
width: "100%",
height: "200px",
diff --git a/src/pages/CheckCoupon.js b/src/pages/CheckCoupon.js
new file mode 100644
index 0000000..ee1e265
--- /dev/null
+++ b/src/pages/CheckCoupon.js
@@ -0,0 +1,64 @@
+import React, { useState } from "react";
+
+import API_BASE_URL from "../config.js";
+
+function getAuthToken() {
+ return localStorage.getItem("auth");
+ }
+
+const CheckCouponPage = () => {
+ const [couponCode, setCouponCode] = useState("");
+ const [couponStatus, setCouponStatus] = useState("");
+ const [couponDetails, setCouponDetails] = useState(null);
+
+ const handleCheckCoupon = async () => {
+ try {
+ const response = await fetch(`${API_BASE_URL}/coupon/check/${couponCode}`, {
+ method: "GET",
+ headers: {
+ "Content-Type": "application/json",
+ Authorization: `Bearer ${getAuthToken()}`,
+ },
+ });
+
+ if (response.ok) {
+ const data = await response.json();
+ setCouponStatus("Coupon is valid");
+ setCouponDetails(data.coupon);
+ } else {
+ setCouponStatus("Coupon not found or expired");
+ setCouponDetails(null);
+ }
+ } catch (error) {
+ setCouponStatus("Error checking coupon.");
+ setCouponDetails(null);
+ }
+ };
+
+ return (
+
+
Check Coupon
+
+
+ setCouponCode(e.target.value)}
+ />
+
+
+ {couponStatus &&
{couponStatus}
}
+ {couponDetails && (
+
+
Coupon Code: {couponDetails.code}
+
Discount Type: {couponDetails.discountType}
+
Discount Value: {couponDetails.discountValue}
+
Discount Periods: {couponDetails.discountPeriods} weeks
+
Expiration Date: {couponDetails.expirationDate || "No expiration"}
+
+ )}
+
+ );
+};
+
+export default CheckCouponPage;
diff --git a/src/pages/CreateCoupon.js b/src/pages/CreateCoupon.js
new file mode 100644
index 0000000..5be0cf7
--- /dev/null
+++ b/src/pages/CreateCoupon.js
@@ -0,0 +1,80 @@
+import React, { useState } from "react";
+
+import API_BASE_URL from "../config.js";
+
+function getAuthToken() {
+ return localStorage.getItem("auth");
+ }
+const CreateCouponPage = () => {
+ const [discountType, setDiscountType] = useState("percentage");
+ const [discountValue, setDiscountValue] = useState("");
+ const [discountPeriods, setDiscountPeriods] = useState("");
+ const [message, setMessage] = useState("");
+
+ const handleSubmit = async (e) => {
+ e.preventDefault();
+ try {
+ const response = await fetch(`${API_BASE_URL}/coupon/create`, {
+ method: "POST",
+ headers: {
+ "Content-Type": "application/json",
+ Authorization: `Bearer ${getAuthToken()}`,
+ },
+ body: JSON.stringify({
+ discountType,
+ discountValue,
+ discountPeriods,
+ }),
+ });
+
+ if (response.ok) {
+ const data = await response.json();
+ setMessage(`Coupon created successfully: ${data.coupon.code}`);
+ } else {
+ setMessage("Failed to create coupon.");
+ }
+ } catch (error) {
+ setMessage("Error creating coupon.");
+ }
+ };
+
+ return (
+
+
Create Coupon
+
+ {message &&
{message}
}
+
+ );
+};
+
+export default CreateCouponPage;
diff --git a/src/pages/CreateUserWithCoupon.js b/src/pages/CreateUserWithCoupon.js
new file mode 100644
index 0000000..e69de29
diff --git a/src/pages/Dashboard.js b/src/pages/Dashboard.js
index 33a4f35..75cae57 100644
--- a/src/pages/Dashboard.js
+++ b/src/pages/Dashboard.js
@@ -927,8 +927,8 @@ const sortedMaterials = allMaterials.sort((a, b) => new Date(a.date) - new Date(