forked from firtman/coffeemasters-vanilla
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
27 lines (23 loc) · 881 Bytes
/
app.js
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
import Store from './services/Store.js';
import API from './services/API.js';
import { loadData } from './services/Menu.js';
import Router from './services/Router.js';
// Web Components
import { MenuPage } from './components/MenuPage.js';
import { DetailsPage } from './components/DetailsPage.js';
import { OrderPage } from './components/OrderPage.js';
import { ProductItem } from './components/ProductItem.js';
import { CartItem } from './components/CartItem.js';
window.app = {}
app.store = Store;
app.router = Router;
window.addEventListener("DOMContentLoaded", async () => {
loadData();
app.router.init();
});
window.addEventListener("appcartchange", event => {
const badge = document.getElementById("badge");
const qty = app.store.cart.reduce((acc, item) => {acc + item.quantity, 0});
badge.textContent = qty.quantity;
badge.hidden = qty == 0;
});