ok
This commit is contained in:
@@ -412,8 +412,13 @@ function App() {
|
|||||||
|
|
||||||
setIsModalOpen(true);
|
setIsModalOpen(true);
|
||||||
setModalContent(content)
|
setModalContent(content)
|
||||||
if (onCloseFunction) setOnModalCloseFunction(onCloseFunction)
|
console.log(onCloseFunction)
|
||||||
else setOnModalCloseFunction(null)
|
|
||||||
|
if (onCloseFunction) {
|
||||||
|
setOnModalCloseFunction(() => onCloseFunction); // Store the close function
|
||||||
|
} else {
|
||||||
|
setOnModalCloseFunction(null);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const closeModal = (closeTheseContent = []) => {
|
const closeModal = (closeTheseContent = []) => {
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
import React, { useState } from 'react';
|
import React, { useState } from 'react';
|
||||||
import styles from './AccountUpdatePage.module.css'; // Adjust CSS if needed
|
|
||||||
import { updateUser } from '../helpers/userHelpers';
|
import { updateUser } from '../helpers/userHelpers';
|
||||||
|
import styles from '../pages/Join.module.css'; // Import the module.css file
|
||||||
|
|
||||||
const AccountUpdatePage = ({ user, showEmail, onSubmit }) => {
|
const AccountUpdatePage = ({ user, showEmail, onSubmit }) => {
|
||||||
const [formData, setFormData] = useState({
|
const [formData, setFormData] = useState({
|
||||||
username: user.username.startsWith('guest') ? '' : user.username || '',
|
username: user.username || '',
|
||||||
email: user.email || '',
|
email: user.email || '',
|
||||||
password: user.password === 'unsetunsetunset' ? '' : user.password || '',
|
password: user.password === 'unsetunsetunset' ? '' : user.password || '',
|
||||||
});
|
});
|
||||||
@@ -12,6 +12,13 @@ const AccountUpdatePage = ({ user, showEmail, onSubmit }) => {
|
|||||||
const [errorMessage, setErrorMessage] = useState('');
|
const [errorMessage, setErrorMessage] = useState('');
|
||||||
const [successMessage, setSuccessMessage] = useState(''); // New state for success messages
|
const [successMessage, setSuccessMessage] = useState(''); // New state for success messages
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
const [loading, setLoading] = useState(false);
|
||||||
|
const [error, setError] = useState(false);
|
||||||
|
const [wasInputtingPassword, setWasInputtingPassword] = useState(false);
|
||||||
|
const [inputtingPassword, setInputtingPassword] = useState(false);
|
||||||
|
|
||||||
const handleChange = (e) => {
|
const handleChange = (e) => {
|
||||||
setFormData({ ...formData, [e.target.name]: e.target.value });
|
setFormData({ ...formData, [e.target.name]: e.target.value });
|
||||||
};
|
};
|
||||||
@@ -41,55 +48,122 @@ const AccountUpdatePage = ({ user, showEmail, onSubmit }) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={styles.container}>
|
|
||||||
<h2>Update Your Account</h2>
|
<div className={styles.linktreePage}>
|
||||||
<form onSubmit={handleSubmit} className={styles.form}>
|
<div className={styles.dashboardContainer}>
|
||||||
<label className={styles.formLabel}>
|
<div className={styles.mainHeading}>Ubah profil</div>
|
||||||
Username:
|
<div className={styles.subHeadingTransparent}>
|
||||||
<input
|
Daftarkan kedaimu sekarang dan mulai gunakan semua fitur unggulan kami.
|
||||||
type="text"
|
</div>
|
||||||
name="username"
|
|
||||||
value={formData.username}
|
|
||||||
onChange={handleChange}
|
|
||||||
className={styles.formInput}
|
|
||||||
/>
|
|
||||||
</label>
|
|
||||||
|
|
||||||
{showEmail && (
|
<div className={styles.LoginForm}>
|
||||||
<label className={styles.formLabel}>
|
<div className={`${styles.FormUsername} ${inputtingPassword ? styles.animateForm : wasInputtingPassword ? styles.reverseForm : ''}`}>
|
||||||
Email:
|
<label htmlFor="username" className={styles.usernameLabel}>----------------------------------------------</label>
|
||||||
<input
|
|
||||||
type="email"
|
<input
|
||||||
name="email"
|
name="username"
|
||||||
value={formData.email}
|
type="text"
|
||||||
onChange={handleChange}
|
placeholder="Username"
|
||||||
className={styles.formInput}
|
value={formData.username}
|
||||||
/>
|
onChange={handleChange}
|
||||||
</label>
|
className={!error ? styles.usernameInput : styles.usernameInputError}
|
||||||
)}
|
/>
|
||||||
|
|
||||||
<label className={styles.formLabel}>
|
<input
|
||||||
Password:
|
name="email"
|
||||||
<input
|
type="number"
|
||||||
type="password"
|
placeholder="Email"
|
||||||
name="password"
|
value={formData.email}
|
||||||
value={formData.password}
|
onChange={handleChange}
|
||||||
onChange={handleChange}
|
className={!error ? styles.usernameInput : styles.usernameInputError}
|
||||||
className={styles.formInput}
|
/>
|
||||||
/>
|
<button onClick={() => { setInputtingPassword(true); setWasInputtingPassword(true); }} className={styles.claimButton}>
|
||||||
</label>
|
<span>➜</span>
|
||||||
|
</button>
|
||||||
{/* Display success message */}
|
|
||||||
{successMessage && <div className={styles.successMessage}>{successMessage}</div>}
|
|
||||||
|
|
||||||
{/* Display error message */}
|
|
||||||
{errorMessage && <div className={styles.errorMessage}>{errorMessage}</div>}
|
|
||||||
|
|
||||||
<button type="submit" className={styles.submitButton}>
|
|
||||||
Submit
|
|
||||||
</button>
|
|
||||||
</form>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div className={`${styles.FormPassword} ${inputtingPassword ? styles.animateForm : wasInputtingPassword ? styles.reverseForm : ''}`}>
|
||||||
|
<span>
|
||||||
|
<label onClick={() => setInputtingPassword(false)} htmlFor="password" className={styles.usernameLabel}> <--- <-- kembali </label>
|
||||||
|
<label htmlFor="password" className={styles.usernameLabel}> ------------------------- </label>
|
||||||
|
</span>
|
||||||
|
|
||||||
|
<input
|
||||||
|
name="password"
|
||||||
|
type="password"
|
||||||
|
placeholder="Ganti password"
|
||||||
|
onChange={handleChange}
|
||||||
|
maxLength="30"
|
||||||
|
className={!error ? styles.usernameInput : styles.usernameInputError}
|
||||||
|
/>
|
||||||
|
<input
|
||||||
|
name="password"
|
||||||
|
type="password"
|
||||||
|
placeholder="Ulangi password"
|
||||||
|
onChange={handleChange}
|
||||||
|
maxLength="30"
|
||||||
|
className={!error ? styles.usernameInput : styles.usernameInputError}
|
||||||
|
/>
|
||||||
|
<button
|
||||||
|
onClick={handleSubmit}
|
||||||
|
className={`${styles.claimButton} ${loading ? styles.loading : ''}`}
|
||||||
|
disabled={loading}
|
||||||
|
>
|
||||||
|
<span>{loading ? 'Loading...' : 'Simpan'}</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
// <div className={styles.container}>
|
||||||
|
// <h2>Update Your Account</h2>
|
||||||
|
// <form onSubmit={handleSubmit} className={styles.form}>
|
||||||
|
// <label className={styles.formLabel}>
|
||||||
|
// Username:
|
||||||
|
// <input
|
||||||
|
// type="text"
|
||||||
|
// name="username"
|
||||||
|
// value={formData.username}
|
||||||
|
// onChange={handleChange}
|
||||||
|
// className={styles.formInput}
|
||||||
|
// />
|
||||||
|
// </label>
|
||||||
|
|
||||||
|
// {showEmail && (
|
||||||
|
// <label className={styles.formLabel}>
|
||||||
|
// Email:
|
||||||
|
// <input
|
||||||
|
// type="email"
|
||||||
|
// name="email"
|
||||||
|
// value={formData.email}
|
||||||
|
// onChange={handleChange}
|
||||||
|
// className={styles.formInput}
|
||||||
|
// />
|
||||||
|
// </label>
|
||||||
|
// )}
|
||||||
|
|
||||||
|
// <label className={styles.formLabel}>
|
||||||
|
// Password:
|
||||||
|
// <input
|
||||||
|
// type="password"
|
||||||
|
// name="password"
|
||||||
|
// value={formData.password}
|
||||||
|
// onChange={handleChange}
|
||||||
|
// className={styles.formInput}
|
||||||
|
// />
|
||||||
|
// </label>
|
||||||
|
|
||||||
|
// {/* Display success message */}
|
||||||
|
// {successMessage && <div className={styles.successMessage}>{successMessage}</div>}
|
||||||
|
|
||||||
|
// {/* Display error message */}
|
||||||
|
// {errorMessage && <div className={styles.errorMessage}>{errorMessage}</div>}
|
||||||
|
|
||||||
|
// <button type="submit" className={styles.submitButton}>
|
||||||
|
// Submit
|
||||||
|
// </button>
|
||||||
|
// </form>
|
||||||
|
// </div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -346,6 +346,14 @@ const Header = ({
|
|||||||
<>
|
<>
|
||||||
<Child hasChildren>
|
<Child hasChildren>
|
||||||
{shopName}
|
{shopName}
|
||||||
|
<Child>
|
||||||
|
Mode pengembangan
|
||||||
|
<Switch
|
||||||
|
borderRadius={0}
|
||||||
|
checked={isEditMode}
|
||||||
|
onChange={() => setIsEditMode(!isEditMode)}
|
||||||
|
/>
|
||||||
|
</Child>
|
||||||
<Child onClick={() => setModal("reports")}>Lihat laporan</Child>
|
<Child onClick={() => setModal("reports")}>Lihat laporan</Child>
|
||||||
<Child onClick={() => setModal("add_material")}>
|
<Child onClick={() => setModal("add_material")}>
|
||||||
Kelola bahan baku
|
Kelola bahan baku
|
||||||
@@ -384,14 +392,6 @@ const Header = ({
|
|||||||
Metode pembayaran
|
Metode pembayaran
|
||||||
</Child>
|
</Child>
|
||||||
</Child>
|
</Child>
|
||||||
<Child>
|
|
||||||
Mode pengembangan
|
|
||||||
<Switch
|
|
||||||
borderRadius={0}
|
|
||||||
checked={isEditMode}
|
|
||||||
onChange={() => setIsEditMode(!isEditMode)}
|
|
||||||
/>
|
|
||||||
</Child>
|
|
||||||
</Child>
|
</Child>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -47,12 +47,16 @@ const Modal = ({ user, shop, isOpen, onClose, modalContent, setModal, handleMove
|
|||||||
if (!isOpen) return null;
|
if (!isOpen) return null;
|
||||||
|
|
||||||
// Function to handle clicks on the overlay
|
// Function to handle clicks on the overlay
|
||||||
|
|
||||||
const handleOverlayClick = (event) => {
|
const handleOverlayClick = (event) => {
|
||||||
// Close the modal only if the overlay is clicked
|
console.log(onModalCloseFunction)
|
||||||
onModalCloseFunction();
|
if (onModalCloseFunction) {
|
||||||
onClose();
|
onModalCloseFunction(); // Execute the passed closure
|
||||||
|
}
|
||||||
|
onClose(); // Close the modal
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// Function to handle clicks on the modal content
|
// Function to handle clicks on the modal content
|
||||||
const handleContentClick = (event) => {
|
const handleContentClick = (event) => {
|
||||||
// Prevent click event from propagating to the overlay
|
// Prevent click event from propagating to the overlay
|
||||||
|
|||||||
@@ -3,37 +3,37 @@ import styles from './Join.module.css';
|
|||||||
import Coupon from '../components/Coupon';
|
import Coupon from '../components/Coupon';
|
||||||
|
|
||||||
import CryptoJS from 'crypto-js';
|
import CryptoJS from 'crypto-js';
|
||||||
import {createCoupon} from "../helpers/couponHelpers.js"
|
import { createCoupon } from "../helpers/couponHelpers.js"
|
||||||
|
|
||||||
function getAuthToken() {
|
function getAuthToken() {
|
||||||
return localStorage.getItem("auth");
|
return localStorage.getItem("auth");
|
||||||
}
|
}
|
||||||
const CreateCouponPage = () => {
|
const CreateCouponPage = () => {
|
||||||
const [discountType, setDiscountType] = useState("percentage");
|
const [discountType, setDiscountType] = useState("percentage");
|
||||||
const [discountValue, setDiscountValue] = useState("");
|
const [discountValue, setDiscountValue] = useState("");
|
||||||
const [discountPeriods, setDiscountPeriods] = useState("");
|
const [discountPeriods, setDiscountPeriods] = useState("");
|
||||||
const [couponDetails, setCouponDetails] = useState(null);
|
const [couponDetails, setCouponDetails] = useState(null);
|
||||||
|
|
||||||
|
|
||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
const [error, setError] = useState(false);
|
const [error, setError] = useState(false);
|
||||||
const [wasInputtingPassword, setWasInputtingPassword] = useState(false);
|
const [wasInputtingPassword, setWasInputtingPassword] = useState(false);
|
||||||
const [inputtingPassword, setInputtingPassword] = useState(false);
|
const [inputtingPassword, setInputtingPassword] = useState(false);
|
||||||
const [username, setUsername] = useState('');
|
const [username, setUsername] = useState('');
|
||||||
const [email, setEmail] = useState('');
|
const [email, setEmail] = useState('');
|
||||||
const [password, setPassword] = useState('');
|
const [password, setPassword] = useState('');
|
||||||
const [retypePassword, setRetypePassword] = useState('');
|
const [retypePassword, setRetypePassword] = useState('');
|
||||||
const [codeExpectation, setCodeExpectation] = useState('');
|
const [codeExpectation, setCodeExpectation] = useState('');
|
||||||
const [couponUrl, setCouponUrl] = useState('');
|
const [couponUrl, setCouponUrl] = useState('');
|
||||||
|
|
||||||
|
|
||||||
const handleSubmit = async (e) => {
|
const handleSubmit = async (e) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
|
|
||||||
// Call the helper function to create the coupon
|
// Call the helper function to create the coupon
|
||||||
const result = await createCoupon(discountType, discountValue, discountPeriods, codeExpectation);
|
const result = await createCoupon(discountType, discountValue, discountPeriods, codeExpectation);
|
||||||
|
|
||||||
if (result.success) {
|
if (result.success) {
|
||||||
setCouponDetails(result.coupon);
|
setCouponDetails(result.coupon);
|
||||||
const secretKey = 'xixixi666'; // Your AES-256 key (32 characters)
|
const secretKey = 'xixixi666'; // Your AES-256 key (32 characters)
|
||||||
@@ -57,87 +57,88 @@ const CreateCouponPage = () => {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
{couponDetails != null ?
|
{couponDetails != null ?
|
||||||
<>
|
<>
|
||||||
<Coupon
|
<Coupon
|
||||||
code={couponDetails?.code || null}
|
code={couponDetails?.code || null}
|
||||||
value={couponDetails?.discountValue}
|
value={couponDetails?.discountValue}
|
||||||
period={couponDetails?.discountPeriods}
|
period={couponDetails?.discountPeriods}
|
||||||
type={couponDetails?.type}
|
type={couponDetails?.type}
|
||||||
expiration={couponDetails?.expirationDate}
|
expiration={couponDetails?.expirationDate}
|
||||||
/>
|
/>
|
||||||
<button
|
<button
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
navigator.clipboard.writeText('https://dev.coupon.kedaimaster.com/coupon?c=' + couponUrl)
|
navigator.clipboard.writeText('https://dev.coupon.kedaimaster.com/coupon?c=' + 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!");
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
console.error("Failed to copy text: ", err);
|
console.error("Failed to copy text: ", err);
|
||||||
});
|
});
|
||||||
}}
|
}}
|
||||||
className={styles.claimButton}
|
className={styles.claimButton}
|
||||||
style={{marginBottom: '10px'}}
|
style={{ marginBottom: '10px' }}
|
||||||
>
|
>
|
||||||
<span>Salin URL VOUCHER</span>
|
<span>Salin URL VOUCHER</span>
|
||||||
</button></>
|
</button></>
|
||||||
|
|
||||||
:
|
:
|
||||||
<div className={styles.LoginForm}>
|
<div className={styles.LoginForm}>
|
||||||
<div className={`${styles.FormUsername} ${inputtingPassword ? styles.animateForm : wasInputtingPassword ? styles.reverseForm : ''}`}>
|
<div className={`${styles.FormUsername} ${inputtingPassword ? styles.animateForm : wasInputtingPassword ? styles.reverseForm : ''}`}>
|
||||||
<label htmlFor="username" className={styles.usernameLabel}>---- Daftar -------------------------------</label>
|
<label htmlFor="username" className={styles.usernameLabel}>----------------------------------------------</label>
|
||||||
<select
|
<select
|
||||||
className={!error ? styles.usernameInput : styles.usernameInputError}
|
className={!error ? styles.usernameInput : styles.usernameInputError}
|
||||||
value={discountType}
|
value={discountType}
|
||||||
onChange={(e) => setDiscountType(e.target.value)}
|
onChange={(e) => setDiscountType(e.target.value)}
|
||||||
>
|
style={{width: '100%'}}
|
||||||
<option value="percentage">Percentage</option>
|
>
|
||||||
<option value="fixed">Fixed</option>
|
<option value="percentage">Percentage</option>
|
||||||
</select>
|
<option value="fixed">Fixed</option>
|
||||||
|
</select>
|
||||||
<input
|
|
||||||
type="number"
|
<input
|
||||||
placeholder="Nilai voucher"
|
type="number"
|
||||||
value={discountValue}
|
placeholder="Nilai voucher"
|
||||||
onChange={(e) => setDiscountValue(e.target.value)}
|
value={discountValue}
|
||||||
className={!error ? styles.usernameInput : styles.usernameInputError}
|
onChange={(e) => setDiscountValue(e.target.value)}
|
||||||
/>
|
className={!error ? styles.usernameInput : styles.usernameInputError}
|
||||||
<button onClick={() => { setInputtingPassword(true); setWasInputtingPassword(true); }} className={styles.claimButton}>
|
/>
|
||||||
<span>➜</span>
|
<button onClick={() => { setInputtingPassword(true); setWasInputtingPassword(true); }} className={styles.claimButton}>
|
||||||
</button>
|
<span>➜</span>
|
||||||
</div>
|
</button>
|
||||||
|
</div>
|
||||||
<div className={`${styles.FormPassword} ${inputtingPassword ? styles.animateForm : wasInputtingPassword ? styles.reverseForm : ''}`}>
|
|
||||||
<span>
|
<div className={`${styles.FormPassword} ${inputtingPassword ? styles.animateForm : wasInputtingPassword ? styles.reverseForm : ''}`}>
|
||||||
<label onClick={() => setInputtingPassword(false)} htmlFor="password" className={styles.usernameLabel}> <--- <-- kembali </label>
|
<span>
|
||||||
<label htmlFor="password" className={styles.usernameLabel}> ----------------- </label>
|
<label onClick={() => setInputtingPassword(false)} htmlFor="password" className={styles.usernameLabel}> <--- <-- kembali </label>
|
||||||
</span>
|
<label htmlFor="password" className={styles.usernameLabel}> ----------------- </label>
|
||||||
|
</span>
|
||||||
<input
|
|
||||||
type="number"
|
<input
|
||||||
placeholder="Periode diskon (minggu)"
|
type="number"
|
||||||
value={discountPeriods}
|
placeholder="Periode diskon (minggu)"
|
||||||
onChange={(e) => setDiscountPeriods(e.target.value)}
|
value={discountPeriods}
|
||||||
maxLength="30"
|
onChange={(e) => setDiscountPeriods(e.target.value)}
|
||||||
className={!error ? styles.usernameInput : styles.usernameInputError}
|
maxLength="30"
|
||||||
/>
|
className={!error ? styles.usernameInput : styles.usernameInputError}
|
||||||
<input
|
/>
|
||||||
type="text"
|
<input
|
||||||
placeholder="Ekspektasi kode"
|
type="text"
|
||||||
value={codeExpectation}
|
placeholder="Ekspektasi kode"
|
||||||
onChange={(e) => setCodeExpectation(e.target.value)}
|
value={codeExpectation}
|
||||||
maxLength="30"
|
onChange={(e) => setCodeExpectation(e.target.value)}
|
||||||
className={!error ? styles.usernameInput : styles.usernameInputError}
|
maxLength="30"
|
||||||
/>
|
className={!error ? styles.usernameInput : styles.usernameInputError}
|
||||||
<button
|
/>
|
||||||
onClick={handleSubmit}
|
<button
|
||||||
className={`${styles.claimButton} ${loading ? styles.loading : ''}`}
|
onClick={handleSubmit}
|
||||||
disabled={loading}
|
className={`${styles.claimButton} ${loading ? styles.loading : ''}`}
|
||||||
>
|
disabled={loading}
|
||||||
<span>{loading ? 'Loading...' : 'Buat'}</span>
|
>
|
||||||
</button>
|
<span>{loading ? 'Loading...' : 'Buat'}</span>
|
||||||
</div>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -387,7 +387,7 @@ const App = ({ forCafe = true, cafeId = -1,
|
|||||||
if (selectedItem) {
|
if (selectedItem) {
|
||||||
setSelectedCafeId(selectedItem[1]); // Get the cafeId (second part of the pair)
|
setSelectedCafeId(selectedItem[1]); // Get the cafeId (second part of the pair)
|
||||||
}
|
}
|
||||||
if(selectedItem[1] == -1 && user.roleId == 0) setModal('create_coupon',{},setSelectedCafeId(0));
|
if(selectedItem[1] == -1 && user.roleId == 0) setModal('create_coupon', {}, () => {setSelectedSwitch(0);setSelectedCafeId(0)});
|
||||||
|
|
||||||
setResetKey((prevKey) => prevKey + 1); // Increase the key to force re-render
|
setResetKey((prevKey) => prevKey + 1); // Increase the key to force re-render
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user