Remove team account related services and actions

Removed services and actions related to team account deletion as well as updated paths within other dependent files, better reflecting their new locations. Also, added a new service titled 'AccountBillingService' for handling billing-related operations and restructured the form layout and handled translation in 'team-account-danger-zone' component.
This commit is contained in:
giancarlo
2024-03-28 15:27:56 +08:00
parent 3ac4d3b00d
commit 041efb89fb
77 changed files with 1998 additions and 1553 deletions

View File

@@ -0,0 +1,75 @@
'use server';
import { SupabaseClient } from '@supabase/supabase-js';
import { Database } from '@kit/supabase/database';
import { getSupabaseServerActionClient } from '@kit/supabase/server-actions-client';
import { AccountMembersService } from '../services/account-members.service';
export async function removeMemberFromAccountAction(params: {
accountId: string;
userId: string;
}) {
const client = getSupabaseServerActionClient();
const { data, error } = await client.auth.getUser();
if (error ?? !data.user) {
throw new Error(`Authentication required`);
}
const service = new AccountMembersService(client);
await service.removeMemberFromAccount({
accountId: params.accountId,
userId: params.userId,
});
return { success: true };
}
export async function updateMemberRoleAction(params: {
accountId: string;
userId: string;
role: Database['public']['Enums']['account_role'];
}) {
const client = getSupabaseServerActionClient();
await assertSession(client);
const service = new AccountMembersService(client);
await service.updateMemberRole({
accountId: params.accountId,
userId: params.userId,
role: params.role,
});
return { success: true };
}
export async function transferOwnershipAction(params: {
accountId: string;
userId: string;
}) {
const client = getSupabaseServerActionClient();
await assertSession(client);
const service = new AccountMembersService(client);
await service.transferOwnership({
accountId: params.accountId,
userId: params.userId,
});
return { success: true };
}
async function assertSession(client: SupabaseClient<Database>) {
const { data, error } = await client.auth.getUser();
if (error ?? !data.user) {
throw new Error(`Authentication required`);
}
}