26 lines
839 B
TypeScript
26 lines
839 B
TypeScript
'use server';
|
|
|
|
import { Result } from '@/lib/contracts/Result';
|
|
import { GenerateAvatarsMutation } from '@/lib/mutations/onboarding/GenerateAvatarsMutation';
|
|
|
|
/**
|
|
* Generate avatars - thin wrapper around mutation
|
|
*
|
|
* Note: This action requires userId to be passed from the client.
|
|
* The client should get userId from session and pass it as a parameter.
|
|
*/
|
|
export async function generateAvatarsAction(params: {
|
|
userId: string;
|
|
facePhotoData: string;
|
|
suitColor: string;
|
|
}): Promise<Result<{ success: boolean; avatarUrls?: string[] }, string>> {
|
|
const mutation = new GenerateAvatarsMutation();
|
|
const result = await mutation.execute(params);
|
|
|
|
if (result.isErr()) {
|
|
return Result.err(result.getError());
|
|
}
|
|
|
|
const data = result.unwrap();
|
|
return Result.ok({ success: data.success, avatarUrls: data.avatarUrls });
|
|
} |