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]); };