mirror of
https://github.com/harivansh-afk/Saas-Teamspace.git
synced 2026-04-20 18:02:18 +00:00
initial commit
This commit is contained in:
commit
ef9ccf22d3
133 changed files with 20802 additions and 0 deletions
25
components/purchase-button.tsx
Normal file
25
components/purchase-button.tsx
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
'use client'
|
||||
import axios from 'axios'
|
||||
import { useState } from 'react'
|
||||
import toast from 'react-hot-toast'
|
||||
import { Button } from '@/components/ui/button'
|
||||
|
||||
export const PurchaseButton = () => {
|
||||
const [isLoading, setIsLoading] = useState(false)
|
||||
const onClick = async () => {
|
||||
try {
|
||||
setIsLoading(true)
|
||||
const response = await axios.post('/api/checkout')
|
||||
window.location.href = response.data.url
|
||||
} catch (error) {
|
||||
toast.error('An error occurred. Please try again.')
|
||||
} finally {
|
||||
setIsLoading(false)
|
||||
}
|
||||
}
|
||||
return (
|
||||
<Button onClick={onClick} disabled={isLoading}>
|
||||
{isLoading ? 'Loading...' : 'Purchase'}
|
||||
</Button>
|
||||
)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue