Skip to content

Commit 6cf0d00

Browse files
committed
refactor: use WithFallback in ManageGroup Page
1 parent 1feaf24 commit 6cf0d00

File tree

1 file changed

+15
-12
lines changed

1 file changed

+15
-12
lines changed

apps/web/src/features/group/pages/ManageGroupPage.tsx

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { Heading } from '@douglasneuroinformatics/libui/components';
44
import { useTranslation } from '@douglasneuroinformatics/libui/hooks';
55

66
import { PageHeader } from '@/components/PageHeader';
7+
import { WithFallback } from '@/components/WithFallback';
78
import { useInstrumentInfoQuery } from '@/hooks/useInstrumentInfoQuery';
89
import { useSetupState } from '@/hooks/useSetupState';
910
import { useAppStore } from '@/store';
@@ -19,12 +20,15 @@ export const ManageGroupPage = () => {
1920
const changeGroup = useAppStore((store) => store.changeGroup);
2021
const setupState = useSetupState();
2122

22-
const availableInstruments = instrumentInfoQuery.data ?? [];
23+
const availableInstruments = instrumentInfoQuery.data;
2324

2425
const accessibleInstrumentIds = currentGroup?.accessibleInstrumentIds;
2526
const defaultIdentificationMethod = currentGroup?.settings.defaultIdentificationMethod;
2627

27-
const { availableInstrumentOptions, initialValues } = useMemo(() => {
28+
const data = useMemo(() => {
29+
if (!availableInstruments) {
30+
return null;
31+
}
2832
const availableInstrumentOptions: AvailableInstrumentOptions = {
2933
form: {},
3034
interactive: {},
@@ -69,16 +73,15 @@ export const ManageGroupPage = () => {
6973
{t('manage.pageTitle')}
7074
</Heading>
7175
</PageHeader>
72-
73-
<ManageGroupForm
74-
data={{
75-
availableInstrumentOptions,
76-
initialValues
77-
}}
78-
readOnly={Boolean(setupState.data?.isDemo && import.meta.env.PROD)}
79-
onSubmit={async (data) => {
80-
const updatedGroup = await updateGroupMutation.mutateAsync(data);
81-
changeGroup(updatedGroup);
76+
<WithFallback
77+
Component={ManageGroupForm}
78+
props={{
79+
data,
80+
onSubmit: async (data) => {
81+
const updatedGroup = await updateGroupMutation.mutateAsync(data);
82+
changeGroup(updatedGroup);
83+
},
84+
readOnly: Boolean(setupState.data?.isDemo && import.meta.env.PROD)
8285
}}
8386
/>
8487
</React.Fragment>

0 commit comments

Comments
 (0)