From 6b20cbf166949704ad8b53a9529fd982b84607dd Mon Sep 17 00:00:00 2001 From: konyogony Date: Sat, 1 Nov 2025 18:18:01 +0700 Subject: [PATCH 01/22] Add more stuff for selfhosting --- app/dash/page.tsx | 40 ++++++++++++++++++++++++---------------- components/panel.tsx | 2 +- lib/utils.ts | 15 ++++++++++++--- 3 files changed, 37 insertions(+), 20 deletions(-) diff --git a/app/dash/page.tsx b/app/dash/page.tsx index 2c848d7..2dc1259 100644 --- a/app/dash/page.tsx +++ b/app/dash/page.tsx @@ -29,7 +29,7 @@ import { DialogTitle, DialogTrigger, } from '@/components/ui/dialog'; -import { cn } from '@/lib/utils'; +import { cn, getPaymentInfo, ParsedPaymentInfo } from '@/lib/utils'; import { AlertDialog, AlertDialogCancel, @@ -363,6 +363,7 @@ const DashboardPage = () => { const [show2FADialog, setShow2FADialog] = useState(false); const [showResetPasswordDialog, setShowResetPasswordDialog] = useState(false); const [isManagingSubscription, setIsManagingSubscription] = useState(false); + const [paymentData, setPaymentData] = useState(null); useEffect(() => { if (!isLoading && !isAuthenticated) { @@ -371,6 +372,10 @@ const DashboardPage = () => { }, [isLoading, isAuthenticated, router]); useEffect(() => { + const fetchPaymentData = async () => { + const data = await getPaymentInfo(); + setPaymentData(data); + }; const fetchClips = async () => { if (isAuthenticated) { try { @@ -387,6 +392,7 @@ const DashboardPage = () => { }; fetchClips(); + fetchPaymentData(); }, [isAuthenticated, api_url]); const handleUnlinkProvider = async (provider: string) => { @@ -495,7 +501,8 @@ const DashboardPage = () => { return ; } - const userTierPlan = pricingPlans.find((p) => p.tierId === userData?.tier) ?? pricingPlans[0]; + const userTierPlan = + paymentData?.active_tiers.find((p) => p.name === userData?.tier) ?? paymentData?.active_tiers[0]; const storageLimitBytes = userData.storage_limit; const storageUsedBytes = userData.storage_used; const storageUsedGB = storageUsedBytes / (1024 * 1024 * 1024); @@ -824,7 +831,8 @@ const DashboardPage = () => { Your Subscription You are currently on the{' '} - {userTierPlan.name} plan. + {userTierPlan?.name ?? 'Error'}{' '} + plan. @@ -849,34 +857,34 @@ const DashboardPage = () => {

Manage Subscription

You are currently on the{' '} - {userTierPlan.name} plan. + {userTierPlan?.name} plan.

)}
- {pricingPlans.map((plan) => ( + {paymentData?.active_tiers.map((plan) => (
{plan.name} - {plan.isPopular && Most Popular} + {plan.is_popular && Most Popular}
{plan.description}
- {plan.price} - {plan.priceFrequency} + {plan.display_price} + {plan.display_frequency}