Refactored classes according to new convention
This commit is contained in:
@@ -11,7 +11,7 @@ import {
|
||||
TeamBillingPortalSchema,
|
||||
TeamCheckoutSchema,
|
||||
} from '../schema/team-billing.schema';
|
||||
import { TeamBillingService } from './team-billing.service';
|
||||
import { createTeamBillingService } from './team-billing.service';
|
||||
|
||||
/**
|
||||
* @name createTeamAccountCheckoutSession
|
||||
@@ -21,7 +21,9 @@ export async function createTeamAccountCheckoutSession(
|
||||
params: z.infer<typeof TeamCheckoutSchema>,
|
||||
) {
|
||||
const data = TeamCheckoutSchema.parse(params);
|
||||
const service = new TeamBillingService(getSupabaseServerActionClient());
|
||||
|
||||
const client = getSupabaseServerActionClient();
|
||||
const service = createTeamBillingService(client);
|
||||
|
||||
return service.createCheckout(data);
|
||||
}
|
||||
@@ -33,7 +35,9 @@ export async function createTeamAccountCheckoutSession(
|
||||
*/
|
||||
export async function createBillingPortalSession(formData: FormData) {
|
||||
const params = TeamBillingPortalSchema.parse(Object.fromEntries(formData));
|
||||
const service = new TeamBillingService(getSupabaseServerActionClient());
|
||||
|
||||
const client = getSupabaseServerActionClient();
|
||||
const service = createTeamBillingService(client);
|
||||
|
||||
// get url to billing portal
|
||||
const url = await service.createBillingPortalSession(params);
|
||||
|
||||
@@ -18,7 +18,15 @@ import { Database } from '~/lib/database.types';
|
||||
|
||||
import { TeamCheckoutSchema } from '../schema/team-billing.schema';
|
||||
|
||||
export class TeamBillingService {
|
||||
export function createTeamBillingService(client: SupabaseClient<Database>) {
|
||||
return new TeamBillingService(client);
|
||||
}
|
||||
|
||||
/**
|
||||
* @name TeamBillingService
|
||||
* @description Service for managing billing for team accounts.
|
||||
*/
|
||||
class TeamBillingService {
|
||||
private readonly namespace = 'billing.team-account';
|
||||
|
||||
constructor(private readonly client: SupabaseClient<Database>) {}
|
||||
|
||||
Reference in New Issue
Block a user