-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcheckout-session.tsx
55 lines (48 loc) · 1.52 KB
/
checkout-session.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
'use client'
import { useEffect } from 'react'
import { CheckCheck, XCircle } from 'lucide-react'
import Stripe from 'stripe'
import { useShoppingCart } from 'use-shopping-cart'
import { Widget } from './Widget'
interface Props {
customerDetails: Stripe.Checkout.Session.CustomerDetails | null
}
export function CheckoutSession({ customerDetails }: Props) {
/* console.log(customerDetails, 'customerDetails') */
const { clearCart } = useShoppingCart()
useEffect(() => {
if (customerDetails) {
clearCart()
}
}, [clearCart, customerDetails])
if (!customerDetails) {
return (
<>
<XCircle className="mx-auto h-10 w-10 text-red-400" />
<h1 className="mt-4 text-3xl font-bold tracking-tight text-red-400 sm:text-5xl">
Nenhuma sessão de checkout encontrada
</h1>
</>
)
}
return (
<>
<CheckCheck className="mx-auto h-10 w-10 text-lime-500 dark:text-lime-400" />
<h1 className="mt-4 text-3xl font-bold tracking-tight text-lime-500 dark:text-lime-400 sm:text-5xl">
Pedido realizado com sucesso!
</h1>
<h3 className="mt-8 text-2xl leading-7">
Agradecemos pela sua preferência,{' '}
<span className="font-extrabold">{customerDetails.name}</span>!
</h3>
<p className="mt-8">
Verifique seu e-mail de compra{''}
<span className="mx-1 font-extrabold text-indigo-500">
{customerDetails.email}
</span>
para detalhes o seu pedido.
</p>
<Widget />
</>
)
}