Skip to content

Commit e5fb9da

Browse files
committed
feat: pass username in as data instead of all of currentUser
1 parent 6c9a1d1 commit e5fb9da

2 files changed

Lines changed: 4 additions & 6 deletions

File tree

apps/web/src/components/StartSessionForm/StartSessionForm.tsx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ import { encodeScopedSubjectId, generateSubjectHash } from '@opendatacapture/sub
1313
import type { Promisable } from 'type-fest';
1414
import { z } from 'zod/v4';
1515

16-
import type { CurrentUser } from '@/store/types';
17-
1816
const currentDate = new Date();
1917

2018
const EIGHTEEN_YEARS = 568025136000; // milliseconds
@@ -34,15 +32,15 @@ type StartSessionFormData = {
3432

3533
type StartSessionFormProps = {
3634
currentGroup: Group | null;
37-
currentUser: CurrentUser | null;
3835
initialValues?: FormTypes.PartialNullableData<StartSessionFormData>;
3936
onSubmit: (data: CreateSessionData) => Promisable<void>;
4037
readOnly: boolean;
38+
username: string | undefined;
4139
};
4240

4341
export const StartSessionForm = ({
4442
currentGroup,
45-
currentUser,
43+
username,
4644
initialValues,
4745
readOnly,
4846
onSubmit
@@ -253,7 +251,7 @@ export const StartSessionForm = ({
253251
await onSubmit({
254252
date: sessionDate,
255253
groupId: currentGroup?.id ?? null,
256-
username: currentUser?.username ?? null,
254+
username: username ?? null,
257255
type: sessionType,
258256
subjectData: {
259257
id: subjectId,

apps/web/src/routes/_app/session/start-session.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ const RouteComponent = () => {
4343
</PageHeader>
4444
<StartSessionForm
4545
currentGroup={currentGroup}
46-
currentUser={currentUser}
4746
initialValues={initialValues}
4847
readOnly={currentSession !== null || createSessionMutation.isPending}
48+
username={currentUser?.username}
4949
onSubmit={async (formData) => {
5050
const session = await createSessionMutation.mutateAsync(formData);
5151
startSession({ ...session, type: formData.type });

0 commit comments

Comments
 (0)