Replace deleteAccount with deleteUser in admin dialog
The code updates the action called when submitting the form in the 'AdminDeleteUserDialog' component. Instead of triggering 'deleteAccount', it now calls 'deleteUser'. Additionally, after a user or an account is deleted, the admin is redirected to the '/admin/accounts' route instead of receiving a 'success: true' message.
This commit is contained in:
@@ -25,7 +25,7 @@ import {
|
||||
} from '@kit/ui/form';
|
||||
import { Input } from '@kit/ui/input';
|
||||
|
||||
import { deleteAccount, deleteUser } from '../lib/server/admin-server-actions';
|
||||
import { deleteUser } from '../lib/server/admin-server-actions';
|
||||
import { DeleteUserSchema } from '../lib/server/schema/admin-actions.schema';
|
||||
|
||||
export function AdminDeleteUserDialog(
|
||||
@@ -60,7 +60,7 @@ export function AdminDeleteUserDialog(
|
||||
<form
|
||||
className={'flex flex-col space-y-8'}
|
||||
onSubmit={form.handleSubmit((data) => {
|
||||
return deleteAccount(data);
|
||||
return deleteUser(data);
|
||||
})}
|
||||
>
|
||||
<FormField
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
'use server';
|
||||
|
||||
import { revalidatePath } from 'next/cache';
|
||||
import { redirect } from 'next/navigation';
|
||||
|
||||
import { enhanceAction } from '@kit/next/actions';
|
||||
import { getSupabaseServerActionClient } from '@kit/supabase/server-actions-client';
|
||||
@@ -92,9 +93,7 @@ export const deleteUser = enhanceAdminAction(
|
||||
|
||||
revalidateAdmin();
|
||||
|
||||
return {
|
||||
success: true,
|
||||
};
|
||||
return redirect('/admin/accounts');
|
||||
},
|
||||
{
|
||||
schema: DeleteUserSchema,
|
||||
@@ -115,9 +114,7 @@ export const deleteAccount = enhanceAdminAction(
|
||||
|
||||
revalidateAdmin();
|
||||
|
||||
return {
|
||||
success: true,
|
||||
};
|
||||
return redirect('/admin/accounts');
|
||||
},
|
||||
{
|
||||
schema: DeleteAccountSchema,
|
||||
|
||||
Reference in New Issue
Block a user