Skip to content

Commit

Permalink
Merge pull request #13 from Xanonymous-GitHub/qwik
Browse files Browse the repository at this point in the history
Disable clear button when paying, remove flag
  • Loading branch information
wortley authored Feb 15, 2024
2 parents a2bf80c + 6c6fa80 commit 43bb013
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 13 deletions.
5 changes: 1 addition & 4 deletions src/checkout.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,7 @@ <h2 class="text-start px-2">Basket Contents</h2>
<th scope="col" style="width: 1px">Remove</th>
</tr>
</thead>
<!-- FIXME: Unexpected <tbody> hidden happened. The following is just a workaround. -->
<div id="basket" class="table-group-divider overflow-y-auto h-100">
<tr><td colspan="5" class="text-center">Nothing here 🥹!</td></tr>
</div>
<tr></tr>
<tfoot id="basket-footer">
<tr>
<td colspan="4">Total</td>
Expand Down
16 changes: 7 additions & 9 deletions src/js/checkout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import type { Basket } from './typing'
import { DialogCloseResult, cookieOptions, readBasketCookie } from './shared'
import { isExpirationDateValid, isSecurityCodeValid, isValid } from './creditCard.ts'

const creditCardShown = false
const basket: Basket = readBasketCookie()

const EMPTY_BASKET_HTML = `<div id="basket" class="table-group-divider overflow-y-auto h-100"><tr><td colspan="5" class="text-center">Nothing here 🥹!</td></tr></div>`
Expand Down Expand Up @@ -98,13 +97,12 @@ function initiateCreditCardFormDataBinding(parentForm: HTMLFormElement) {
function showCreditCardPage(e: Event) {
e.preventDefault()

if (!creditCardShown) {
const payIFrame = document.createElement('iframe')
payIFrame.src = 'creditcard.html'
payIFrame.width = '100%'
payIFrame.height = '500px'
document.querySelector('#customerDetails')?.replaceChildren(payIFrame)
}
const payIFrame = document.createElement('iframe')
payIFrame.src = 'creditcard.html'
payIFrame.width = '100%'
payIFrame.height = '500px'
document.querySelector('#customerDetails')?.replaceChildren(payIFrame);
(document.querySelector('#clearbasket') as HTMLButtonElement).disabled = true
}

async function showSweetAlert(message: string, e: Event, onDialogClose?: (result: DialogCloseResult) => void) {
Expand Down Expand Up @@ -156,7 +154,7 @@ function updateCheckoutList() {
(document.querySelector('#clearbasket') as HTMLButtonElement).disabled = true;
(document.querySelector('#paycreditcard') as HTMLButtonElement).disabled = true
const checkoutListBody = document.querySelector('.checkoutList tbody')
checkoutListBody?.replaceChildren();
checkoutListBody?.replaceChildren()
checkoutListBody?.insertAdjacentHTML('afterbegin', EMPTY_BASKET_HTML)
return
}
Expand Down

0 comments on commit 43bb013

Please sign in to comment.