website refactor

This commit is contained in:
2026-01-14 10:51:05 +01:00
parent 4522d41aef
commit 0d89ad027e
291 changed files with 6887 additions and 3685 deletions

View File

@@ -3,6 +3,8 @@
import { UpdateUserStatusMutation } from '@/lib/mutations/admin/UpdateUserStatusMutation';
import { DeleteUserMutation } from '@/lib/mutations/admin/DeleteUserMutation';
import { revalidatePath } from 'next/cache';
import { Result } from '@/lib/contracts/Result';
import { routes } from '@/lib/routing/RouteConfig';
/**
* Server actions for admin operations
@@ -10,34 +12,44 @@ import { revalidatePath } from 'next/cache';
* All write operations must enter through server actions.
* Actions are thin wrappers that handle framework concerns (revalidation).
* Business logic is handled by Mutations.
* All actions return Result types for type-safe error handling.
*/
/**
* Update user status
*
* @param userId - The ID of the user to update
* @param status - The new status to set
* @returns Result with success indicator or error
*/
export async function updateUserStatus(userId: string, status: string) {
export async function updateUserStatus(userId: string, status: string): Promise<Result<{ success: boolean }, string>> {
const mutation = new UpdateUserStatusMutation();
const result = await mutation.execute({ userId, status });
if (result.isErr()) {
console.error('updateUserStatus failed:', result.getError());
throw new Error('Failed to update user status');
return Result.err(result.getError());
}
revalidatePath('/admin/users');
revalidatePath(routes.admin.users);
return Result.ok({ success: true });
}
/**
* Delete user
*
* @param userId - The ID of the user to delete
* @returns Result with success indicator or error
*/
export async function deleteUser(userId: string) {
export async function deleteUser(userId: string): Promise<Result<{ success: boolean }, string>> {
const mutation = new DeleteUserMutation();
const result = await mutation.execute({ userId });
if (result.isErr()) {
console.error('deleteUser failed:', result.getError());
throw new Error('Failed to delete user');
return Result.err(result.getError());
}
revalidatePath('/admin/users');
revalidatePath(routes.admin.users);
return Result.ok({ success: true });
}