diff --git a/apps/web/components/billing-warning.tsx b/apps/web/components/billing-warning.tsx new file mode 100644 index 000000000..bf68c44f2 --- /dev/null +++ b/apps/web/components/billing-warning.tsx @@ -0,0 +1,51 @@ +import { useSubscription } from "@documenso/lib/stripe" +import { PaperAirplaneIcon } from "@heroicons/react/24/outline"; +import { SubscriptionStatus } from '@prisma/client' +import Link from "next/link"; + +export const BillingWarning = () => { + const { subscription } = useSubscription(); + + return ( + <> + {subscription?.status === SubscriptionStatus.PAST_DUE && ( +
+
+
+
+ +
+

+ Your subscription is past due.{" "} + + Please update your payment information to avoid any service interruptions. + +

+
+
+
+ )} + + {subscription?.status === SubscriptionStatus.INACTIVE && ( +
+
+
+
+ +
+

+ Your subscription is inactive. You can continue to view and edit your documents, + but you will not be able to send them or create new ones.{" "} + + You can update your payment information here + +

+
+
+
+ )} + + ) +} \ No newline at end of file diff --git a/apps/web/components/layout.tsx b/apps/web/components/layout.tsx index 408472633..06a5bb2de 100644 --- a/apps/web/components/layout.tsx +++ b/apps/web/components/layout.tsx @@ -1,8 +1,13 @@ import { useEffect } from "react"; +import Link from "next/link"; import { useRouter } from "next/router"; import { NEXT_PUBLIC_WEBAPP_URL } from "@documenso/lib/constants"; +import { useSubscription } from "@documenso/lib/stripe"; import Navigation from "./navigation"; +import { PaperAirplaneIcon } from "@heroicons/react/24/outline"; +import { SubscriptionStatus } from "@prisma/client"; import { useSession } from "next-auth/react"; +import { BillingWarning } from "./billing-warning"; function useRedirectToLoginIfUnauthenticated() { const { data: session, status } = useSession(); @@ -30,11 +35,16 @@ function useRedirectToLoginIfUnauthenticated() { export default function Layout({ children }: any) { useRedirectToLoginIfUnauthenticated(); + const { subscription } = useSubscription(); + return ( <>
- + +
+ +
{children}