Skip to content

Commit 900f27e

Browse files
committed
Testing
1 parent 199b16c commit 900f27e

File tree

4 files changed

+50
-0
lines changed

4 files changed

+50
-0
lines changed

.firebase/hosting.YnVpbGQ.cache

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
index.html,1576704022747,7274a1e92dc0ca83c7d36ef1db0b75e2b7d3639b3a3b8f709938f4b2a7b06086
2+
service-worker.js,1576704022915,47c4de2bd6a77ca047011db83bdc4e04f826bac159021d03c06024cb541c2119
3+
asset-manifest.json,1576704022747,89d18b7b2464d73720b955142dcb7bd7091828a78e739fb2e68e39c2b784d03c
4+
static/css/main.a808de29.css.map,1576704022815,9f123cf3f58d4abe42b67efec01aa7ec3344489e415d947cf6cf9e2de52f1f30
5+
static/css/main.a808de29.css,1576704022759,ffb3b04c239907c437e085f96c2701be056bed4752c1024e0b1af520ac7b2043
6+
static/js/main.ef653e2f.js,1576704022758,a02be7cedb651ad6e301f21366373d0afff5b08e7f52d4e99da856aa656bc251
7+
static/js/main.ef653e2f.js.map,1576704022815,4121d93e68d65e534c2ca87c29645a41b18076cd84819965388c680529371828

.firebaserc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"projects": {
3+
"default": "bookligo-2b01b"
4+
}
5+
}

firebase.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"hosting": {
3+
"public": "build",
4+
"ignore": [
5+
"firebase.json",
6+
"**/.*",
7+
"**/node_modules/**"
8+
],
9+
"rewrites": [
10+
{
11+
"source": "**",
12+
"destination": "/index.html"
13+
}
14+
]
15+
}
16+
}

src/data/BookligoModel.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ class BookligoModel extends ObservableModel {
77
this.state = localStorage.getItem('state') ? JSON.parse(localStorage.getItem('state')) : {
88
numberOfBooks: 0,
99
bookList: [],
10+
shoppingCart: [],
1011
price: 0,
1112
};
1213
}
@@ -45,6 +46,27 @@ class BookligoModel extends ObservableModel {
4546
return this.state.bookList;
4647
}
4748

49+
//Returns all the books on the shopping cart.
50+
getFullShoppingCart() {
51+
return this.state.shoppingCart;
52+
}
53+
54+
//Returns the total price of the shopping cart (price per book multiplied by number of books).
55+
getTotalShoppingCartPrice() {
56+
let prices = this.state.shoppingCart.map(book => {
57+
if(book.saleInfo.saleability === "FOR_SALE")
58+
{
59+
return book.saleInfo.retailPrice.amount;
60+
}
61+
else {
62+
return 0;
63+
}
64+
});
65+
let noOfBooks = this.getNumberOfBooks();
66+
let sum = prices.reduce((total, amount) => total + amount, 0);
67+
return sum*noOfBooks;
68+
}
69+
4870
//Returns all ingredients for all the dishes on the menu.
4971
/*getAllIngredients() {
5072
return this.state.bookList.map(book => book.extendedIngredients.map(name => name.name)).flat();

0 commit comments

Comments
 (0)