pagi
This commit is contained in:
@@ -28,6 +28,12 @@ export default function Footer({
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleHapusMeja = (event) => {
|
||||||
|
event.stopPropagation(); // Ensure click event doesn't propagate
|
||||||
|
goToNonTable();
|
||||||
|
setIsStretched(false);
|
||||||
|
};
|
||||||
|
|
||||||
const handleClickOutside = (event) => {
|
const handleClickOutside = (event) => {
|
||||||
if (scanMejaRef.current && !scanMejaRef.current.contains(event.target)) {
|
if (scanMejaRef.current && !scanMejaRef.current.contains(event.target)) {
|
||||||
setIsStretched(false);
|
setIsStretched(false);
|
||||||
@@ -111,7 +117,7 @@ export default function Footer({
|
|||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
{tableId && isStretched && (
|
{tableId && isStretched && (
|
||||||
<button onClick={goToNonTable} className={styles.hapusMejaBtn}>
|
<button onClick={handleHapusMeja} className={styles.hapusMejaBtn}>
|
||||||
Hapus Meja
|
Hapus Meja
|
||||||
</button>
|
</button>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -26,9 +26,7 @@ const Searchinput = styled.input`
|
|||||||
outline: none;
|
outline: none;
|
||||||
background-color: white;
|
background-color: white;
|
||||||
border: 1px solid #ccc;
|
border: 1px solid #ccc;
|
||||||
transition:
|
transition: background-color 0.3s ease, border-color 0.3s ease;
|
||||||
background-color 0.3s ease,
|
|
||||||
border-color 0.3s ease;
|
|
||||||
|
|
||||||
&:focus {
|
&:focus {
|
||||||
background-color: lightgray;
|
background-color: lightgray;
|
||||||
@@ -44,7 +42,12 @@ const SearchIcon = styled.svg`
|
|||||||
pointer-events: none;
|
pointer-events: none;
|
||||||
`;
|
`;
|
||||||
|
|
||||||
export default function SearchInput({ shopId, autofocus, onSearchChange }) {
|
export default function SearchInput({
|
||||||
|
shopId,
|
||||||
|
tableId,
|
||||||
|
autofocus,
|
||||||
|
onSearchChange,
|
||||||
|
}) {
|
||||||
const [songName, setSongName] = useState("");
|
const [songName, setSongName] = useState("");
|
||||||
const [debouncedSongName, setDebouncedSongName] = useState("");
|
const [debouncedSongName, setDebouncedSongName] = useState("");
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
@@ -68,14 +71,18 @@ export default function SearchInput({ shopId, autofocus, onSearchChange }) {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (siteLoaded) {
|
if (siteLoaded) {
|
||||||
//Start the timer
|
//Start the timer
|
||||||
if (autofocus)
|
let url = "";
|
||||||
navigate(`/${shopId}/search?query=${encodeURIComponent(songName)}`);
|
if (autofocus || songName != "") {
|
||||||
else if (songName != "")
|
url = tableId
|
||||||
navigate(`/${shopId}/search?query=${encodeURIComponent(songName)}`);
|
? `/${shopId}/${tableId}/search?query=${encodeURIComponent(songName)}`
|
||||||
|
: `/${shopId}/search?query=${encodeURIComponent(songName)}`;
|
||||||
|
navigate(url);
|
||||||
|
}
|
||||||
|
|
||||||
if (autofocus) {
|
if (autofocus) {
|
||||||
if (songName == "") {
|
if (songName == "") {
|
||||||
navigate(`/${shopId}`);
|
if (tableId) navigate(`/${shopId}/${tableId}`);
|
||||||
|
else navigate(`/${shopId}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (onSearchChange) onSearchChange(songName);
|
if (onSearchChange) onSearchChange(songName);
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ const TableCanvas = ({
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (
|
if (
|
||||||
|
!tables ||
|
||||||
tables.length === 0 ||
|
tables.length === 0 ||
|
||||||
canvasSize.width === 0 ||
|
canvasSize.width === 0 ||
|
||||||
canvasSize.height === 0
|
canvasSize.height === 0
|
||||||
|
|||||||
@@ -365,26 +365,27 @@ const TableCanvas = ({ shopId }) => {
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<ul style={{ listStyleType: "none", padding: 0, margin: 0 }}>
|
<ul style={{ listStyleType: "none", padding: 0, margin: 0 }}>
|
||||||
{tables.map((table) => (
|
{tables &&
|
||||||
<li
|
tables.map((table) => (
|
||||||
key={table.tableId}
|
<li
|
||||||
style={{
|
key={table.tableId}
|
||||||
backgroundColor: "white",
|
style={{
|
||||||
marginBottom: "10px",
|
backgroundColor: "white",
|
||||||
padding: "10px",
|
marginBottom: "10px",
|
||||||
borderRadius: "4px",
|
padding: "10px",
|
||||||
boxShadow: "0 2px 4px rgba(0,0,0,0.1)",
|
borderRadius: "4px",
|
||||||
}}
|
boxShadow: "0 2px 4px rgba(0,0,0,0.1)",
|
||||||
onClick={() => handleSelect(table)}
|
}}
|
||||||
>
|
onClick={() => handleSelect(table)}
|
||||||
{
|
>
|
||||||
table.tableNo === 0
|
{
|
||||||
? "Clerk" // Display "Clerk" if tableNo is 0
|
table.tableNo === 0
|
||||||
: `Table ${table.tableNo}` // Display "Table {tableNo}" otherwise
|
? "Clerk" // Display "Clerk" if tableNo is 0
|
||||||
}{" "}
|
: `Table ${table.tableNo}` // Display "Table {tableNo}" otherwise
|
||||||
- Position: ({table.xposition}, {table.yposition})
|
}{" "}
|
||||||
</li>
|
- Position: ({table.xposition}, {table.yposition})
|
||||||
))}
|
</li>
|
||||||
|
))}
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -26,8 +26,17 @@ export const useNavigationHelpers = (shopId, tableId) => {
|
|||||||
navigate(url);
|
navigate(url);
|
||||||
};
|
};
|
||||||
const goToScan = () => {
|
const goToScan = () => {
|
||||||
// Construct the base URL for the shop
|
// Construct the base URL
|
||||||
let url = `/scan`;
|
let url = "/scan";
|
||||||
|
|
||||||
|
// Append query parameters conditionally
|
||||||
|
const queryParams = new URLSearchParams();
|
||||||
|
if (shopId) queryParams.append("next", shopId);
|
||||||
|
|
||||||
|
// Set the URL with query parameters
|
||||||
|
if (queryParams.toString()) {
|
||||||
|
url += `?${queryParams.toString()}`;
|
||||||
|
}
|
||||||
|
|
||||||
// Perform the navigation
|
// Perform the navigation
|
||||||
navigate(url);
|
navigate(url);
|
||||||
|
|||||||
@@ -110,7 +110,7 @@ function CafePage({
|
|||||||
removeConnectedGuestSides={removeConnectedGuestSides}
|
removeConnectedGuestSides={removeConnectedGuestSides}
|
||||||
/>
|
/>
|
||||||
<div style={{ marginTop: "5px" }}></div>
|
<div style={{ marginTop: "5px" }}></div>
|
||||||
<SearchInput shopId={shopId} />
|
<SearchInput shopId={shopId} tableId={tableId} />
|
||||||
<div style={{ marginTop: "15px" }}></div>
|
<div style={{ marginTop: "15px" }}></div>
|
||||||
<ItemTypeLister
|
<ItemTypeLister
|
||||||
user={user}
|
user={user}
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ function SearchResult({ user, shopItems, sendParam }) {
|
|||||||
sendParam({ shopId, tableId });
|
sendParam({ shopId, tableId });
|
||||||
|
|
||||||
const [searchValue, setSearchValue] = useState(
|
const [searchValue, setSearchValue] = useState(
|
||||||
"dwadawa vvwqd21qb13 4kfawfdwa dhawldhawr dliawbdjawndlks",
|
"dwadawa vvwqd21qb13 4kfawfdwa dhawldhawr dliawbdjawndlks"
|
||||||
);
|
);
|
||||||
|
|
||||||
// Function to handle search input change
|
// Function to handle search input change
|
||||||
@@ -28,7 +28,7 @@ function SearchResult({ user, shopItems, sendParam }) {
|
|||||||
.map((itemType) => {
|
.map((itemType) => {
|
||||||
// Filter items in the itemList based on searchValue
|
// Filter items in the itemList based on searchValue
|
||||||
const filteredItemList = itemType.itemList.filter((item) =>
|
const filteredItemList = itemType.itemList.filter((item) =>
|
||||||
item.name.toLowerCase().includes(searchValue.toLowerCase()),
|
item.name.toLowerCase().includes(searchValue.toLowerCase())
|
||||||
);
|
);
|
||||||
|
|
||||||
// Return itemType with only filtered items
|
// Return itemType with only filtered items
|
||||||
@@ -47,6 +47,7 @@ function SearchResult({ user, shopItems, sendParam }) {
|
|||||||
<div style={{ marginTop: "5px" }}></div>
|
<div style={{ marginTop: "5px" }}></div>
|
||||||
<SearchInput
|
<SearchInput
|
||||||
shopId={shopId}
|
shopId={shopId}
|
||||||
|
tableId={tableId}
|
||||||
autofocus={true}
|
autofocus={true}
|
||||||
onSearchChange={handleSearchChange}
|
onSearchChange={handleSearchChange}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -73,58 +73,59 @@ export default function Transactions({ propsShopId, sendParam, deviceType }) {
|
|||||||
<div style={{ marginTop: "30px" }}></div>
|
<div style={{ marginTop: "30px" }}></div>
|
||||||
<TableCanvas tables={tables} selectedTable={selectedTable} />
|
<TableCanvas tables={tables} selectedTable={selectedTable} />
|
||||||
<div className={styles.TransactionListContainer}>
|
<div className={styles.TransactionListContainer}>
|
||||||
{transactions.map((transaction) => (
|
{transactions &&
|
||||||
<div
|
transactions.map((transaction) => (
|
||||||
key={transaction.transactionId}
|
<div
|
||||||
className={styles.RoundedRectangle}
|
key={transaction.transactionId}
|
||||||
onClick={() =>
|
className={styles.RoundedRectangle}
|
||||||
setSelectedTable(transaction.Table || { tableId: 0 })
|
onClick={() =>
|
||||||
}
|
setSelectedTable(transaction.Table || { tableId: 0 })
|
||||||
>
|
}
|
||||||
<h2 className={styles["Transactions-detail"]}>
|
>
|
||||||
Transaction ID: {transaction.transactionId}
|
<h2 className={styles["Transactions-detail"]}>
|
||||||
</h2>
|
Transaction ID: {transaction.transactionId}
|
||||||
<h2 className={styles["Transactions-detail"]}>
|
</h2>
|
||||||
Payment Type: {transaction.payment_type}
|
<h2 className={styles["Transactions-detail"]}>
|
||||||
</h2>
|
Payment Type: {transaction.payment_type}
|
||||||
<ul>
|
</h2>
|
||||||
{transaction.DetailedTransactions.map((detail) => (
|
<ul>
|
||||||
<li key={detail.detailedTransactionId}>
|
{transaction.DetailedTransactions.map((detail) => (
|
||||||
<span>{detail.Item.name}</span> - {detail.qty} x Rp{" "}
|
<li key={detail.detailedTransactionId}>
|
||||||
{detail.Item.price}
|
<span>{detail.Item.name}</span> - {detail.qty} x Rp{" "}
|
||||||
</li>
|
{detail.Item.price}
|
||||||
))}
|
</li>
|
||||||
</ul>
|
))}
|
||||||
<h2 className={styles["Transactions-detail"]}>
|
</ul>
|
||||||
{transaction.serving_type === "pickup"
|
<h2 className={styles["Transactions-detail"]}>
|
||||||
? "Diambil di kasir"
|
{transaction.serving_type === "pickup"
|
||||||
: `Diantar ke meja nomor ${
|
? "Diambil di kasir"
|
||||||
transaction.Table ? transaction.Table.tableNo : "N/A"
|
: `Diantar ke meja nomor ${
|
||||||
}`}
|
transaction.Table ? transaction.Table.tableNo : "N/A"
|
||||||
</h2>
|
}`}
|
||||||
<div className={styles.TotalContainer}>
|
</h2>
|
||||||
<span>Total:</span>
|
<div className={styles.TotalContainer}>
|
||||||
<span>
|
<span>Total:</span>
|
||||||
Rp {calculateTotalPrice(transaction.DetailedTransactions)}
|
<span>
|
||||||
</span>
|
Rp {calculateTotalPrice(transaction.DetailedTransactions)}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div className={styles.TotalContainer}>
|
||||||
|
<button
|
||||||
|
className={styles.PayButton}
|
||||||
|
onClick={() => handleConfirm(transaction.transactionId)}
|
||||||
|
disabled={transaction.confirmed || isPaymentLoading} // Disable button if confirmed or loading
|
||||||
|
>
|
||||||
|
{isPaymentLoading ? (
|
||||||
|
<ColorRing height="50" width="50" color="white" />
|
||||||
|
) : transaction.confirmed ? (
|
||||||
|
"Confirmed" // Display "Confirmed" if the transaction is confirmed
|
||||||
|
) : (
|
||||||
|
"Confirm" // Display "Confirm" otherwise
|
||||||
|
)}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className={styles.TotalContainer}>
|
))}
|
||||||
<button
|
|
||||||
className={styles.PayButton}
|
|
||||||
onClick={() => handleConfirm(transaction.transactionId)}
|
|
||||||
disabled={transaction.confirmed || isPaymentLoading} // Disable button if confirmed or loading
|
|
||||||
>
|
|
||||||
{isPaymentLoading ? (
|
|
||||||
<ColorRing height="50" width="50" color="white" />
|
|
||||||
) : transaction.confirmed ? (
|
|
||||||
"Confirmed" // Display "Confirmed" if the transaction is confirmed
|
|
||||||
) : (
|
|
||||||
"Confirm" // Display "Confirm" otherwise
|
|
||||||
)}
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
))}
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user