This commit is contained in:
zadit frontend
2024-08-04 23:44:40 +00:00
parent 6461279b06
commit 7426ccd61b
8 changed files with 112 additions and 86 deletions

View File

@@ -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 && (
<button onClick={goToNonTable} className={styles.hapusMejaBtn}>
<button onClick={handleHapusMeja} className={styles.hapusMejaBtn}>
Hapus Meja
</button>
)}

View File

@@ -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);

View File

@@ -35,6 +35,7 @@ const TableCanvas = ({
useEffect(() => {
if (
!tables ||
tables.length === 0 ||
canvasSize.width === 0 ||
canvasSize.height === 0

View File

@@ -365,7 +365,8 @@ const TableCanvas = ({ shopId }) => {
}}
>
<ul style={{ listStyleType: "none", padding: 0, margin: 0 }}>
{tables.map((table) => (
{tables &&
tables.map((table) => (
<li
key={table.tableId}
style={{

View File

@@ -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);

View File

@@ -110,7 +110,7 @@ function CafePage({
removeConnectedGuestSides={removeConnectedGuestSides}
/>
<div style={{ marginTop: "5px" }}></div>
<SearchInput shopId={shopId} />
<SearchInput shopId={shopId} tableId={tableId} />
<div style={{ marginTop: "15px" }}></div>
<ItemTypeLister
user={user}

View File

@@ -16,7 +16,7 @@ function SearchResult({ user, shopItems, sendParam }) {
sendParam({ shopId, tableId });
const [searchValue, setSearchValue] = useState(
"dwadawa vvwqd21qb13 4kfawfdwa dhawldhawr dliawbdjawndlks",
"dwadawa vvwqd21qb13 4kfawfdwa dhawldhawr dliawbdjawndlks"
);
// Function to handle search input change
@@ -28,7 +28,7 @@ function SearchResult({ user, shopItems, sendParam }) {
.map((itemType) => {
// 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 }) {
<div style={{ marginTop: "5px" }}></div>
<SearchInput
shopId={shopId}
tableId={tableId}
autofocus={true}
onSearchChange={handleSearchChange}
/>

View File

@@ -73,7 +73,8 @@ export default function Transactions({ propsShopId, sendParam, deviceType }) {
<div style={{ marginTop: "30px" }}></div>
<TableCanvas tables={tables} selectedTable={selectedTable} />
<div className={styles.TransactionListContainer}>
{transactions.map((transaction) => (
{transactions &&
transactions.map((transaction) => (
<div
key={transaction.transactionId}
className={styles.RoundedRectangle}