diff --git a/src/components/Footer.js b/src/components/Footer.js index 3ff6f18..fc82792 100644 --- a/src/components/Footer.js +++ b/src/components/Footer.js @@ -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) => { if (scanMejaRef.current && !scanMejaRef.current.contains(event.target)) { setIsStretched(false); @@ -111,7 +117,7 @@ export default function Footer({ /> )} {tableId && isStretched && ( - )} diff --git a/src/components/SearchInput.js b/src/components/SearchInput.js index b77757a..f26e776 100644 --- a/src/components/SearchInput.js +++ b/src/components/SearchInput.js @@ -26,9 +26,7 @@ const Searchinput = styled.input` outline: none; background-color: white; border: 1px solid #ccc; - transition: - background-color 0.3s ease, - border-color 0.3s ease; + transition: background-color 0.3s ease, border-color 0.3s ease; &:focus { background-color: lightgray; @@ -44,7 +42,12 @@ const SearchIcon = styled.svg` pointer-events: none; `; -export default function SearchInput({ shopId, autofocus, onSearchChange }) { +export default function SearchInput({ + shopId, + tableId, + autofocus, + onSearchChange, +}) { const [songName, setSongName] = useState(""); const [debouncedSongName, setDebouncedSongName] = useState(""); const navigate = useNavigate(); @@ -68,14 +71,18 @@ export default function SearchInput({ shopId, autofocus, onSearchChange }) { useEffect(() => { if (siteLoaded) { //Start the timer - if (autofocus) - navigate(`/${shopId}/search?query=${encodeURIComponent(songName)}`); - else if (songName != "") - navigate(`/${shopId}/search?query=${encodeURIComponent(songName)}`); + let url = ""; + if (autofocus || songName != "") { + url = tableId + ? `/${shopId}/${tableId}/search?query=${encodeURIComponent(songName)}` + : `/${shopId}/search?query=${encodeURIComponent(songName)}`; + navigate(url); + } if (autofocus) { if (songName == "") { - navigate(`/${shopId}`); + if (tableId) navigate(`/${shopId}/${tableId}`); + else navigate(`/${shopId}`); } } if (onSearchChange) onSearchChange(songName); diff --git a/src/components/TableCanvas.js b/src/components/TableCanvas.js index ad660b2..97545b1 100644 --- a/src/components/TableCanvas.js +++ b/src/components/TableCanvas.js @@ -35,6 +35,7 @@ const TableCanvas = ({ useEffect(() => { if ( + !tables || tables.length === 0 || canvasSize.width === 0 || canvasSize.height === 0 diff --git a/src/components/TableMaps.js b/src/components/TableMaps.js index ce8ac80..1d9ee28 100644 --- a/src/components/TableMaps.js +++ b/src/components/TableMaps.js @@ -365,26 +365,27 @@ const TableCanvas = ({ shopId }) => { }} > diff --git a/src/helpers/navigationHelpers.js b/src/helpers/navigationHelpers.js index f154bb4..c7be080 100644 --- a/src/helpers/navigationHelpers.js +++ b/src/helpers/navigationHelpers.js @@ -26,8 +26,17 @@ export const useNavigationHelpers = (shopId, tableId) => { navigate(url); }; const goToScan = () => { - // Construct the base URL for the shop - let url = `/scan`; + // Construct the base URL + 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 navigate(url); diff --git a/src/pages/CafePage.js b/src/pages/CafePage.js index eaf413e..f32216d 100644 --- a/src/pages/CafePage.js +++ b/src/pages/CafePage.js @@ -110,7 +110,7 @@ function CafePage({ removeConnectedGuestSides={removeConnectedGuestSides} />
- +
{ // Filter items in the itemList based on searchValue const filteredItemList = itemType.itemList.filter((item) => - item.name.toLowerCase().includes(searchValue.toLowerCase()), + item.name.toLowerCase().includes(searchValue.toLowerCase()) ); // Return itemType with only filtered items @@ -47,6 +47,7 @@ function SearchResult({ user, shopItems, sendParam }) {
diff --git a/src/pages/Transactions.js b/src/pages/Transactions.js index 844438e..af2072d 100644 --- a/src/pages/Transactions.js +++ b/src/pages/Transactions.js @@ -73,58 +73,59 @@ export default function Transactions({ propsShopId, sendParam, deviceType }) {
- {transactions.map((transaction) => ( -
- setSelectedTable(transaction.Table || { tableId: 0 }) - } - > -

- Transaction ID: {transaction.transactionId} -

-

- Payment Type: {transaction.payment_type} -

-
    - {transaction.DetailedTransactions.map((detail) => ( -
  • - {detail.Item.name} - {detail.qty} x Rp{" "} - {detail.Item.price} -
  • - ))} -
-

- {transaction.serving_type === "pickup" - ? "Diambil di kasir" - : `Diantar ke meja nomor ${ - transaction.Table ? transaction.Table.tableNo : "N/A" - }`} -

-
- Total: - - Rp {calculateTotalPrice(transaction.DetailedTransactions)} - + {transactions && + transactions.map((transaction) => ( +
+ setSelectedTable(transaction.Table || { tableId: 0 }) + } + > +

+ Transaction ID: {transaction.transactionId} +

+

+ Payment Type: {transaction.payment_type} +

+
    + {transaction.DetailedTransactions.map((detail) => ( +
  • + {detail.Item.name} - {detail.qty} x Rp{" "} + {detail.Item.price} +
  • + ))} +
+

+ {transaction.serving_type === "pickup" + ? "Diambil di kasir" + : `Diantar ke meja nomor ${ + transaction.Table ? transaction.Table.tableNo : "N/A" + }`} +

+
+ Total: + + Rp {calculateTotalPrice(transaction.DetailedTransactions)} + +
+
+ +
-
- -
-
- ))} + ))}
);