diff --git a/src/App.js b/src/App.js index 3b43976..240c678 100644 --- a/src/App.js +++ b/src/App.js @@ -394,14 +394,14 @@ function App() { console.log(transaction_info); // Log the updated transaction_info -const depthh = transactionList.current.findIndex( - item => item.transactionId.toString() === transaction_info.toString() -); - -setDepth(depthh); + const depthh = transactionList.current.findIndex( + item => item.transactionId.toString() === transaction_info.toString() + ); + setDepth(depthh); + console.log(transaction_info == response[0].transactionId) // If transaction_info is an empty string, set the modal - if (transaction_info == '') return false; + if (transaction_info == '' || transaction_info == response[0].transactionId) return false; else return true; } @@ -433,6 +433,7 @@ setDepth(depthh); // If transaction_info is an empty string, set the modal if (!isViewingOtherTransaction) { setModal("new_transaction", data); + navigate(`?transactionId=${data.transactionId}`, { replace: true }); } }); diff --git a/src/components/Item.js b/src/components/Item.js index ce255b1..fe3b53f 100644 --- a/src/components/Item.js +++ b/src/components/Item.js @@ -192,7 +192,7 @@ const Item = ({ whiteSpace: 'nowrap', borderRadius: '9999px', backgroundColor: !isAvailable ? 'gray' : 'unset', - backgroundImage: isAvailable && 'linear-gradient(to right, #e52535, #eb525e)', + backgroundImage: isAvailable && 'linear-gradient(to right, #e52535, #fe6d78)', padding: '0.25rem 0rem', color: 'rgb(255, 255, 255)', fontSize: '0.75rem', diff --git a/src/components/Modal.js b/src/components/Modal.js index 991f780..9e3f4d8 100644 --- a/src/components/Modal.js +++ b/src/components/Modal.js @@ -93,7 +93,7 @@ const Modal = ({ user, shop, isOpen, onClose, modalContent, deviceType, setModal {modalContent === "transaction_canceled" && ( )} - {modalContent === "transaction_pending" && } + {modalContent === "transaction_pending" && } {modalContent === "transaction_item" && } {modalContent === "transaction_confirmed" && ( diff --git a/src/helpers/transactionHelpers.js b/src/helpers/transactionHelpers.js index 85c29a9..fa1aeb3 100644 --- a/src/helpers/transactionHelpers.js +++ b/src/helpers/transactionHelpers.js @@ -47,7 +47,7 @@ export async function declineTransaction(transactionId) { return false; } - return true; + return await response.json(); } catch (error) { console.error("Error:", error); } @@ -57,7 +57,7 @@ export async function cancelTransaction(transactionId) { try { const token = getLocalStorage("auth"); const response = await fetch( - `${API_BASE_URL}/transaction/cancel-transaction/${transactionId}`, + `${API_BASE_URL}/transaction/decline-transaction/${transactionId}`, { method: "POST", headers: { diff --git a/src/pages/Transaction_pending.js b/src/pages/Transaction_pending.js index 0816aca..6c20b8d 100644 --- a/src/pages/Transaction_pending.js +++ b/src/pages/Transaction_pending.js @@ -11,7 +11,7 @@ import { getTables } from "../helpers/tableHelper"; import TableCanvas from "../components/TableCanvas"; import { useSearchParams } from "react-router-dom"; -export default function Transactions({ propsShopId, sendParam, deviceType, handleMoveToTransaction, shopImg }) { +export default function Transactions({ propsShopId, sendParam, deviceType, handleMoveToTransaction, shopImg, setModal }) { const { shopId, tableId } = useParams(); if (sendParam) sendParam({ shopId, tableId }); @@ -173,7 +173,15 @@ export default function Transactions({ propsShopId, sendParam, deviceType, handl
{ localStorage.setItem('lastTransaction', JSON.stringify(transaction)); - }} className={styles["addNewItem"]}>Tambah pesanan
+ setModal("message", { captMessage: 'Silahkan tambahkan pesanan', descMessage: 'Pembayaran akan ditambahkan ke transaksi sebelumnya.' }, null, null); + + // Dispatch the custom event + window.dispatchEvent(new Event("localStorageUpdated")); + }} + className={styles["addNewItem"]} + > + Tambah pesanan +

{transaction.serving_type === "pickup" diff --git a/src/pages/Transactions.js b/src/pages/Transactions.js index e934af9..f6dd1ba 100644 --- a/src/pages/Transactions.js +++ b/src/pages/Transactions.js @@ -121,7 +121,7 @@ export default function Transactions({ shop, shopId, propsShopId, sendParam, dev setTransactions((prevTransactions) => prevTransactions.map((transaction) => transaction.transactionId === transactionId - ? { ...transaction, confirmed: -1 } // Set to confirmed + ? c // Set to confirmed : transaction ) ); @@ -153,7 +153,7 @@ export default function Transactions({ shop, shopId, propsShopId, sendParam, dev {transaction.confirmed === 1 ? ( ) : transaction.confirmed === -1 || transaction.confirmed === -2 ? ( -
+
) : transaction.confirmed === 3 ? ( - "Transaction success" +
+ + + + + + + + + + +
) : ( @@ -196,7 +221,7 @@ export default function Transactions({ shop, shopId, propsShopId, sendParam, dev )}

:

{transaction.confirmed === 1 ? ( - "Silahkan Bayar Dengan QRIS" + (transaction.payment_type == 'cash' ? 'Silahkan Bayar Ke Kasir' : "Silahkan Bayar Dengan QRIS") ) : transaction.confirmed === -1 ? ( "Dibatalkan Oleh Kasir" ) : transaction.confirmed === -2 ? ( @@ -268,15 +293,15 @@ export default function Transactions({ shop, shopId, propsShopId, sendParam, dev Rp {calculateTotalPrice(transaction.DetailedTransactions)} +
- {(deviceType == 'clerk' && (transaction.confirmed == 0 || transaction.confirmed == 1 || transaction.confirmed == 2)) || - (deviceType == 'guestDevice' && (transaction.confirmed == 0))&& + {(deviceType == 'clerk' && (transaction.confirmed == 0 || transaction.confirmed == 1 || transaction.confirmed == 2)) && } - {transaction.payment_type != 'cash' && transaction.payment_type != 'paylater/cash' && + {deviceType == 'guestDevice' && transaction.confirmed < 2 && transaction.payment_type != 'cash' && transaction.payment_type != 'paylater/cash' && - {transaction.payment_type == 'cash' ? + {deviceType == 'guestDevice' && transaction.confirmed >=0 && transaction.confirmed < 2 && transaction.payment_type == 'cash' ? : - ((transaction.payment_type != 'paylater/cash' && transaction.payment_type != 'paylater/cashless' || isPaymentOpen) && + ((transaction.confirmed >= 0 && transaction.confirmed < 2 && transaction.payment_type != 'paylater/cash' && transaction.payment_type != 'paylater/cashless' || isPaymentOpen) &&
@@ -358,14 +378,6 @@ export default function Transactions({ shop, shopId, propsShopId, sendParam, dev
) } - {transaction.confirmed == 0 && ( -
handleDecline(transaction.transactionId)} - > - decline -
- )}
))}