"use client"; import { createManagementSubscriptionSession, getSubscriptions, } from "@/app/actions"; import { Subscription, User } from "@/types"; import React from "react"; import { useState, useEffect } from "react"; import { toast } from "react-toastify"; import { useRouter } from "next/navigation"; import { useQRCode } from "next-qrcode"; import pb from "@/lib/pocketbase"; interface ManageSubscriptionProps { user: User; } function AccountContent({ user }: ManageSubscriptionProps) { const router = useRouter(); const { Canvas } = useQRCode(); const [subscription, setSubscription] = useState(); const [loading, setLoading] = useState(true); useEffect(() => { (async () => { if (!user) { setLoading(false); return; } try { setLoading(true); const subscriptions = await getSubscriptions(); if (subscriptions.length > 0) { setSubscription(subscriptions[0]); } setLoading(false); } catch (err) { setLoading(false); } })(); }, [user]); const manageSubscription = async () => { try { const managementSession = await createManagementSubscriptionSession(); router.push(managementSession.url); } catch (error) { if (error instanceof Error) { toast.error(error.message, { position: "bottom-left", autoClose: 5000, hideProgressBar: false, closeOnClick: true, pauseOnHover: true, draggable: true, progress: undefined, theme: "colored", }); } } }; return loading ? (
) : (
{/* //TODO: Create Application Component */} {/* {subscription ? (

Get Started

  1. Download the application {" "} by scanning the QR code

  2. Upload some PDF {" "} Forms you want to fill

  3. Setup some{" "} Integrations

) : ( <> )} */}

Your Subscription

{subscription && subscription.status != "canceled" ? ( <>

{subscription?.product?.name}

{subscription.product?.description}

) : ( <>

{"You haven’t upgraded your workflow yet"}

)}
); } export default AccountContent;