'use server'; import { UpdateUserStatusMutation } from '@/lib/mutations/admin/UpdateUserStatusMutation'; import { DeleteUserMutation } from '@/lib/mutations/admin/DeleteUserMutation'; import { revalidatePath } from 'next/cache'; /** * Server actions for admin operations * * All write operations must enter through server actions. * Actions are thin wrappers that handle framework concerns (revalidation). * Business logic is handled by Mutations. */ /** * Update user status */ export async function updateUserStatus(userId: string, status: string): Promise { try { const mutation = new UpdateUserStatusMutation(); await mutation.execute({ userId, status }); // Revalidate the users page revalidatePath('/admin/users'); } catch (error) { console.error('updateUserStatus failed:', error); throw new Error('Failed to update user status'); } } /** * Delete user */ export async function deleteUser(userId: string): Promise { try { const mutation = new DeleteUserMutation(); await mutation.execute({ userId }); // Revalidate the users page revalidatePath('/admin/users'); } catch (error) { console.error('deleteUser failed:', error); throw new Error('Failed to delete user'); } }