refactor calculation code

- implement fee
- centralize the code
This commit is contained in:
2025-10-27 08:08:22 +03:00
parent 251e7a9369
commit cd49a3756f
13 changed files with 395 additions and 284 deletions

View File

@@ -0,0 +1,18 @@
import { updateRestaurant } from "features/order/orderSlice";
import { useEffect } from "react";
import { useAppDispatch } from "redux/hooks";
import { RestaurantDetails } from "utils/types/appTypes";
/**
* Custom hook to automatically load restaurant into Redux store
* when restaurant data is available
*/
export const useRestaurant = (restaurant: RestaurantDetails | undefined) => {
const dispatch = useAppDispatch();
useEffect(() => {
if (restaurant) {
dispatch(updateRestaurant(restaurant));
}
}, [restaurant, dispatch]);
};