|
| 1 | +"use client"; |
| 2 | + |
| 3 | +import { redirectToBillingPortal } from "@/actions/billing"; |
| 4 | +import { BillingPortalButton } from "@/components/billing"; |
| 5 | +import { Spinner } from "@chakra-ui/react"; |
| 6 | +import { ArrowRightIcon } from "lucide-react"; |
| 7 | +import { useState } from "react"; |
| 8 | + |
| 9 | +function PaymentAlertBanner(props: { |
| 10 | + title: string; |
| 11 | + description: React.ReactNode; |
| 12 | + teamSlug: string; |
| 13 | +}) { |
| 14 | + const [isRouteLoading, setIsRouteLoading] = useState(false); |
| 15 | + |
| 16 | + return ( |
| 17 | + <div className="flex flex-col border-b bg-card px-4 py-6 lg:items-center lg:text-center"> |
| 18 | + <h3 className="font-semibold text-red-500 text-xl tracking-tight"> |
| 19 | + {props.title} |
| 20 | + </h3> |
| 21 | + <p className="mt-1 mb-4 text-muted-foreground text-sm"> |
| 22 | + {props.description} |
| 23 | + </p> |
| 24 | + <BillingPortalButton |
| 25 | + className="gap-2" |
| 26 | + size="sm" |
| 27 | + teamSlug={props.teamSlug} |
| 28 | + redirectPath={`/team/${props.teamSlug}`} |
| 29 | + redirectToBillingPortal={redirectToBillingPortal} |
| 30 | + onClick={() => { |
| 31 | + setIsRouteLoading(true); |
| 32 | + }} |
| 33 | + > |
| 34 | + Pay Invoices |
| 35 | + {isRouteLoading ? ( |
| 36 | + <Spinner className="size-4" /> |
| 37 | + ) : ( |
| 38 | + <ArrowRightIcon className="size-4" /> |
| 39 | + )} |
| 40 | + </BillingPortalButton> |
| 41 | + </div> |
| 42 | + ); |
| 43 | +} |
| 44 | + |
| 45 | +export function PastDueBanner(props: { |
| 46 | + teamSlug: string; |
| 47 | +}) { |
| 48 | + return ( |
| 49 | + <PaymentAlertBanner |
| 50 | + title="You have unpaid invoices" |
| 51 | + description={ |
| 52 | + <> |
| 53 | + Your service will be cut off when you hit a max unpaid amount <br />{" "} |
| 54 | + Pay your invoices to ensure continued access to thirdweb services |
| 55 | + </> |
| 56 | + } |
| 57 | + teamSlug={props.teamSlug} |
| 58 | + /> |
| 59 | + ); |
| 60 | +} |
| 61 | + |
| 62 | +export function ServiceCutOffBanner(props: { |
| 63 | + teamSlug: string; |
| 64 | +}) { |
| 65 | + return ( |
| 66 | + <PaymentAlertBanner |
| 67 | + title="Your service is cut off" |
| 68 | + description={ |
| 69 | + <> |
| 70 | + Your service is cut off due to unpaid invoices <br /> Please pay your |
| 71 | + invoices to continue using thirdweb services |
| 72 | + </> |
| 73 | + } |
| 74 | + teamSlug={props.teamSlug} |
| 75 | + /> |
| 76 | + ); |
| 77 | +} |
0 commit comments