website refactor
This commit is contained in:
3
apps/website/app/onboarding/OnboardingLayoutProps.ts
Normal file
3
apps/website/app/onboarding/OnboardingLayoutProps.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
export interface OnboardingLayoutProps {
|
||||
children: React.ReactNode;
|
||||
}
|
||||
@@ -3,7 +3,8 @@
|
||||
import { useRouter } from 'next/navigation';
|
||||
import { OnboardingWizard } from '@/components/onboarding/OnboardingWizard';
|
||||
import { routes } from '@/lib/routing/RouteConfig';
|
||||
import { completeOnboardingAction, generateAvatarsAction } from './actions';
|
||||
import { completeOnboardingAction } from './completeOnboardingAction';
|
||||
import { generateAvatarsAction } from './generateAvatarsAction';
|
||||
import { useAuth } from '@/lib/auth/AuthContext';
|
||||
|
||||
export function OnboardingWizardClient() {
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
import { Result } from '@/lib/contracts/Result';
|
||||
import { CompleteOnboardingMutation } from '@/lib/mutations/onboarding/CompleteOnboardingMutation';
|
||||
import { GenerateAvatarsMutation } from '@/lib/mutations/onboarding/GenerateAvatarsMutation';
|
||||
import { CompleteOnboardingInputDTO } from '@/lib/types/generated/CompleteOnboardingInputDTO';
|
||||
import { revalidatePath } from 'next/cache';
|
||||
import { routes } from '@/lib/routing/RouteConfig';
|
||||
@@ -28,26 +27,4 @@ export async function completeOnboardingAction(
|
||||
|
||||
revalidatePath(routes.protected.dashboard);
|
||||
return Result.ok({ success: true });
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 });
|
||||
}
|
||||
26
apps/website/app/onboarding/generateAvatarsAction.ts
Normal file
26
apps/website/app/onboarding/generateAvatarsAction.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
'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 });
|
||||
}
|
||||
@@ -1,7 +1,3 @@
|
||||
interface OnboardingLayoutProps {
|
||||
children: React.ReactNode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Onboarding Layout
|
||||
*
|
||||
@@ -11,6 +7,7 @@ interface OnboardingLayoutProps {
|
||||
import { headers } from 'next/headers';
|
||||
import { redirect } from 'next/navigation';
|
||||
import { createRouteGuard } from '@/lib/auth/createRouteGuard';
|
||||
import { OnboardingLayoutProps } from './OnboardingLayoutProps';
|
||||
|
||||
export default async function OnboardingLayout({ children }: OnboardingLayoutProps) {
|
||||
const headerStore = await headers();
|
||||
|
||||
Reference in New Issue
Block a user