Skip to content

Commit

Permalink
🎨 Initiate checkout only on button click
Browse files Browse the repository at this point in the history
  • Loading branch information
joyliu-q committed Apr 23, 2024
1 parent 6b1998c commit 0d78694
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions frontend/components/Tickets/CartTickets.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,11 @@ const CartTickets: React.FC<CartTicketsProps> = ({ tickets, soldOut }) => {
)
}, [])

useEffect(() => {
function handleInitiateCheckout() {
if (countedTickets.length === 0) {
return
}
setShowPaymentForm(true)
doApiRequest(`/tickets/initiate_checkout/?format=json`, {
method: 'POST',
body: { tickets: countedTickets },
Expand All @@ -173,7 +174,7 @@ const CartTickets: React.FC<CartTicketsProps> = ({ tickets, soldOut }) => {
}
setToken(res.detail)
})
}, [countedTickets])
}

function handleUpdateTicket(ticket: CountedEventTicket, newCount?: number) {
let reqPromise
Expand Down Expand Up @@ -326,7 +327,9 @@ const CartTickets: React.FC<CartTicketsProps> = ({ tickets, soldOut }) => {
<Summary tickets={countedTickets} />
<button
className="button is-primary is-fullwidth mt-4"
onClick={() => setShowPaymentForm(true)}
onClick={() => {
handleInitiateCheckout()
}}
>
Proceed to Checkout
</button>
Expand Down

0 comments on commit 0d78694

Please sign in to comment.