mirror of
https://github.com/yusufipk/OpenFrame.git
synced 2026-09-11 17:46:06 +00:00
feat(billing): integrate Stripe for subscription management and billing access
- Added billing-related fields to the User model in the database. - Implemented functions for managing billing access, including trial periods and subscription statuses. - Created new billing utility functions for Stripe integration. - Updated onboarding page to include billing overview and workspace creation eligibility. - Enhanced route access checks to require billing access for certain actions. - Implemented cleanup scripts for expired billing workspaces and associated media. - Updated header component to conditionally show app navigation based on billing access. - Added new migrations for billing-related database changes.
This commit is contained in:
@@ -2,7 +2,9 @@ import { auth } from '@/lib/auth';
|
||||
import { redirect } from 'next/navigation';
|
||||
import { db } from '@/lib/db';
|
||||
import { Prisma } from '@prisma/client';
|
||||
import { hasCollaboratorBillingBackedAccess, requireBillingAccessOrRedirect } from '@/lib/route-access';
|
||||
import { DashboardClient } from './dashboard-client';
|
||||
import { buildBillingAccessWhereInput } from '@/lib/billing';
|
||||
|
||||
export default async function DashboardPage({
|
||||
searchParams,
|
||||
@@ -14,6 +16,11 @@ export default async function DashboardPage({
|
||||
redirect('/login');
|
||||
}
|
||||
|
||||
const hasCollaboratorAccess = await hasCollaboratorBillingBackedAccess(session.user.id);
|
||||
if (!hasCollaboratorAccess) {
|
||||
await requireBillingAccessOrRedirect({ userId: session.user.id });
|
||||
}
|
||||
|
||||
const userOnboarding = await db.user.findUnique({
|
||||
where: { id: session.user.id },
|
||||
select: { onboardingCompletedAt: true },
|
||||
@@ -37,6 +44,7 @@ export default async function DashboardPage({
|
||||
{ members: { some: { userId: session.user.id } } },
|
||||
{
|
||||
workspace: {
|
||||
owner: buildBillingAccessWhereInput(),
|
||||
OR: [
|
||||
{ ownerId: session.user.id },
|
||||
{ members: { some: { userId: session.user.id } } },
|
||||
@@ -44,6 +52,9 @@ export default async function DashboardPage({
|
||||
},
|
||||
},
|
||||
],
|
||||
workspace: {
|
||||
owner: buildBillingAccessWhereInput(),
|
||||
},
|
||||
};
|
||||
|
||||
// Build unique workspace list for filter (Needs an unbounded list of accessible workspaces)
|
||||
|
||||
Reference in New Issue
Block a user