Deleted unnecessary schema files and reorganized their imports into more logical order. Modified the package script structure to align more accurately with standard conventions. Also refactored the team-billing.service file to improve action structure, making it easier to understand and edit. Furthermore, upgraded various dependencies, reflecting their new versions in the lockfile.
35 lines
1.1 KiB
TypeScript
35 lines
1.1 KiB
TypeScript
'use server';
|
|
|
|
import { redirect } from 'next/navigation';
|
|
|
|
import { enhanceAction } from '@kit/next/actions';
|
|
import { getSupabaseServerActionClient } from '@kit/supabase/server-actions-client';
|
|
|
|
import { PersonalAccountCheckoutSchema } from './_lib/schema/personal-account-checkout.schema';
|
|
import { UserBillingService } from './_lib/server/user-billing.service';
|
|
|
|
/**
|
|
* @name createPersonalAccountCheckoutSession
|
|
* @description Creates a checkout session for a personal account.
|
|
*/
|
|
export const createPersonalAccountCheckoutSession = enhanceAction(
|
|
async function (data) {
|
|
const service = new UserBillingService(getSupabaseServerActionClient());
|
|
|
|
return await service.createCheckoutSession(data);
|
|
},
|
|
{
|
|
schema: PersonalAccountCheckoutSchema,
|
|
},
|
|
);
|
|
|
|
/**
|
|
* @description Creates a billing Portal session for a personal account
|
|
*/
|
|
export async function createPersonalAccountBillingPortalSession() {
|
|
const service = new UserBillingService(getSupabaseServerActionClient());
|
|
const url = await service.createBillingPortalSession();
|
|
|
|
return redirect(url);
|
|
}
|