-
Notifications
You must be signed in to change notification settings - Fork 893
18r Solution #119
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 18r
Are you sure you want to change the base?
18r Solution #119
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -112,4 +112,13 @@ function renderProductsGrid() { | |
| const search = document.querySelector('.js-search-bar').value; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. One extra featured that I find useful: // using cart-class.js oop
import { cart } from '../data/cart-class.js'
import { products, loadProductsFetch } from '../data/products.js'
import { renderAmazonHeader, displayCartQuantity } from './partials/header.js'
renderAmazonHeader()
loadPage()
// loading products from backend https://supersimplebackend.dev/products
async function loadPage() {
await loadProductsFetch().catch(() => alert('error'))
renderProductsGrid()
} |
||
| window.location.href = `amazon.html?search=${search}`; | ||
| }); | ||
|
|
||
| // Extra feature: searching by pressing "Enter" on the keyboard. | ||
| document.querySelector('.js-search-bar') | ||
| .addEventListener('keydown', (event) => { | ||
| if (event.key === 'Enter') { | ||
| const searchTerm = document.querySelector('.js-search-bar').value; | ||
| window.location.href = `amazon.html?search=${searchTerm}`; | ||
| } | ||
| }); | ||
| } | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Another feature that I add was making the paymentSummary sticky , so even though you have multiple products in your cart you can still have access/see your payment summary :> There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nice idea |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| import {cart} from '../../data/cart.js'; | ||
| import {cart, resetCart} from '../../data/cart.js'; | ||
| import {getProduct} from '../../data/products.js'; | ||
| import {getDeliveryOption} from '../../data/deliveryOptions.js'; | ||
| import {formatCurrency} from '../utils/money.js'; | ||
|
|
@@ -89,6 +89,8 @@ export function renderPaymentSummary() { | |
| console.log('Unexpected error. Try again later.'); | ||
| } | ||
|
|
||
| // Extra feature: make the cart empty after creating an order. | ||
| resetCart(); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it is making my orders.html broken it becomes empty , i got it i should have kept reset cart in try{ } below addOrder |
||
| window.location.href = 'orders.html'; | ||
| }); | ||
| } | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. very nice |

There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Congratulations to everyone who made it this far, you've made a good progress and work. Be proud of yourself and never stop learning).