Skip to content
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

David's part #5

Merged
merged 2 commits into from
Feb 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"@popperjs/core": "^2.11.8",
"bootstrap": "^5.3.2",
"js-cookie": "^3.0.5",
"sweetalert2": "^11.10.5",
"vanilla-lazyload": "^17.8.8"
}
}
7 changes: 7 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

40 changes: 40 additions & 0 deletions src/about.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8"/>
<meta content="width=device-width, initial-scale=1.0" name="viewport"/>
<link href="/favicon.ico" rel="icon">
<link href="css/lib.scss" rel="stylesheet">
<link href="css/main.scss" rel="stylesheet">
<script src="js/products.ts" type="module" defer></script>
<script src="js/checkout.ts" type="module" defer></script>
<script src="main.ts" type="module" defer></script>
<title>E-Veg Shop</title>
</head>
<body>
<div class="hero">
<div class="title mb-2">E-Veg</div>
</div>
<div class="about-area d-flex flex-column justify-content-center position-relative m-auto px-2">
<div class="position-relative w-100 px-2" id="customerDetails">
<h2>Objective</h2>
<div>This is an online shopping WebApp prototype which compatible with mobile devices, retrieve information from a catalogue of products available in the shop, fill a shopping basket with items, record shipping and payment data and invoke the ordering process resulting in an invoice being generated. The main usability goal of the WebApp is that it should be equally easy to use regardless of whether it is used on a desktop computer or on a mobile phone.</div>
<hr class="my-3">
<h2>Contact</h2>
<div>
<h4 class="mb-3">Group 20</h4>
<h4 class="mb-3">Suraj Mann</h4>
<h4 class="mb-3">Regan Kastelie</h4>
<h4 class="mb-3">Olly Wortley</h4>
<h4 class="mb-3">David Chun-Wah Luk</h4>
<h4 class="mb-3">Tien Yu Lin</h4>
</div>
<div></div>
</div>
</div>
<footer class="about">
<div>&copy; 2021 InterVeg Coventry Ltd.</div>
<div>Fresh produce from the Midland's green countryside.</div>
</footer>
</body>
</html>
19 changes: 19 additions & 0 deletions src/css/common.css
Original file line number Diff line number Diff line change
Expand Up @@ -299,3 +299,22 @@ a:visited {
margin-bottom: .25rem;
}
}

.about-area {
@media (max-width: 576px) {
font-size: .7rem;
width: 95%;
}

@media (min-width: 576px) and (max-width: 768px) {
font-size: .8rem;
width: 95%;
}

@media (min-width: 768px) {
font-size: .9rem;
max-width: 800px;
margin: auto;
width: 75%;
}
}
2 changes: 1 addition & 1 deletion src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
<a class="nav-link active" href="/checkout.html">Checkout</a>
</li>
<li class="nav-item">
<a class="nav-link active" href="#">About</a>
<a class="nav-link active" href="/about.html">About</a>
</li>
</ul>
<form class="d-flex search flex-lg-row flex-column align-items-center" role="search">
Expand Down
19 changes: 18 additions & 1 deletion src/js/checkout.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import Swal from 'sweetalert2'
import { products } from './products.ts'
import type { Basket } from './typing'
import { readBasketCookie } from './shared'
Expand All @@ -16,7 +17,8 @@ function init() {
}

function resetListeners() {
document.querySelector('#paycreditcard')?.addEventListener('click', showCreditCardPage)
// document.querySelector('#paycreditcard')?.addEventListener('click', showCreditCardPage)
document.querySelector('#paycreditcard')?.addEventListener('click', showSweetAlert)
}

function showCreditCardPage(e: Event) {
Expand All @@ -31,6 +33,21 @@ function showCreditCardPage(e: Event) {
}
}

function showSweetAlert(e: Event) {
e.preventDefault()

Swal.fire({
title: 'Are you sure to checkout?',
icon: 'warning',
confirmButtonText: 'Yes',
confirmButtonColor: '#d33',
showCancelButton: true,
}).then((result) => {
if (result.isConfirmed)
showCreditCardPage(e)
})
}

function calculateTotalPrice() {
return Array.from(
basket,
Expand Down
14 changes: 13 additions & 1 deletion src/js/productCard.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import Swal from 'sweetalert2'
import type { Product } from './typing.ts'

const cardTemplateStr: string = `
Expand Down Expand Up @@ -67,7 +68,18 @@ export function createProductCard(

thisProductCard.querySelector('.addToBasket')?.addEventListener(
'click',
() => onAddToBasketRequested(product.id, Number.parseInt(inputBox.value)),
() => {
// Display SweetAlert2 message with auto-close
Swal.fire({
timerProgressBar: true,
icon: 'success',
title: `${product.name} was added to basket.`,
showConfirmButton: false,
timer: 2000, // Close after 1500ms (1.5 seconds)
})

onAddToBasketRequested(product.id, Number.parseInt(inputBox.value))
},
)

const img = createProductImageElement(`/images/${product.imgName}`)
Expand Down
Loading