ok
This commit is contained in:
@@ -10,7 +10,6 @@ import {
|
|||||||
} from "react-router-dom";
|
} from "react-router-dom";
|
||||||
import socket from "./services/socketService";
|
import socket from "./services/socketService";
|
||||||
|
|
||||||
import API_BASE_URL from "./config.js";
|
|
||||||
|
|
||||||
import Dashboard from "./pages/Dashboard";
|
import Dashboard from "./pages/Dashboard";
|
||||||
import ScanMeja from "./pages/ScanMeja";
|
import ScanMeja from "./pages/ScanMeja";
|
||||||
|
|||||||
@@ -27,6 +27,10 @@ import Login from "../pages/Login";
|
|||||||
import ResetPassword from "../pages/ResetPassword";
|
import ResetPassword from "../pages/ResetPassword";
|
||||||
import { getImageUrl } from "../helpers/itemHelper.js";
|
import { getImageUrl } from "../helpers/itemHelper.js";
|
||||||
|
|
||||||
|
|
||||||
|
import CreateCoupon from "../pages/CreateCoupon";
|
||||||
|
import CheckCoupon from "../pages/CheckCoupon";
|
||||||
|
|
||||||
const Modal = ({ user, shop, isOpen, onClose, modalContent, setModal, handleMoveToTransaction,welcomePageConfig }) => {
|
const Modal = ({ user, shop, isOpen, onClose, modalContent, setModal, handleMoveToTransaction,welcomePageConfig }) => {
|
||||||
|
|
||||||
const [shopImg, setShopImg] = useState('');
|
const [shopImg, setShopImg] = useState('');
|
||||||
@@ -95,6 +99,10 @@ const Modal = ({ user, shop, isOpen, onClose, modalContent, setModal, handleMove
|
|||||||
)}
|
)}
|
||||||
{modalContent === "welcome_config" && <WelcomePageEditor cafeId={shop.cafeId} welcomePageConfig={shop.welcomePageConfig} />}
|
{modalContent === "welcome_config" && <WelcomePageEditor cafeId={shop.cafeId} welcomePageConfig={shop.welcomePageConfig} />}
|
||||||
{modalContent === "reports" && <Reports handleClose={handleOverlayClick} cafeId={shop.cafeId} />}
|
{modalContent === "reports" && <Reports handleClose={handleOverlayClick} cafeId={shop.cafeId} />}
|
||||||
|
|
||||||
|
|
||||||
|
{modalContent === "create_coupon" && <CreateCoupon />}
|
||||||
|
{modalContent === "check_coupon" && <CheckCoupon />}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ const SetPaymentQr = ({ shop }) => {
|
|||||||
const [bgImageUrl, setBgImageUrl] = useState(getImageUrl(shop.qrBackground));
|
const [bgImageUrl, setBgImageUrl] = useState(getImageUrl(shop.qrBackground));
|
||||||
const qrBackgroundInputRef = useRef(null);
|
const qrBackgroundInputRef = useRef(null);
|
||||||
|
|
||||||
|
const [cafeIdentifyNameDefault, setCafeIdentifyNameDefault] = useState(shop.cafeIdentifyName);
|
||||||
const [cafeIdentifyNameUpdate, setCafeIdentifyNameUpdate] = useState(shop.cafeIdentifyName);
|
const [cafeIdentifyNameUpdate, setCafeIdentifyNameUpdate] = useState(shop.cafeIdentifyName);
|
||||||
const shopUrl = window.location.hostname + "/" + cafeIdentifyNameUpdate;
|
const shopUrl = window.location.hostname + "/" + cafeIdentifyNameUpdate;
|
||||||
|
|
||||||
@@ -350,7 +351,7 @@ const SetPaymentQr = ({ shop }) => {
|
|||||||
}}
|
}}
|
||||||
onBlur={() => {
|
onBlur={() => {
|
||||||
setIsConfigCafeIdentityName(false); // Set the state to false when input loses focus
|
setIsConfigCafeIdentityName(false); // Set the state to false when input loses focus
|
||||||
setCafeIdentifyNameUpdate(shop.cafeIdentifyName)
|
setCafeIdentifyNameUpdate(cafeIdentifyNameDefault)
|
||||||
}} // Handle blur event to reset the state
|
}} // Handle blur event to reset the state
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@@ -617,7 +618,8 @@ const SetPaymentQr = ({ shop }) => {
|
|||||||
>
|
>
|
||||||
Ganti alamat kedai
|
Ganti alamat kedai
|
||||||
</div> : (
|
</div> : (
|
||||||
<div style={{ display: 'flex', justifyContent: 'space-between', width: '100%' }}>
|
<div style={{ display: 'flex', justifyContent: 'space-between', width: '100%',
|
||||||
|
marginBottom: '10px' }}>
|
||||||
<div
|
<div
|
||||||
onClick={() => setIsConfigCafeIdentityName(false)} // Close the config modal
|
onClick={() => setIsConfigCafeIdentityName(false)} // Close the config modal
|
||||||
style={{
|
style={{
|
||||||
@@ -636,8 +638,10 @@ const SetPaymentQr = ({ shop }) => {
|
|||||||
|
|
||||||
<div
|
<div
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
|
setCafeIdentifyNameDefault(cafeIdentifyNameUpdate)
|
||||||
// Handle save functionality here
|
// Handle save functionality here
|
||||||
setIsConfigCafeIdentityName(false); // Close after saving
|
setIsConfigCafeIdentityName(false); // Close after saving
|
||||||
|
|
||||||
}}
|
}}
|
||||||
style={{
|
style={{
|
||||||
backgroundColor: '#303034',
|
backgroundColor: '#303034',
|
||||||
@@ -951,7 +955,7 @@ const styles = {
|
|||||||
},
|
},
|
||||||
qrCodeContainer: {
|
qrCodeContainer: {
|
||||||
backgroundColor: '#999999',
|
backgroundColor: '#999999',
|
||||||
borderRadius: '20px',
|
borderRadius: '8px',
|
||||||
position: "relative",
|
position: "relative",
|
||||||
width: "100%",
|
width: "100%",
|
||||||
height: "200px",
|
height: "200px",
|
||||||
|
|||||||
64
src/pages/CheckCoupon.js
Normal file
64
src/pages/CheckCoupon.js
Normal file
@@ -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 (
|
||||||
|
<div>
|
||||||
|
<h1>Check Coupon</h1>
|
||||||
|
<div>
|
||||||
|
<label>Coupon Code:</label>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
value={couponCode}
|
||||||
|
onChange={(e) => setCouponCode(e.target.value)}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<button onClick={handleCheckCoupon}>Check Coupon</button>
|
||||||
|
{couponStatus && <p>{couponStatus}</p>}
|
||||||
|
{couponDetails && (
|
||||||
|
<div>
|
||||||
|
<p>Coupon Code: {couponDetails.code}</p>
|
||||||
|
<p>Discount Type: {couponDetails.discountType}</p>
|
||||||
|
<p>Discount Value: {couponDetails.discountValue}</p>
|
||||||
|
<p>Discount Periods: {couponDetails.discountPeriods} weeks</p>
|
||||||
|
<p>Expiration Date: {couponDetails.expirationDate || "No expiration"}</p>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default CheckCouponPage;
|
||||||
80
src/pages/CreateCoupon.js
Normal file
80
src/pages/CreateCoupon.js
Normal file
@@ -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 (
|
||||||
|
<div>
|
||||||
|
<h1>Create Coupon</h1>
|
||||||
|
<form onSubmit={handleSubmit}>
|
||||||
|
<div>
|
||||||
|
<label>Discount Type:</label>
|
||||||
|
<select
|
||||||
|
value={discountType}
|
||||||
|
onChange={(e) => setDiscountType(e.target.value)}
|
||||||
|
>
|
||||||
|
<option value="percentage">Percentage</option>
|
||||||
|
<option value="fixed">Fixed</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<label>Discount Value:</label>
|
||||||
|
<input
|
||||||
|
type="number"
|
||||||
|
value={discountValue}
|
||||||
|
onChange={(e) => setDiscountValue(e.target.value)}
|
||||||
|
required
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<label>Discount Periods (in weeks):</label>
|
||||||
|
<input
|
||||||
|
type="number"
|
||||||
|
value={discountPeriods}
|
||||||
|
onChange={(e) => setDiscountPeriods(e.target.value)}
|
||||||
|
required
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<button type="submit">Create Coupon</button>
|
||||||
|
</form>
|
||||||
|
{message && <p>{message}</p>}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default CreateCouponPage;
|
||||||
0
src/pages/CreateUserWithCoupon.js
Normal file
0
src/pages/CreateUserWithCoupon.js
Normal file
@@ -927,8 +927,8 @@ const sortedMaterials = allMaterials.sort((a, b) => new Date(a.date) - new Date(
|
|||||||
|
|
||||||
<div className={styles.footer}>
|
<div className={styles.footer}>
|
||||||
<div className={styles.footerLinks}>
|
<div className={styles.footerLinks}>
|
||||||
<a href="https://linktr.ee/discover/trending" target="_blank" rel="noreferrer" className={styles.footerLink}>Pelajari lebih lanjut</a>
|
<a href="https://kediritechnopark.com/kedaimaster" target="_blank" rel="noreferrer" className={styles.footerLink}>Pelajari lebih lanjut</a>
|
||||||
<a href="https://linktr.ee" target="_blank" rel="noreferrer" className={styles.footerLink}>Tentang kedaimaster.com</a>
|
<a href="https://kediritechnopark.com/" target="_blank" rel="noreferrer" className={styles.footerLink}>Tentang kedaimaster.com</a>
|
||||||
<a
|
<a
|
||||||
target="_blank"
|
target="_blank"
|
||||||
rel="noreferrer"
|
rel="noreferrer"
|
||||||
@@ -946,6 +946,7 @@ const sortedMaterials = allMaterials.sort((a, b) => new Date(a.date) - new Date(
|
|||||||
onError={(e) => e.target.src = '/fallback-image.png'}
|
onError={(e) => e.target.src = '/fallback-image.png'}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
<a style={{left: 0, right: 0, bottom: 0, textAlign: 'center', color: '#254F1A', fontSize:'13px', position: 'fixed'}}>©2025 KEDIRITECHNOPARK</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ const LinktreePage = ({ data }) => {
|
|||||||
rel="noreferrer"
|
rel="noreferrer"
|
||||||
className={styles.footerLink}
|
className={styles.footerLink}
|
||||||
>
|
>
|
||||||
Tentang kedaimaster.com
|
Gunakan kupon
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
<div className={styles.footerImage}>
|
<div className={styles.footerImage}>
|
||||||
|
|||||||
Reference in New Issue
Block a user