website refactor
This commit is contained in:
20
apps/website/app/profile/actions.ts
Normal file
20
apps/website/app/profile/actions.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
'use server';
|
||||
|
||||
import { revalidatePath } from 'next/cache';
|
||||
import { Result } from '@/lib/contracts/Result';
|
||||
import { routes } from '@/lib/routing/RouteConfig';
|
||||
import { UpdateDriverProfileMutation } from '@/lib/mutations/drivers/UpdateDriverProfileMutation';
|
||||
|
||||
export async function updateProfileAction(
|
||||
updates: { bio?: string; country?: string },
|
||||
): Promise<Result<void, string>> {
|
||||
const mutation = new UpdateDriverProfileMutation();
|
||||
const result = await mutation.execute({ bio: updates.bio, country: updates.country });
|
||||
|
||||
if (result.isErr()) {
|
||||
return Result.err(result.getError());
|
||||
}
|
||||
|
||||
revalidatePath(routes.protected.profile);
|
||||
return Result.ok(undefined);
|
||||
}
|
||||
Reference in New Issue
Block a user