Skip to content

Commit e255606

Browse files
committed
fix: remove group option for admin
1 parent b536b6a commit e255606

1 file changed

Lines changed: 15 additions & 6 deletions

File tree

apps/web/src/features/admin/pages/CreateUserPage.tsx

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,19 @@ export const CreateUserPage = () => {
8080
variant: 'select'
8181
},
8282
groupIds: {
83-
kind: 'set',
84-
label: t('common.groups'),
85-
options: Object.fromEntries((groupsQuery.data ?? []).map((group) => [group.id, group.name])),
86-
variant: 'listbox'
83+
kind: 'dynamic',
84+
deps: ['basePermissionLevel'],
85+
render({ basePermissionLevel }) {
86+
if (!basePermissionLevel || basePermissionLevel === 'ADMIN') {
87+
return null;
88+
}
89+
return {
90+
kind: 'set',
91+
label: t('common.groups'),
92+
options: Object.fromEntries((groupsQuery.data ?? []).map((group) => [group.id, group.name])),
93+
variant: 'listbox'
94+
};
95+
}
8796
}
8897
}
8998
},
@@ -125,7 +134,7 @@ export const CreateUserPage = () => {
125134
})
126135
.extend({
127136
basePermissionLevel: $BasePermissionLevel,
128-
groupIds: z.set(z.string()),
137+
groupIds: z.set(z.string()).optional(),
129138
confirmPassword: z.string().min(1)
130139
})
131140
.superRefine((arg, ctx) => {
@@ -146,7 +155,7 @@ export const CreateUserPage = () => {
146155
});
147156
}
148157
})}
149-
onSubmit={(data) => handleSubmit({ ...data, groupIds: Array.from(data.groupIds) })}
158+
onSubmit={(data) => handleSubmit({ ...data, groupIds: Array.from(data.groupIds ?? []) })}
150159
/>
151160
</div>
152161
);

0 commit comments

Comments
 (0)