2023-08-02 09:35:48 +00:00
|
|
|
import { usePathname } from "next/navigation";
|
2022-10-04 22:54:15 +00:00
|
|
|
|
2023-03-22 14:29:14 +00:00
|
|
|
import { useIntercom } from "@calcom/features/ee/support/lib/intercom/useIntercom";
|
2023-01-05 17:00:16 +00:00
|
|
|
import { getLayout } from "@calcom/features/settings/layouts/SettingsLayout";
|
2022-10-04 22:54:15 +00:00
|
|
|
import { classNames } from "@calcom/lib";
|
2022-11-10 20:23:56 +00:00
|
|
|
import { WEBAPP_URL } from "@calcom/lib/constants";
|
2022-10-04 22:54:15 +00:00
|
|
|
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
2023-01-23 23:08:01 +00:00
|
|
|
import { Button, Meta } from "@calcom/ui";
|
2023-04-12 15:26:31 +00:00
|
|
|
import { ExternalLink } from "@calcom/ui/components/icon";
|
2022-10-04 22:54:15 +00:00
|
|
|
|
2023-04-18 18:45:32 +00:00
|
|
|
import PageWrapper from "@components/PageWrapper";
|
|
|
|
|
2022-10-04 22:54:15 +00:00
|
|
|
interface CtaRowProps {
|
|
|
|
title: string;
|
|
|
|
description: string;
|
|
|
|
children: React.ReactNode;
|
|
|
|
className?: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
const CtaRow = ({ title, description, className, children }: CtaRowProps) => {
|
|
|
|
return (
|
|
|
|
<>
|
2023-04-05 18:14:46 +00:00
|
|
|
<section className={classNames("text-default flex flex-col sm:flex-row", className)}>
|
2022-10-04 22:54:15 +00:00
|
|
|
<div>
|
|
|
|
<h2 className="font-medium">{title}</h2>
|
|
|
|
<p>{description}</p>
|
|
|
|
</div>
|
2023-06-22 22:25:37 +00:00
|
|
|
<div className="flex-shrink-0 pt-3 sm:ml-auto sm:pl-3 sm:pt-0">{children}</div>
|
2022-10-04 22:54:15 +00:00
|
|
|
</section>
|
2023-04-05 18:14:46 +00:00
|
|
|
<hr className="border-subtle" />
|
2022-10-04 22:54:15 +00:00
|
|
|
</>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
const BillingView = () => {
|
2023-08-02 09:35:48 +00:00
|
|
|
const pathname = usePathname();
|
2022-10-04 22:54:15 +00:00
|
|
|
const { t } = useLocale();
|
2023-03-22 14:29:14 +00:00
|
|
|
const { open } = useIntercom();
|
2023-08-02 09:35:48 +00:00
|
|
|
const returnTo = pathname;
|
2022-11-10 20:23:56 +00:00
|
|
|
const billingHref = `/api/integrations/stripepayment/portal?returnTo=${WEBAPP_URL}${returnTo}`;
|
2022-10-04 22:54:15 +00:00
|
|
|
|
2023-04-19 20:22:07 +00:00
|
|
|
const onContactSupportClick = async () => {
|
|
|
|
await open();
|
2022-10-04 22:54:15 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
return (
|
|
|
|
<>
|
|
|
|
<Meta title={t("billing")} description={t("manage_billing_description")} />
|
|
|
|
<div className="space-y-6 text-sm sm:space-y-8">
|
2023-06-08 13:37:54 +00:00
|
|
|
<CtaRow title={t("view_and_manage_billing_details")} description={t("view_and_edit_billing_details")}>
|
2023-04-12 15:26:31 +00:00
|
|
|
<Button color="primary" href={billingHref} target="_blank" EndIcon={ExternalLink}>
|
2022-10-04 22:54:15 +00:00
|
|
|
{t("billing_portal")}
|
|
|
|
</Button>
|
|
|
|
</CtaRow>
|
|
|
|
|
2023-06-08 13:37:54 +00:00
|
|
|
<CtaRow title={t("need_anything_else")} description={t("further_billing_help")}>
|
2022-10-04 22:54:15 +00:00
|
|
|
<Button color="secondary" onClick={onContactSupportClick}>
|
2022-12-07 20:53:44 +00:00
|
|
|
{t("contact_support")}
|
2022-10-04 22:54:15 +00:00
|
|
|
</Button>
|
|
|
|
</CtaRow>
|
|
|
|
</div>
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
BillingView.getLayout = getLayout;
|
2023-04-18 18:45:32 +00:00
|
|
|
BillingView.PageWrapper = PageWrapper;
|
2022-10-04 22:54:15 +00:00
|
|
|
|
|
|
|
export default BillingView;
|