From 4d135a31444699ddaaf622dfea924a474f4cd49a Mon Sep 17 00:00:00 2001 From: Yvann PONCE Date: Sun, 3 Nov 2024 09:33:16 +0100 Subject: [PATCH 1/4] common reset button --- apps/frontend-common-space/.env.development | 6 ++--- libs/ui/common/src/lib/commandsR/Item.tsx | 4 ++-- .../lib/commandsR/mealSelectionForPayment.tsx | 23 ++++++++++++++----- 3 files changed, 22 insertions(+), 11 deletions(-) diff --git a/apps/frontend-common-space/.env.development b/apps/frontend-common-space/.env.development index e995a08..f7a0e0d 100644 --- a/apps/frontend-common-space/.env.development +++ b/apps/frontend-common-space/.env.development @@ -1,6 +1,6 @@ VITE_KITCHEN_BASE_URL=https://kitchen-backend.spos.polytech.apoorva64.com VITE_MENU_BASE_URL=https://menu-backend.spos.polytech.apoorva64.com VITE_DINING_BASE_URL=https://dining-backend.spos.polytech.apoorva64.com -VITE_BFF_BASE_URL=https://backend-bff.spos.dev.polytech.apoorva64.com -VITE_PAYMENT_SHARING_BASE_URL=https://payment-sharing.spos.dev.polytech.apoorva64.com -VITE_ORDERING_BASE_URL=https://ordering.spos.dev.polytech.apoorva64.com \ No newline at end of file +VITE_BFF_BASE_URL=https://backend-bff.spos.polytech.apoorva64.com +VITE_PAYMENT_SHARING_BASE_URL=https://payment-sharing.spos.polytech.apoorva64.com +VITE_ORDERING_BASE_URL=https://ordering.spos.polytech.apoorva64.com \ No newline at end of file diff --git a/libs/ui/common/src/lib/commandsR/Item.tsx b/libs/ui/common/src/lib/commandsR/Item.tsx index 7bb2a32..b4aa7c9 100644 --- a/libs/ui/common/src/lib/commandsR/Item.tsx +++ b/libs/ui/common/src/lib/commandsR/Item.tsx @@ -22,12 +22,12 @@ export function Item(props: Readonly) { const currentTableCart: Cart = useCarts((state) => state.carts)[props.tableNumber] || []; const updateItem = useCarts((state) => state.updateItem); - + const count = currentTableCart.find( (element) => element.shortName === props.item.shortName )?.quantity ?? 0; - + return ( void; @@ -36,10 +38,6 @@ export function MealSelectionForPayment() { tableNumber: string; }>(); - function handleClose() { - console.log('Close button clicked'); - } - function handleSelectWhoPays() { console.log('Select who pays button clicked'); //navigate(`/diningRoomTables/${tableNumber}`); @@ -60,7 +58,6 @@ export function MealSelectionForPayment() { return ( table.number === tableNumber); const itemIds = currentTable ? currentTable.elements.map((element) => element.item.id) : []; + const updateItem = useCarts((state) => state.updateItem); const { data: catalog, isLoading: isLoadingCatalog } = useQuery({ queryKey: ['catalogMealSelectionForPayments', itemIds], @@ -105,6 +103,19 @@ function MealSelectionContent({ return No items available for this table.; } + function handleClose(tableItems: PaymentResponseTableDTO[], updateItem: (tableNumber: number, itemId: string, shortName: string, quantity: number) => void): void { + console.log('Close button clicked'); + for (const key in tableItems) { + const table = tableItems[key] + tableNumber = table.number + const elements = table.elements + for (const elemKey in elements){ + const element = elements[elemKey] + updateItem(tableNumber, element.item.id, element.item.name, 0) + } + } + } + return ( @@ -159,7 +170,7 @@ function MealSelectionContent({ )} -