"use client"; import { usePaymentLaunchFlow } from "@/app/_hooks/use-payment-launch-flow"; import type { TipCoffeeType } from "@/lib/tip/tip_coffee"; import { usePaymentDispatch, usePaymentState, } from "@/stores/payment/payment-context"; import { Logger } from "@/utils"; import { LazyStripePaymentDialog } from "../subscription/components/lazy-stripe-payment-dialog"; import { stripePaymentDialogStyles as dialogStyles } from "../subscription/components/stripe-payment-dialog.styles"; import styles from "./tip-screen.module.css"; const log = new Logger("TipCheckoutButton"); export interface TipCheckoutButtonProps { coffeeType: TipCoffeeType; disabled?: boolean; isAuthLoading?: boolean; onOrder: () => void; returnPath: string; } export function TipCheckoutButton({ coffeeType, disabled = false, isAuthLoading = false, onOrder, returnPath, }: TipCheckoutButtonProps) { const payment = usePaymentState(); const paymentDispatch = usePaymentDispatch(); const paymentLaunch = usePaymentLaunchFlow({ log, logScope: "tip-checkout", payment, paymentDispatch, subscriptionType: "tip", tipCoffeeType: coffeeType, }); const isLoading = isAuthLoading || payment.isCreatingOrder || payment.isPollingOrder; const label = payment.isPollingOrder ? "Processing payment..." : payment.isCreatingOrder ? "Creating order..." : payment.isPaid ? "Thanks for the coffee" : "Order and Buy"; return ( <> {payment.errorMessage ? (

{payment.errorMessage}

) : null} {paymentLaunch.shouldShowEzpayConfirmDialog ? ( ) : null} {paymentLaunch.shouldShowStripeDialog && paymentLaunch.stripeClientSecret ? ( ) : null} ); } interface EzpayRedirectConfirmDialogProps { orderId: string; isConfirming: boolean; onCancel: () => void; onConfirm: () => void; } function EzpayRedirectConfirmDialog({ orderId, isConfirming, onCancel, onConfirm, }: EzpayRedirectConfirmDialogProps) { return (

Continue to GCash?

Your coffee order is ready. Continue to GCash to finish the payment.

Order No. {orderId}

); }