mirror of
https://github.com/supabase/supabase.git
synced 2026-10-09 11:25:06 +03:00
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: Ivan Vasilov <vasilov.ivan@gmail.com>
32 lines
724 B
TypeScript
32 lines
724 B
TypeScript
import { toast } from 'sonner'
|
|
import { Button } from 'ui'
|
|
|
|
import { useInvoicePaymentLinkGetMutation } from '@/data/invoices/invoice-payment-link-mutation'
|
|
|
|
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
|