diff --git a/apps/backend-bff/.env.development b/apps/backend-bff/.env.development index 2aa74a9..950d187 100644 --- a/apps/backend-bff/.env.development +++ b/apps/backend-bff/.env.development @@ -1,4 +1,5 @@ KITCHEN_BASE_URL=https://kitchen-backend.spos.polytech.apoorva64.com MENU_BASE_URL=https://menu-backend.spos.polytech.apoorva64.com DINING_BASE_URL=https://dining-backend.spos.polytech.apoorva64.com -ORDERING_BASE_URL=https://ordering.spos.dev.polytech.apoorva64.com +ORDERING_BASE_URL=http://localhost:3003 + diff --git a/apps/frontend-bff/.env.development b/apps/frontend-bff/.env.development index e995a08..4d7ce21 100644 --- a/apps/frontend-bff/.env.development +++ b/apps/frontend-bff/.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=http://localhost:3000 +VITE_PAYMENT_SHARING_BASE_URL=http://localhost:3002 +VITE_ORDERING_BASE_URL=http://localhost:3003 \ No newline at end of file diff --git a/apps/frontend-common-space/.env.development b/apps/frontend-common-space/.env.development index f7a0e0d..4d7ce21 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.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 +VITE_BFF_BASE_URL=http://localhost:3000 +VITE_PAYMENT_SHARING_BASE_URL=http://localhost:3002 +VITE_ORDERING_BASE_URL=http://localhost:3003 \ No newline at end of file diff --git a/apps/frontend-common-space/src/app/app.tsx b/apps/frontend-common-space/src/app/app.tsx index aada2a2..847582b 100644 --- a/apps/frontend-common-space/src/app/app.tsx +++ b/apps/frontend-common-space/src/app/app.tsx @@ -12,7 +12,7 @@ export function App() {
} /> - } /> + } /> } /> + {/* END: routes */}
diff --git a/apps/frontend-personal-space/.env.development b/apps/frontend-personal-space/.env.development index d906da5..7098116 100644 --- a/apps/frontend-personal-space/.env.development +++ b/apps/frontend-personal-space/.env.development @@ -1,5 +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_BFF_BASE_URL=http://localhost:3000 +VITE_PAYMENT_SHARING_BASE_URL=http://localhost:3002 +VITE_ORDERING_BASE_URL=http://localhost:3003 diff --git a/apps/frontend-personal-space/src/app/app.tsx b/apps/frontend-personal-space/src/app/app.tsx index e3a6e69..2e6efcc 100644 --- a/apps/frontend-personal-space/src/app/app.tsx +++ b/apps/frontend-personal-space/src/app/app.tsx @@ -9,7 +9,7 @@ export function App() {
} /> - } /> + } /> } /> {/* END: routes */} diff --git a/apps/frontend-personal-space/src/app/pages/Personal-billing.tsx b/apps/frontend-personal-space/src/app/pages/Personal-billing.tsx index 52bee02..4c93b6a 100644 --- a/apps/frontend-personal-space/src/app/pages/Personal-billing.tsx +++ b/apps/frontend-personal-space/src/app/pages/Personal-billing.tsx @@ -1,16 +1,21 @@ import { useNavigate, useParams } from 'react-router-dom'; -import { Box, Button, Typography } from '@mui/material'; +import { Box, Button, CircularProgress, Typography } from '@mui/material'; import { SSEProvider, useSSE } from 'react-hooks-sse'; -import { TableBillingShell, GroupClosedListener } from '@spos/ui/common'; -import { useMutation } from '@tanstack/react-query'; +import { GroupClosedListener, TableBillingShell } from '@spos/ui/common'; +import { useMutation, useQuery } from '@tanstack/react-query'; import { Configuration, ItemRequestDto, - PaymentsApi, PaymentsApiPaymentControllerMakePaymentRequest, - SelectedByCustomerDTO + PaymentsApi, + PaymentsApiPaymentControllerMakePaymentRequest, + SelectedByCustomerDTO, } from '@spos/clients-payment-sharing'; import { TableItem } from '@spos/services/common'; import React from 'react'; +import { + Configuration as ConfigurationGroup, + RemoteGroupApi, +} from '@spos/clients-bff'; interface TablesProps { groupId: string; @@ -180,14 +185,29 @@ const PriceDisplay = () => { export function PersonalBilling() { const navigate = useNavigate(); - const { groupId, tableNumber, ownerId } = useParams<{ - groupId: string; + const { tableNumber, ownerId } = useParams<{ tableNumber: string; ownerId: string; }>(); + const { data: groupId } = useQuery({ + queryKey: ['group', tableNumber], + queryFn: async () => { + const api = new RemoteGroupApi( + new ConfigurationGroup({ basePath: import.meta.env.VITE_BFF_BASE_URL }) + ); + + return ( + await api.remoteGroupControllerGetGroupFromTableNumber({ + tableNumber: tableNumber || '', + }) + ).data.id; + }, + }); const partialPaymentMutation = useMutation({ - mutationFn: (paymentsApiPaymentControllerMakePaymentRequest: PaymentsApiPaymentControllerMakePaymentRequest) => { + mutationFn: ( + paymentsApiPaymentControllerMakePaymentRequest: PaymentsApiPaymentControllerMakePaymentRequest + ) => { console.log(paymentsApiPaymentControllerMakePaymentRequest); return new PaymentsApi( new Configuration({ @@ -198,15 +218,21 @@ export function PersonalBilling() { }) ).paymentControllerMakePayment({ groupId: paymentsApiPaymentControllerMakePaymentRequest.groupId, - ownerId: paymentsApiPaymentControllerMakePaymentRequest.ownerId + ownerId: paymentsApiPaymentControllerMakePaymentRequest.ownerId, }); }, onSuccess: (data) => { if (data.data) { navigate('/thanks'); } - } + }, }); + if (!tableNumber) { + throw new Error('Table number is required'); + } + if (!groupId) { + return ; + } return (