Multiple updates are made to refine the account management features, including updating the 'Your Teams' text to show the number of teams, and modifying the form data validation process in the 'deletePersonalAccountAction' service. Additionally, improvements have been made in test configurations including updating the test timeout settings, taking screenshots when a test fails, and adjusting the location for saving Playwright reports.
58 lines
1.3 KiB
TypeScript
58 lines
1.3 KiB
TypeScript
import 'server-only';
|
|
|
|
import { SupabaseClient } from '@supabase/supabase-js';
|
|
|
|
import { getLogger } from '@kit/shared/logger';
|
|
import { Database } from '@kit/supabase/database';
|
|
|
|
export class DeleteTeamAccountService {
|
|
private readonly namespace = 'accounts.delete-team-account';
|
|
|
|
/**
|
|
* Deletes a team account. Permissions are not checked here, as they are
|
|
* checked in the server action.
|
|
*
|
|
* USE WITH CAUTION. THE USER MUST HAVE THE NECESSARY PERMISSIONS.
|
|
*
|
|
* @param adminClient
|
|
* @param params
|
|
*/
|
|
async deleteTeamAccount(
|
|
adminClient: SupabaseClient<Database>,
|
|
params: {
|
|
accountId: string;
|
|
userId: string;
|
|
},
|
|
) {
|
|
const logger = await getLogger();
|
|
|
|
const ctx = {
|
|
accountId: params.accountId,
|
|
userId: params.userId,
|
|
name: this.namespace,
|
|
};
|
|
|
|
logger.info(ctx, `Requested team account deletion. Processing...`);
|
|
|
|
// we can use the admin client to delete the account.
|
|
const { error } = await adminClient
|
|
.from('accounts')
|
|
.delete()
|
|
.eq('id', params.accountId);
|
|
|
|
if (error) {
|
|
logger.error(
|
|
{
|
|
...ctx,
|
|
error,
|
|
},
|
|
'Failed to delete team account',
|
|
);
|
|
|
|
throw new Error('Failed to delete team account');
|
|
}
|
|
|
|
logger.info(ctx, 'Successfully deleted team account');
|
|
}
|
|
}
|