Skip to content

Commit

Permalink
Merge branch 'master' into implemBackFront
Browse files Browse the repository at this point in the history
  • Loading branch information
annadiplacido committed Nov 3, 2024
2 parents 4917a47 + 4b8d071 commit dca9ff9
Show file tree
Hide file tree
Showing 9 changed files with 137 additions and 52 deletions.
6 changes: 3 additions & 3 deletions apps/frontend-common-space/.env.development
Original file line number Diff line number Diff line change
@@ -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
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
12 changes: 12 additions & 0 deletions apps/frontend-common-space/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
## 0.7.0 (2024-11-03)


### 🚀 Features

- add assign payment skeleton ([0cc42be](https://github.com/StartUpNationLabs/spos/commit/0cc42be))


### ❤️ Thank You

- Apoorva Srinivas Appadoo

## 0.6.0 (2024-11-02)


Expand Down
2 changes: 1 addition & 1 deletion apps/frontend-common-space/package.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"name": "frontend-common-space",
"version": "0.6.0"
"version": "0.7.0"
}
13 changes: 13 additions & 0 deletions apps/frontend-common-space/src/vite-env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/// <reference types="vite/client" />
interface ImportMetaEnv {
VITE_KITCHEN_BASE_URL: string;
VITE_MENU_BASE_URL: string;
VITE_DINING_BASE_URL: string;
VITE_BFF_BASE_URL: string;
VITE_PAYMENT_SHARING_BASE_URL: string;
VITE_ORDERING_BASE_URL: string;
}

interface ImportMeta {
readonly env: ImportMetaEnv;
}
12 changes: 12 additions & 0 deletions libs/ui/common/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
## 0.36.0 (2024-11-03)


### 🚀 Features

- add assign payment skeleton ([0cc42be](https://github.com/StartUpNationLabs/spos/commit/0cc42be))


### ❤️ Thank You

- Apoorva Srinivas Appadoo

## 0.35.0 (2024-11-02)


Expand Down
2 changes: 1 addition & 1 deletion libs/ui/common/package.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"name": "ui-common",
"version": "0.35.0"
"version": "0.36.0"
}
116 changes: 77 additions & 39 deletions libs/ui/common/src/lib/billing/payementAsignee.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,43 +2,41 @@ import React from 'react';
import IconButton from '@mui/material/IconButton';
import ArrowOutwardIcon from '@mui/icons-material/ArrowOutward';
import CancelIcon from '@mui/icons-material/Cancel';
import { Configuration, PaymentsApi } from '@spos/clients-payment-sharing';
import { useMutation } from '@tanstack/react-query';
import { useNavigate } from 'react-router-dom';

const makePayment = async (data: {
userState: any;
tableId: string;
groupId: string;
userId: string;
}) => {
const api = new PaymentsApi(
new Configuration({
basePath: import.meta.env.VITE_PAYMENTS_API_BASE_PATH,
})
);

// faire cette req pour chaque type d'item (foie gras, pizza, etc) en mettant la quantité
return (
await api.paymentControllerTakeItemFromCenterTable({
itemRequestDto: {} as any,
})
).data;
};

export function PayementAsignee() {
// propriétés communes des BackButton
const buttonProps = {
color: 'black',
fontSize: '150px',
//scaleX: 0.5,
scaleY: 0.5,
};
const tableId = '1';
const groupId = '1';
const state = {};

// mutation
const { mutate } = useMutation({
mutationFn: makePayment,
});

// propriétés spécifiques des BackButton
const buttonPositions = [
{
onClick: () => alert('Top Left'),
top: '-150px',
left: '-150px',
rotation: 45,
},
{
onClick: () => alert('Top Right'),
top: '-155px',
left: '150px',
rotation: 135,
},
{
onClick: () => alert('Bottom Left'),
top: '140px',
left: '-150px',
rotation: -45,
},
{
onClick: () => alert('Bottom Right'),
top: '140px',
left: '180px',
rotation: -135,
},
];
const navigate = useNavigate();

return (
<div
Expand All @@ -57,7 +55,16 @@ export function PayementAsignee() {
justifyContent: 'center',
}}
>
<IconButton>
<IconButton
onClick={() => {
mutate({
userState: state,
tableId: tableId,
groupId: groupId,
userId: tableId + '1',
});
}}
>
<ArrowOutwardIcon
style={{
fontSize: '150px',
Expand All @@ -81,7 +88,16 @@ export function PayementAsignee() {
justifyContent: 'center',
}}
>
<IconButton>
<IconButton
onClick={() => {
mutate({
userState: state,
tableId: tableId,
groupId: groupId,
userId: tableId + '2',
});
}}
>
<ArrowOutwardIcon
style={{
fontSize: '150px',
Expand All @@ -106,7 +122,11 @@ export function PayementAsignee() {
justifyContent: 'center',
}}
>
<IconButton>
<IconButton
onClick={() => {
navigate(`/mealSelectionForPayment/${groupId}/${tableId}`);
}}
>
<CancelIcon
style={{
fontSize: '150px',
Expand All @@ -131,7 +151,16 @@ export function PayementAsignee() {
justifyContent: 'center',
}}
>
<IconButton>
<IconButton
onClick={() => {
mutate({
userState: state,
tableId: tableId,
groupId: groupId,
userId: tableId + '3',
});
}}
>
<ArrowOutwardIcon
style={{
fontSize: '150px',
Expand All @@ -156,7 +185,16 @@ export function PayementAsignee() {
justifyContent: 'center',
}}
>
<IconButton>
<IconButton
onClick={() => {
mutate({
userState: state,
tableId: tableId,
groupId: groupId,
userId: tableId + '4',
});
}}
>
<ArrowOutwardIcon
style={{
fontSize: '150px',
Expand Down
4 changes: 2 additions & 2 deletions libs/ui/common/src/lib/commandsR/Item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ export function Item(props: Readonly<ItemProps>) {
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 (
<Card sx={{ maxWidth: 250, minWidth: 150, maxHeight: 250 }}>
<CardMedia
Expand Down
22 changes: 16 additions & 6 deletions libs/ui/common/src/lib/commandsR/mealSelectionForPayment.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { useTableStore } from '../dining/stores/tableSelectionStore';
import OtherTable from './otherTables';
import useCarts from './stores/cart';


interface MealSelectionContentProps {
onClose: () => void;
onSelectWhoPays: () => void;
Expand All @@ -39,10 +40,6 @@ export function MealSelectionForPayment() {
tableNumber: string;
}>();

function handleClose() {
console.log('Close button clicked');
}

function handleSelectWhoPays() {
console.log('Select who pays button clicked');
navigate(`/payementAsignee/`);
Expand All @@ -63,7 +60,6 @@ export function MealSelectionForPayment() {
return (
<SSEProvider endpoint={`${import.meta.env.VITE_PAYMENT_SHARING_BASE_URL}/api/payments/sse/table-items/${groupId}`}>
<MealSelectionContent
onClose={handleClose}
onSelectWhoPays={handleSelectWhoPays}
onGroupClick={handleGroupClick}
onBackButtonClick={handleBackButtonClick}
Expand Down Expand Up @@ -102,6 +98,7 @@ function MealSelectionContent({
}, [currentTable, otherTables]);



const { data: catalog, isLoading: isLoadingCatalog } = useQuery({
queryKey: ['catalogMealSelectionForPayments', itemIds],
queryFn: async () => {
Expand Down Expand Up @@ -132,6 +129,19 @@ function MealSelectionContent({
}
}

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 (
<Box sx={{ pb: 10 }}>
<BackButton onClick={onBackButtonClick} />
Expand Down Expand Up @@ -189,7 +199,7 @@ function MealSelectionContent({
<OtherTable key={table.number} table={table} catalog={catalog} handleSelectItem={handleSelectItem}/>
))}
</Box>
<Footer onClose={onClose} onSelectWhoPays={onSelectWhoPays} onGroupClick={onGroupClick} />
<Footer onClose={() => handleClose(tableItems, updateItem)} onSelectWhoPays={onSelectWhoPays} onGroupClick={onGroupClick} />
</Box>
);
}
Expand Down

0 comments on commit dca9ff9

Please sign in to comment.