feat: new billing and restrict access when trial has ended

* fix: simply billing

* fix usage graph

* imporve billing more + supporter prompt on self-hosting

* revert service change

* revert query builder

* fix: comments
This commit is contained in:
Carl-Gerhard Lindesvärd
2025-11-11 11:09:11 +01:00
committed by GitHub
parent bbd30ca6e0
commit 9cafd61b25
57 changed files with 1642 additions and 1269 deletions

View File

@@ -1,8 +1,8 @@
import FullPageLoadingState from '@/components/full-page-loading-state';
import SupporterPrompt from '@/components/organization/supporter-prompt';
import { LinkButton } from '@/components/ui/button';
import { useTRPC } from '@/integrations/trpc/react';
import { cn } from '@/utils/cn';
import { FREE_PRODUCT_IDS } from '@openpanel/payments';
import { useSuspenseQuery } from '@tanstack/react-query';
import {
Outlet,
@@ -106,24 +106,9 @@ function Component() {
</LinkButton>
</Alert>
)}
{organization.subscriptionEndsAt && organization.isExpired && (
<Alert
title="Subscription expired"
description={`Your subscription has expired. You can reactivate it by choosing a new plan below. It expired on ${format(organization.subscriptionEndsAt, 'PPP')}`}
>
<LinkButton
to="/$organizationId/billing"
params={{
organizationId: organizationId,
}}
>
Reactivate
</LinkButton>
</Alert>
)}
{organization.subscriptionEndsAt && organization.isWillBeCanceled && (
<Alert
title="Subscription will becanceled"
title="Subscription will be canceled"
description={`You have canceled your subscription. You can reactivate it by choosing a new plan below. It'll expire on ${format(organization.subscriptionEndsAt, 'PPP')}`}
>
<LinkButton
@@ -151,25 +136,8 @@ function Component() {
</LinkButton>
</Alert>
)}
{organization.subscriptionProductId &&
FREE_PRODUCT_IDS.includes(organization.subscriptionProductId) && (
<Alert
title="Free plan is removed"
description="We've removed the free plan. You can upgrade to a paid plan to continue using OpenPanel."
className="bg-orange-400/40 border-orange-400/50"
>
<LinkButton
className="bg-orange-400 text-white hover:bg-orange-400/80"
to="/$organizationId/billing"
params={{
organizationId: organizationId,
}}
>
Upgrade
</LinkButton>
</Alert>
)}
<Outlet />
<SupporterPrompt />
</>
);
}