File size: 1,310 Bytes
1b4923e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// Initialize local storage if not exists
if (!localStorage.getItem('restaurantData')) {
    const initialData = {
        orders: [],
        reservations: [],
        menuItems: [
            { id: 1, name: "Margherita Pizza", price: 12.99, category: "Main Course" },
            { id: 2, name: "Caesar Salad", price: 8.99, category: "Appetizer" },
            { id: 3, name: "Tiramisu", price: 6.99, category: "Dessert" }
        ],
        staff: [
            { id: 1, name: "John Doe", role: "Chef", shift: "Morning" },
            { id: 2, name: "Jane Smith", role: "Waiter", shift: "Evening" }
        ],
        stats: {
            dailyRevenue: 0,
            monthlyRevenue: 0,
            activeOrders: 0,
            todaysReservations: 0
        }
    };
    localStorage.setItem('restaurantData', JSON.stringify(initialData));
}

// Utility functions
function updateLocalStorage(data) {
    localStorage.setItem('restaurantData', JSON.stringify(data));
}

function getRestaurantData() {
    return JSON.parse(localStorage.getItem('restaurantData'));
}

// Event bus for component communication
const eventBus = new EventTarget();

// Export functions to be used in components
window.restaurantApp = {
    getData: getRestaurantData,
    updateData: updateLocalStorage,
    eventBus: eventBus
};