initial commit

This commit is contained in:
Harivansh Rathi 2024-11-24 20:56:03 -05:00
commit ef9ccf22d3
133 changed files with 20802 additions and 0 deletions

View 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>
)
}