Skip to content

Commit c1b725e

Browse files
committed
feat: add age limit editor in group manage form
1 parent a850d30 commit c1b725e

2 files changed

Lines changed: 42 additions & 0 deletions

File tree

apps/web/src/routes/_app/group/manage.tsx

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ type ManageGroupFormProps = {
3232
accessibleInteractiveInstrumentIds: Set<string>;
3333
defaultIdentificationMethod?: SubjectIdentificationMethod;
3434
idValidationRegex?: null | string;
35+
minimumAge?: number;
36+
minimumAgeApplied?: boolean;
3537
subjectIdDisplayLength?: number;
3638
};
3739
};
@@ -86,6 +88,40 @@ const ManageGroupForm = ({ data, onSubmit, readOnly }: ManageGroupFormProps) =>
8688
fr: "Paramètres d'affichage"
8789
})
8890
},
91+
{
92+
fields: {
93+
minimumAgeApplied: {
94+
kind: 'boolean',
95+
label: t({
96+
en: 'Apply Minimum Age For Subjects',
97+
fr: 'Appliquer un âge minimum aux sujets'
98+
}),
99+
variant: 'radio'
100+
},
101+
// eslint-disable-next-line perfectionist/sort-objects
102+
minimumAge: {
103+
deps: ['minimumAgeApplied'],
104+
kind: 'dynamic',
105+
render: (data) => {
106+
if (data.minimumAgeApplied) {
107+
return {
108+
kind: 'number',
109+
label: t({
110+
en: 'Enter minimum age',
111+
fr: "Entrez l'âge minimum"
112+
}),
113+
variant: 'input'
114+
};
115+
}
116+
return null;
117+
}
118+
}
119+
},
120+
title: t({
121+
en: 'Age Limit Settings',
122+
fr: "Paramètres de l'âge"
123+
})
124+
},
89125
{
90126
fields: {
91127
defaultIdentificationMethod: {
@@ -157,6 +193,8 @@ const ManageGroupForm = ({ data, onSubmit, readOnly }: ManageGroupFormProps) =>
157193
idValidationRegex: $RegexString.optional(),
158194
idValidationRegexErrorMessageEn: z.string().optional(),
159195
idValidationRegexErrorMessageFr: z.string().optional(),
196+
minimumAge: z.number().int().positive().optional(),
197+
minimumAgeApplied: z.boolean().optional(),
160198
subjectIdDisplayLength: z.number().int().min(1)
161199
})}
162200
onSubmit={(data) => {
@@ -169,6 +207,8 @@ const ManageGroupForm = ({ data, onSubmit, readOnly }: ManageGroupFormProps) =>
169207
en: data.idValidationRegexErrorMessageEn,
170208
fr: data.idValidationRegexErrorMessageFr
171209
},
210+
minimumAge: data.minimumAge,
211+
minimumAgeApplied: data.minimumAgeApplied,
172212
subjectIdDisplayLength: data.subjectIdDisplayLength
173213
}
174214
});

packages/schemas/src/group/group.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ export const $GroupSettings = z.object({
1313
fr: z.string().nullish()
1414
})
1515
.nullish(),
16+
minimumAge: z.number().int().positive().nullish(),
17+
minimumAgeApplied: z.boolean().nullish(),
1618
subjectIdDisplayLength: z.number().nullish()
1719
});
1820

0 commit comments

Comments
 (0)