feat(onboarding): enhance navigation after registration by using selected keys

This commit is contained in:
Nati
2026-08-17 07:11:07 +00:00
parent c698f381b9
commit 4ed2057a45
2 changed files with 27 additions and 4 deletions

View File

@@ -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<string, string> = {
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() {
</Text>
</div>
<Paper p="xl" shadow="sm" radius="lg" withBorder>
<OperationsFormContent onSaved={() => navigate('/dashboard')} />
<OperationsFormContent
onSaved={(keys) => navigate(nextStepFor(keys))}
/>
</Paper>
</Stack>
</Container>

View File

@@ -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');
}