diff --git a/apps/web/src/features/session/pages/StartSessionPage.tsx b/apps/web/src/features/session/pages/StartSessionPage.tsx index 03603174b..d1c328ed6 100644 --- a/apps/web/src/features/session/pages/StartSessionPage.tsx +++ b/apps/web/src/features/session/pages/StartSessionPage.tsx @@ -15,18 +15,23 @@ export const StartSessionPage = () => { const currentGroup = useAppStore((store) => store.currentGroup); const currentSession = useAppStore((store) => store.currentSession); const startSession = useAppStore((store) => store.startSession); - const [key, setKey] = useState(0); const location = useLocation() as Location<{ initialValues?: FormTypes.PartialNullableData; } | null>; + const defaultInitialValues = { + sessionType: 'IN_PERSON', + subjectIdentificationMethod: currentGroup?.settings.defaultIdentificationMethod ?? 'CUSTOM_ID' + } as const; + const [initialValues, setInitialValues] = useState>( + location.state?.initialValues ?? defaultInitialValues + ); const { t } = useTranslation('session'); const createSessionMutation = useCreateSession(); - // this is to force reset the form when the session changes, if on the same page useEffect(() => { if (currentSession === null) { - setKey(key + 1); + setInitialValues(defaultInitialValues); } }, [currentSession]); @@ -39,17 +44,11 @@ export const StartSessionPage = () => { { - const session = await createSessionMutation.mutateAsync(data); - startSession(session); + onSubmit={async (formData) => { + const session = await createSessionMutation.mutateAsync(formData); + startSession({ ...session, type: formData.type }); }} /> diff --git a/package.json b/package.json index 4bd10a2b3..b952070f5 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "opendatacapture", "type": "module", - "version": "1.8.2", + "version": "1.8.3", "private": true, "packageManager": "pnpm@9.14.2", "license": "Apache-2.0",