'use client'; import { createOnboardingStripeCheckoutSession } from "@/actions"; import { SourcebotLogo } from "@/app/components/sourcebotLogo"; import { useToast } from "@/components/hooks/use-toast"; import { Button } from "@/components/ui/button"; import { useDomain } from "@/hooks/useDomain"; import { useNonEmptyQueryParam } from "@/hooks/useNonEmptyQueryParam"; import { ErrorCode } from "@/lib/errorCodes"; import { isServiceError } from "@/lib/utils"; import { Check, Loader2 } from "lucide-react"; import { useCallback, useEffect, useState } from "react"; import { useRouter } from "next/navigation"; import { TEAM_FEATURES } from "@/lib/constants"; export const Checkout = () => { const domain = useDomain(); const { toast } = useToast(); const errorCode = useNonEmptyQueryParam('errorCode'); const errorMessage = useNonEmptyQueryParam('errorMessage'); const [isLoading, setIsLoading] = useState(false); const router = useRouter(); useEffect(() => { if (errorCode === ErrorCode.STRIPE_CHECKOUT_ERROR && errorMessage) { toast({ description: `⚠️ Stripe checkout failed with error: ${errorMessage}`, variant: "destructive", }); } }, [errorCode, errorMessage, toast]); const onCheckout = useCallback(() => { setIsLoading(true); createOnboardingStripeCheckoutSession(domain) .then((response) => { if (isServiceError(response)) { toast({ description: `❌ Stripe checkout failed with error: ${response.message}`, variant: "destructive", }) } else { router.push(response.url); } }) .finally(() => { setIsLoading(false); }); }, [domain, router, toast]); return (

Start your 7 day free trial

Cancel anytime. No credit card required.

) }