2021-09-28 10:27:46 +00:00
|
|
|
import { ExternalLinkIcon } from "@heroicons/react/solid";
|
2022-01-29 00:46:35 +00:00
|
|
|
import { ReactNode } from "react";
|
2021-09-27 22:57:23 +00:00
|
|
|
|
2022-05-26 17:07:14 +00:00
|
|
|
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
2022-03-16 23:36:43 +00:00
|
|
|
import Button from "@calcom/ui/Button";
|
2022-05-17 19:31:49 +00:00
|
|
|
import { useIntercom } from "@ee/lib/intercom/useIntercom";
|
2022-03-16 23:36:43 +00:00
|
|
|
|
2022-05-04 21:13:01 +00:00
|
|
|
import useMeQuery from "@lib/hooks/useMeQuery";
|
2021-09-22 19:52:38 +00:00
|
|
|
|
2021-09-29 21:33:18 +00:00
|
|
|
import SettingsShell from "@components/SettingsShell";
|
2021-06-16 12:44:25 +00:00
|
|
|
|
2022-01-29 00:46:35 +00:00
|
|
|
type CardProps = { title: string; description: string; className?: string; children: ReactNode };
|
|
|
|
const Card = ({ title, description, className = "", children }: CardProps): JSX.Element => (
|
2022-02-09 00:05:13 +00:00
|
|
|
<div className={`border bg-white sm:rounded-sm ${className}`}>
|
2022-01-29 00:46:35 +00:00
|
|
|
<div className="px-4 py-5 sm:p-6">
|
|
|
|
<h3 className="text-lg font-medium leading-6 text-gray-900">{title}</h3>
|
2022-02-09 00:05:13 +00:00
|
|
|
<div className="mt-2 max-w-xl text-sm text-gray-500">
|
2022-01-29 00:46:35 +00:00
|
|
|
<p>{description}</p>
|
|
|
|
</div>
|
|
|
|
<div className="mt-5">{children}</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
|
2021-08-02 17:29:34 +00:00
|
|
|
export default function Billing() {
|
2021-10-13 09:34:55 +00:00
|
|
|
const { t } = useLocale();
|
2022-01-29 00:46:35 +00:00
|
|
|
const query = useMeQuery();
|
|
|
|
const { data } = query;
|
2022-01-29 13:48:15 +00:00
|
|
|
const { boot, show } = useIntercom();
|
2021-10-13 09:34:55 +00:00
|
|
|
|
2021-06-16 12:44:25 +00:00
|
|
|
return (
|
2022-05-26 17:07:14 +00:00
|
|
|
<SettingsShell heading={t("billing")} subtitle={t("manage_your_billing_info")}>
|
|
|
|
<>
|
2022-02-09 00:05:13 +00:00
|
|
|
<div className="py-6 lg:col-span-9 lg:pb-8">
|
2022-01-29 00:46:35 +00:00
|
|
|
{data?.plan && ["FREE", "TRIAL"].includes(data.plan) && (
|
|
|
|
<Card
|
|
|
|
title={t("plan_description", { plan: data.plan })}
|
|
|
|
description={t("plan_upgrade_invitation")}
|
|
|
|
className="mb-4">
|
|
|
|
<form method="POST" action={`/api/upgrade`}>
|
|
|
|
<Button type="submit">
|
2022-02-09 00:05:13 +00:00
|
|
|
{t("upgrade_now")} <ExternalLinkIcon className="ml-1 h-4 w-4" />
|
2022-01-29 00:46:35 +00:00
|
|
|
</Button>
|
|
|
|
</form>
|
|
|
|
</Card>
|
|
|
|
)}
|
|
|
|
|
|
|
|
<Card title={t("view_and_manage_billing_details")} description={t("view_and_edit_billing_details")}>
|
|
|
|
<form method="POST" action={`/api/integrations/stripepayment/portal`}>
|
2022-01-29 13:48:15 +00:00
|
|
|
<Button type="submit" color="secondary">
|
2022-02-09 00:05:13 +00:00
|
|
|
{t("go_to_billing_portal")} <ExternalLinkIcon className="ml-1 h-4 w-4" />
|
2022-01-29 00:46:35 +00:00
|
|
|
</Button>
|
|
|
|
</form>
|
|
|
|
</Card>
|
|
|
|
<div className="mt-4 border bg-gray-50 sm:rounded-sm">
|
2021-09-28 10:27:46 +00:00
|
|
|
<div className="px-4 py-5 sm:p-6">
|
2022-01-29 00:46:35 +00:00
|
|
|
<h3 className="text-lg font-medium leading-6 text-gray-900">{t("need_anything_else")}</h3>
|
2022-02-09 00:05:13 +00:00
|
|
|
<div className="mt-2 max-w-xl text-sm text-gray-500">
|
2021-10-13 09:34:55 +00:00
|
|
|
<p>{t("further_billing_help")}</p>
|
2021-09-28 10:27:46 +00:00
|
|
|
</div>
|
|
|
|
<div className="mt-5">
|
2022-01-29 13:48:15 +00:00
|
|
|
<Button
|
|
|
|
onClick={() => {
|
|
|
|
boot();
|
|
|
|
show();
|
|
|
|
}}
|
|
|
|
color="secondary">
|
2021-10-13 09:34:55 +00:00
|
|
|
{t("contact_our_support_team")}
|
2021-09-28 14:07:33 +00:00
|
|
|
</Button>
|
2021-09-28 10:27:46 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
2021-06-16 12:44:25 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
2022-05-26 17:07:14 +00:00
|
|
|
</>
|
|
|
|
</SettingsShell>
|
2021-06-16 12:44:25 +00:00
|
|
|
);
|
|
|
|
}
|