ok
This commit is contained in:
@@ -15,6 +15,8 @@ import PeriodCharts from '../components/PeriodCharts.js';
|
||||
|
||||
import Coupon from "../components/Coupon.js";
|
||||
|
||||
import CreateCouponPage from "./CreateCoupon.js";
|
||||
|
||||
const RoundedRectangle = ({
|
||||
onClick,
|
||||
title,
|
||||
@@ -306,12 +308,12 @@ const App = ({ forCafe = true, cafeId = -1,
|
||||
let updatedFullTexts;
|
||||
|
||||
if (otherCafes.length === 0) {
|
||||
updatedFullTexts = [["Buat bisnis", 0]];
|
||||
updatedFullTexts = [[user.roleId == 0 ? "Buat Voucher":"Buat bisnis", 0]];
|
||||
setSelectedCafeId(-1);
|
||||
} else if (otherCafes.length === 1) {
|
||||
updatedFullTexts = [
|
||||
[otherCafes[0].name || otherCafes[0].username, otherCafes[0].cafeId || otherCafes[0].userId],
|
||||
["Buat bisnis", -1]
|
||||
[user.roleId == 0 ? "Buat Voucher":"Buat bisnis", -1]
|
||||
];
|
||||
|
||||
setSelectedCafeId(otherCafes[0].cafeId); // Get the cafeId (second part of the pair)
|
||||
@@ -319,7 +321,7 @@ const App = ({ forCafe = true, cafeId = -1,
|
||||
updatedFullTexts = [
|
||||
["semua", 0], // First entry is "semua"
|
||||
...otherCafes.map(item => [item.name || item.username, item.cafeId || item.userId]), // Map over cafes to get name and cafeId pairs
|
||||
["tambah bisnis +", -1] // Add the "+" entry
|
||||
[user.roleId == 0 ? "Buat Voucher":"Tambah Bisnis +", -1] // Add the "+" entry
|
||||
];
|
||||
|
||||
setSelectedCafeId(0);
|
||||
@@ -385,6 +387,7 @@ const App = ({ forCafe = true, cafeId = -1,
|
||||
if (selectedItem) {
|
||||
setSelectedCafeId(selectedItem[1]); // Get the cafeId (second part of the pair)
|
||||
}
|
||||
if(selectedItem[1] == -1 && user.roleId == 0) setModal('create_coupon',{},setSelectedCafeId(0));
|
||||
|
||||
setResetKey((prevKey) => prevKey + 1); // Increase the key to force re-render
|
||||
};
|
||||
@@ -654,61 +657,6 @@ const App = ({ forCafe = true, cafeId = -1,
|
||||
}
|
||||
</div>
|
||||
}
|
||||
{!forCafe && selectedCafeId == -1 &&
|
||||
<div style={{
|
||||
textAlign: "center",
|
||||
}}>
|
||||
<div
|
||||
style={{
|
||||
display: "flex",
|
||||
flexWrap: "wrap",
|
||||
justifyContent: "center",
|
||||
padding: "20px",
|
||||
}}
|
||||
>
|
||||
{user?.roleId == 0 ?
|
||||
<RoundedRectangle
|
||||
title={"Masukkan nama bisnis"}
|
||||
width="calc(100% - 10px)"
|
||||
>
|
||||
<input
|
||||
value={itemName}
|
||||
onChange={(e) => setItemName(e.target.value)}
|
||||
style={{
|
||||
width: '70%',
|
||||
fontSize: '25px',
|
||||
borderRadius: '7px',
|
||||
border: '1px solid black'
|
||||
}}
|
||||
/>
|
||||
</RoundedRectangle>
|
||||
:
|
||||
|
||||
<RoundedRectangle
|
||||
title={"Masukkan nama bisnis"}
|
||||
width="calc(100% - 10px)"
|
||||
>
|
||||
<input
|
||||
value={itemName}
|
||||
onChange={(e) => setItemName(e.target.value)}
|
||||
style={{
|
||||
width: '70%',
|
||||
fontSize: '25px',
|
||||
borderRadius: '7px',
|
||||
border: '1px solid black'
|
||||
}}
|
||||
/>
|
||||
</RoundedRectangle>
|
||||
|
||||
}
|
||||
<RoundedRectangle
|
||||
title={user?.roleId === 0 ? "Buat Voucher" : "Buat Bisnis"}
|
||||
width="calc(100% - 10px)"
|
||||
onClick={handleClick}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
{user?.roleId == 1 &&
|
||||
<>
|
||||
<div className={`${styles.couponContainer}`}>
|
||||
|
||||
Reference in New Issue
Block a user