mirror of
https://github.com/supabase/supabase.git
synced 2026-10-12 04:45:08 +03:00
* billing improvements * wrapper improvements * border fix * Nit adjustments * fixes * fix aria * fix loading * fixes * fix --------- Co-authored-by: Joshen Lim <joshenlimek@gmail.com>
31 lines
721 B
TypeScript
31 lines
721 B
TypeScript
import { useInvoicePaymentLinkGetMutation } from 'data/invoices/invoice-payment-link-mutation'
|
|
import { toast } from 'sonner'
|
|
import { Button } from 'ui'
|
|
|
|
interface InvoicePayButtonProps {
|
|
slug?: string
|
|
invoiceId: string
|
|
}
|
|
|
|
const InvoicePayButton = ({ slug, invoiceId }: InvoicePayButtonProps) => {
|
|
const { mutate, isPending } = useInvoicePaymentLinkGetMutation({
|
|
onSuccess(data) {
|
|
toast.success('Redirecting to payment gateway...')
|
|
|
|
window.location.href = data.redirectUrl
|
|
},
|
|
})
|
|
|
|
function onPayNow() {
|
|
mutate({ slug, invoiceId })
|
|
}
|
|
|
|
return (
|
|
<Button onClick={onPayNow} loading={isPending} disabled={isPending}>
|
|
Pay now
|
|
</Button>
|
|
)
|
|
}
|
|
|
|
export default InvoicePayButton
|