diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index 93f2cdb..21ce3db 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -10,6 +10,7 @@ import {ConfirmationDialogProvider} from "./utils/ConfirmationDialogContext.tsx" import {ApiAccessProvider} from "./utils/ApiAccessContext.tsx"; import {NotificationContextProvider} from "./utils/NotificationContext.tsx"; import {WebsocketContextProvider} from "./utils/WebsocketContext.tsx"; +import {DataModalDialogProvider} from "./utils/DataModalDialogContext.tsx"; function NamedLogo() { return @@ -54,35 +55,37 @@ function App() { - - - - - - + + + + + + + - theme.zIndex.drawer + 1}} color="info"> - - + theme.zIndex.drawer + 1}} color="info"> + + - + - - - + + + - - + + -
- -
+
+ +
+
-
-
-
-
+ + + +
diff --git a/frontend/src/components/orders/ordersList/NewOrder.tsx b/frontend/src/components/orders/ordersList/NewOrder.tsx new file mode 100644 index 0000000..8109728 --- /dev/null +++ b/frontend/src/components/orders/ordersList/NewOrder.tsx @@ -0,0 +1,7 @@ +import {Restaurant} from "../../../../build/generated-ts/api"; + +export default function NewOrder({restaurant}: { restaurant: Restaurant }) { + return
+ New order for {restaurant.name} !!!! +
+} diff --git a/frontend/src/components/orders/ordersList/NewOrderButton.tsx b/frontend/src/components/orders/ordersList/NewOrderButton.tsx index df71243..884acda 100644 --- a/frontend/src/components/orders/ordersList/NewOrderButton.tsx +++ b/frontend/src/components/orders/ordersList/NewOrderButton.tsx @@ -7,6 +7,8 @@ import {useApiAccess} from "../../../utils/ApiAccessContext.tsx"; import {useNotification} from "../../../utils/NotificationContext.tsx"; import {RestaurantOrderable} from "../types.ts"; import RestaurantAvatar from "../../restaurant/RestaurantAvatar.tsx"; +import {useDataModalDialog} from "../../../utils/DataModalDialogContext.tsx"; +import NewOrder from "./NewOrder.tsx"; type NewOrderButtonProps = { restaurants: RestaurantOrderable[], @@ -25,21 +27,29 @@ export default function NewOrderButton({restaurants, onChange}: NewOrderButtonPr const handleClick = (event: React.MouseEvent) => setAnchorEl(event.currentTarget); const handleClose = () => setAnchorEl(null); - const handleRestaurantClick = useCallback((restaurant: Restaurant) => { - setIsLoading(true); + const {openDialog} = useDataModalDialog() + const handleRestaurantClick = useCallback(async (restaurant: Restaurant) => { handleClose() - orderApi.createOrder(restaurant.id) - .then(res => res.data) - .then(newOrder => { - notifySuccess("Neue Bestellung eröffnet") - onChange() - navigate({pathname: `/order/${newOrder.id}`}); - }) - .catch(e => notifyError("Konnte keine neue Order erstellen", e)) - .finally(() => setIsLoading(false)) - }, [navigate, onChange, orderApi, notifyError, notifySuccess]); + await openDialog({ + content: , + + onSuccess: () => { + setIsLoading(true); + + orderApi.createOrder(restaurant.id) + .then(res => res.data) + .then(newOrder => { + notifySuccess("Neue Bestellung eröffnet") + onChange() + navigate({pathname: `/order/${newOrder.id}`}); + }) + .catch(e => notifyError("Konnte keine neue Order erstellen", e)) + .finally(() => setIsLoading(false)) + } + }) + }, [openDialog, orderApi, notifySuccess, onChange, navigate, notifyError]); return <>