import { t } from "@lingui/core/macro"; import { HiBolt, HiCheckBadge } from "react-icons/hi2"; import Button from "~/components/Button"; import { useModal } from "~/providers/modal"; import { usePopup } from "~/providers/popup"; export function UpgradeToProConfirmation({ workspacePublicId, }: { userId: string; workspacePublicId: string; }) { const { closeModal, entityId } = useModal(); const { showPopup } = usePopup(); const handleUpgrade = async () => { try { const response = await fetch("/api/stripe/create_checkout_session", { method: "POST", headers: { "Content-Type": "application/json", }, body: JSON.stringify({ ...(entityId && { slug: entityId }), workspacePublicId: workspacePublicId, plan: "pro", billing: "monthly", cancelUrl: "/settings", successUrl: "/settings", }), }); const { url } = (await response.json()) as { url: string }; if (url) { window.location.href = url; } } catch (error) { console.error("Error creating checkout session:", error); showPopup({ header: t`Error upgrading subscription`, message: t`Please try again later, or contact customer support.`, icon: "error", }); } }; return (
{t`Supercharge your workspace for just $29/month. Here's what you'll get:`}