Files
myeasycms-v2/apps/web/app/admin/organizations/@modal/[uid]/actions.server.ts
giancarlo bce3479368 Cleanup
2024-03-24 02:23:22 +08:00

30 lines
819 B
TypeScript

'use server';
import { revalidatePath } from 'next/cache';
import { redirect } from 'next/navigation';
import { withAdminSession } from '~/admin/lib/actions-utils';
import { Logger } from '@kit/shared/logger';
import { getSupabaseServerActionClient } from '@kit/supabase/server-actions-client';
const getClient = () => getSupabaseServerActionClient({ admin: true });
export const deleteOrganizationAction = withAdminSession(
async ({ id }: { id: number; csrfToken: string }) => {
const client = getClient();
Logger.info({ id }, `Admin requested to delete Organization`);
await deleteOrganization(client, {
organizationId: id,
});
revalidatePath('/admin/organizations', 'page');
Logger.info({ id }, `Organization account deleted`);
redirect('/admin/organizations');
},
);