Initial commit

This commit is contained in:
2025-10-04 18:22:24 +03:00
commit 2852c2c054
291 changed files with 38109 additions and 0 deletions

View File

@@ -0,0 +1,54 @@
"use client";
import { useEffect } from "react";
// Cart storage keys - same as in CartContext
const CART_STORAGE_KEYS = {
ITEMS: 'fascano_cart_items',
SPECIAL_REQUEST: 'fascano_special_request',
COUPON: 'fascano_coupon',
TIP: 'fascano_tip',
TABLES: 'fascano_tables',
LOCATION: 'fascano_location',
ROOM_DETAILS: 'fascano_room_details',
OFFICE_DETAILS: 'fascano_office_details',
GIFT_DETAILS: 'fascano_gift_details',
ESTIMATE_TIME: 'fascano_estimate_time',
ESTIMATE_TIME_DATE: 'fascano_estimate_time_date',
ESTIMATE_TIME_TIME: 'fascano_estimate_time_time',
COLLECTION_METHOD: 'fascano_collection_method',
} as const;
const clearCartFromLocalStorage = () => {
// Clear all cart-related data from localStorage
Object.values(CART_STORAGE_KEYS).forEach(key => {
localStorage.removeItem(key);
});
};
export default function LocalStorageHandler({
restaurantID,
restaurantName,
orderType,
}: {
restaurantID: string;
restaurantName: string;
orderType: string;
}) {
useEffect(() => {
// Check if restaurant has changed
const currentStoredRestaurantID = localStorage.getItem("restaurantID");
// If there's a stored restaurant ID and it's different from the current one, clear the cart
if (currentStoredRestaurantID && currentStoredRestaurantID !== restaurantID) {
clearCartFromLocalStorage();
}
// Update localStorage with new values
localStorage.setItem("restaurantID", restaurantID);
localStorage.setItem("restaurantName", restaurantName);
localStorage.setItem("orderType", orderType);
}, [restaurantID, restaurantName, orderType]);
return null;
}