21 lines
678 B
TypeScript
21 lines
678 B
TypeScript
'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);
|
|
}
|