diff --git a/libs/ui/common/src/lib/commandsR/mealSelectionForPayment.tsx b/libs/ui/common/src/lib/commandsR/mealSelectionForPayment.tsx index ab0fdf6..b194215 100644 --- a/libs/ui/common/src/lib/commandsR/mealSelectionForPayment.tsx +++ b/libs/ui/common/src/lib/commandsR/mealSelectionForPayment.tsx @@ -1,11 +1,9 @@ import React from 'react'; import Footer from '../utils/mealSelectionForPaymentFooter'; import BackButton from '../utils/backButton'; -import { CatalogDisplay } from './catalogDisplay'; import { useSSE, SSEProvider } from 'react-hooks-sse'; import { useParams } from 'react-router-dom'; -import { Box, Typography } from '@mui/material'; -import { parse } from 'path'; +import { Box, Typography, CircularProgress, Divider, Grid } from '@mui/material'; import { PaymentResponseTableDTO } from '@spos/clients-payment-sharing'; import { Item } from './Item'; import { useContext } from 'react'; @@ -33,11 +31,11 @@ interface TableItem { } export function MealSelectionForPayment() { - const { groupId, tableNumber } = useParams<{ - groupId: string; + const { groupId, tableNumber } = useParams<{ + groupId: string; tableNumber: string; }>(); - + function handleClose() { console.log('Close button clicked'); } @@ -75,7 +73,6 @@ function MealSelectionContent({ tableNumber, }: MealSelectionContentProps) { const tableItems = useSSE('message', []); - const container = React.useContext(ContainerContext); const currentTable = tableItems.find((table) => table.number === tableNumber); @@ -84,9 +81,7 @@ function MealSelectionContent({ const { data: catalog, isLoading: isLoadingCatalog } = useQuery({ queryKey: ['catalogMealSelectionForPayments', itemIds], queryFn: async () => { - const catalogService: CatalogueService = container.get( - TYPES.CatalogueService - ); + const catalogService: CatalogueService = container.get(TYPES.CatalogueService); return catalogService.getFullItemFromItemIdsArray(itemIds); }, enabled: itemIds.length > 0, @@ -94,54 +89,72 @@ function MealSelectionContent({ }); if (!tableItems || tableItems.length === 0) { - return

Loading for elements in this table...

; + return ( + + + + ); } if (!currentTable) { - return

No element available for this table.

; + return No items available for this table.; } return ( -
+ - - My Table (Number {currentTable.number}) + + + My table (Nb {currentTable.number}) + + + {isLoadingCatalog ? ( -

Chargement du catalogue...

+ + + ) : ( - currentTable.elements.map((element, elementIndex) => { - const catalogItem = catalog?.find((item) => item._id === element.item.id); - const isSelected = itemIds.includes(element.item.id); - - return ( - - Nom: {element.item.name} - Prix: {element.item.price} € - Quantité restante: {element.remaining} - Sur la table: {element.onTable} - console.log('Item selected')} - remaining={element.remaining} - isSelected={isSelected} - /> - - ); - }) + + + {currentTable.elements.map((element, index) => { + const catalogItem = catalog?.find((item) => item._id === element.item.id); + const isSelected = itemIds.includes(element.item.id); + + return ( + + + console.log('Item selected')} + remaining={element.remaining} + isSelected={isSelected} + /> + + ); + })} + + )}
+ ); } - export default MealSelectionForPayment;