From 4ed2057a45da99bd0cfea1c84349c77a6d65d79e Mon Sep 17 00:00:00 2001 From: Nati Date: Mon, 17 Aug 2026 07:11:07 +0000 Subject: [PATCH] feat(onboarding): enhance navigation after registration by using selected keys --- .../pages/OperationsOnboardingPage.tsx | 20 ++++++++++++++++++- .../components/OperationsFormContent.tsx | 11 +++++++--- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/apps/portal/src/app/features/onboarding/pages/OperationsOnboardingPage.tsx b/apps/portal/src/app/features/onboarding/pages/OperationsOnboardingPage.tsx index bdfe4f524..3f2abd624 100644 --- a/apps/portal/src/app/features/onboarding/pages/OperationsOnboardingPage.tsx +++ b/apps/portal/src/app/features/onboarding/pages/OperationsOnboardingPage.tsx @@ -2,6 +2,22 @@ import { useNavigate } from 'react-router-dom'; import { Container, Paper, Stack, Text, Title } from '@mantine/core'; import { OperationsFormContent } from '../../profile/components/OperationsFormContent'; +/** + * Where a fresh applicant lands after declaring themselves. Someone who says + * "I am a seafarer" or "I own a vessel" came here to register, so they are + * taken straight to that form instead of a dashboard that only links to it. + * Seafarer wins when both are ticked; the other form is one nav click away. + */ +const NEXT_STEP: Record = { + SEAFARER_REGISTRATION: '/seafarer-registration', + VESSEL_REGISTRATION: '/licensing/VESSEL_REGISTRATION/apply', +}; + +function nextStepFor(selectedKeys: string[]): string { + const key = Object.keys(NEXT_STEP).find((k) => selectedKeys.includes(k)); + return key ? NEXT_STEP[key] : '/dashboard'; +} + /** * The one thing a new applicant is asked for beyond their credentials. * @@ -28,7 +44,9 @@ export function OperationsOnboardingPage() { - navigate('/dashboard')} /> + navigate(nextStepFor(keys))} + /> diff --git a/apps/portal/src/app/features/profile/components/OperationsFormContent.tsx b/apps/portal/src/app/features/profile/components/OperationsFormContent.tsx index fb6fe5d6f..564aaa40d 100644 --- a/apps/portal/src/app/features/profile/components/OperationsFormContent.tsx +++ b/apps/portal/src/app/features/profile/components/OperationsFormContent.tsx @@ -47,8 +47,11 @@ const PERSONAL_REGISTRATION_KEYS = [ export function OperationsFormContent({ onSaved, }: { - /** Where to go once the set is stored — used by the onboarding step. */ - onSaved?: () => void; + /** + * Called once the set is stored with the keys of the selected licence + * types — the onboarding step uses them to pick where to go next. + */ + onSaved?: (selectedKeys: string[]) => void; } = {}) { const { data: catalogue, isLoading: loadingTypes } = useGetLicenseTypesQuery(); const { data: mine, isLoading: loadingMine } = useGetMyOperatorTypesQuery(); @@ -118,7 +121,9 @@ export function OperationsFormContent({ 'The licences you can apply for have been updated to match.', 'Operations updated', ); - onSaved?.(); + onSaved?.( + options.filter((t) => selected.includes(t.id)).map((t) => t.key), + ); } catch (err) { notify.error(extractErrorMessage(err), 'Could not save'); }