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,26 +365,27 @@ const TableCanvas = ({ shopId }) => {
}}
>
<ul style={{ listStyleType: "none", padding: 0, margin: 0 }}>
{tables.map((table) => (
<li
key={table.tableId}
style={{
backgroundColor: "white",
marginBottom: "10px",
padding: "10px",
borderRadius: "4px",
boxShadow: "0 2px 4px rgba(0,0,0,0.1)",
}}
onClick={() => handleSelect(table)}
>
{
table.tableNo === 0
? "Clerk" // Display "Clerk" if tableNo is 0
: `Table ${table.tableNo}` // Display "Table {tableNo}" otherwise
}{" "}
- Position: ({table.xposition}, {table.yposition})
</li>
))}
{tables &&
tables.map((table) => (
<li
key={table.tableId}
style={{
backgroundColor: "white",
marginBottom: "10px",
padding: "10px",
borderRadius: "4px",
boxShadow: "0 2px 4px rgba(0,0,0,0.1)",
}}
onClick={() => handleSelect(table)}
>
{
table.tableNo === 0
? "Clerk" // Display "Clerk" if tableNo is 0
: `Table ${table.tableNo}` // Display "Table {tableNo}" otherwise
}{" "}
- Position: ({table.xposition}, {table.yposition})
</li>
))}
</ul>
</div>
</div>

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,58 +73,59 @@ export default function Transactions({ propsShopId, sendParam, deviceType }) {
<div style={{ marginTop: "30px" }}></div>
<TableCanvas tables={tables} selectedTable={selectedTable} />
<div className={styles.TransactionListContainer}>
{transactions.map((transaction) => (
<div
key={transaction.transactionId}
className={styles.RoundedRectangle}
onClick={() =>
setSelectedTable(transaction.Table || { tableId: 0 })
}
>
<h2 className={styles["Transactions-detail"]}>
Transaction ID: {transaction.transactionId}
</h2>
<h2 className={styles["Transactions-detail"]}>
Payment Type: {transaction.payment_type}
</h2>
<ul>
{transaction.DetailedTransactions.map((detail) => (
<li key={detail.detailedTransactionId}>
<span>{detail.Item.name}</span> - {detail.qty} x Rp{" "}
{detail.Item.price}
</li>
))}
</ul>
<h2 className={styles["Transactions-detail"]}>
{transaction.serving_type === "pickup"
? "Diambil di kasir"
: `Diantar ke meja nomor ${
transaction.Table ? transaction.Table.tableNo : "N/A"
}`}
</h2>
<div className={styles.TotalContainer}>
<span>Total:</span>
<span>
Rp {calculateTotalPrice(transaction.DetailedTransactions)}
</span>
{transactions &&
transactions.map((transaction) => (
<div
key={transaction.transactionId}
className={styles.RoundedRectangle}
onClick={() =>
setSelectedTable(transaction.Table || { tableId: 0 })
}
>
<h2 className={styles["Transactions-detail"]}>
Transaction ID: {transaction.transactionId}
</h2>
<h2 className={styles["Transactions-detail"]}>
Payment Type: {transaction.payment_type}
</h2>
<ul>
{transaction.DetailedTransactions.map((detail) => (
<li key={detail.detailedTransactionId}>
<span>{detail.Item.name}</span> - {detail.qty} x Rp{" "}
{detail.Item.price}
</li>
))}
</ul>
<h2 className={styles["Transactions-detail"]}>
{transaction.serving_type === "pickup"
? "Diambil di kasir"
: `Diantar ke meja nomor ${
transaction.Table ? transaction.Table.tableNo : "N/A"
}`}
</h2>
<div className={styles.TotalContainer}>
<span>Total:</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 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>
);