Refactor billing imports, reorganize package scripts and improve action structure
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.
This commit is contained in:
@@ -1,6 +0,0 @@
|
||||
import { z } from 'zod';
|
||||
|
||||
export const TeamBillingPortalSchema = z.object({
|
||||
accountId: z.string().uuid(),
|
||||
slug: z.string().min(1),
|
||||
});
|
||||
@@ -1,5 +1,10 @@
|
||||
import { z } from 'zod';
|
||||
|
||||
export const TeamBillingPortalSchema = z.object({
|
||||
accountId: z.string().uuid(),
|
||||
slug: z.string().min(1),
|
||||
});
|
||||
|
||||
export const TeamCheckoutSchema = z.object({
|
||||
slug: z.string().min(1),
|
||||
productId: z.string().min(1),
|
||||
@@ -14,7 +14,7 @@ import appConfig from '~/config/app.config';
|
||||
import billingConfig from '~/config/billing.config';
|
||||
import pathsConfig from '~/config/paths.config';
|
||||
|
||||
import { TeamCheckoutSchema } from '../../_lib/schema/team-checkout.schema';
|
||||
import { TeamCheckoutSchema } from '../../_lib/schema/team-billing.schema';
|
||||
|
||||
export class TeamBillingService {
|
||||
private readonly namespace = 'billing.team-account';
|
||||
|
||||
@@ -6,9 +6,11 @@ import { z } from 'zod';
|
||||
|
||||
import { getSupabaseServerActionClient } from '@kit/supabase/server-actions-client';
|
||||
|
||||
import { TeamBillingPortalSchema } from '~/(dashboard)/home/[account]/_lib/schema/team-billing-portal.schema';
|
||||
|
||||
import { TeamCheckoutSchema } from '../_lib/schema/team-checkout.schema';
|
||||
// billing imports
|
||||
import {
|
||||
TeamBillingPortalSchema,
|
||||
TeamCheckoutSchema,
|
||||
} from '../_lib/schema/team-billing.schema';
|
||||
import { TeamBillingService } from '../_lib/server/team-billing.service';
|
||||
|
||||
/**
|
||||
@@ -19,7 +21,6 @@ export async function createTeamAccountCheckoutSession(
|
||||
params: z.infer<typeof TeamCheckoutSchema>,
|
||||
) {
|
||||
const data = TeamCheckoutSchema.parse(params);
|
||||
|
||||
const service = new TeamBillingService(getSupabaseServerActionClient());
|
||||
|
||||
return service.createCheckout(data);
|
||||
@@ -32,7 +33,6 @@ export async function createTeamAccountCheckoutSession(
|
||||
*/
|
||||
export async function createBillingPortalSession(formData: FormData) {
|
||||
const params = TeamBillingPortalSchema.parse(Object.fromEntries(formData));
|
||||
|
||||
const service = new TeamBillingService(getSupabaseServerActionClient());
|
||||
|
||||
// get url to billing portal
|
||||
|
||||
Reference in New Issue
Block a user