Skip to content

Commit 07e33b7

Browse files
fix: handle missing capture namespace in DataStore
1 parent ec86768 commit 07e33b7

File tree

1 file changed

+11
-6
lines changed
  • src/core_modules/capture-core/components/DataEntries/common/TEIAndEnrollment/useMetadataForRegistrationForm/hooks

1 file changed

+11
-6
lines changed

src/core_modules/capture-core/components/DataEntries/common/TEIAndEnrollment/useMetadataForRegistrationForm/hooks/useDataEntryFormConfig.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,15 @@ export const useDataEntryFormConfig = ({ selectedScopeId }: Props) => {
2020
} = useApiMetadataQuery<any>(
2121
['dataStore', 'capture'],
2222
{ resource: 'dataStore/capture' },
23-
{
24-
select: (captureKeys: Array<string> | null | undefined) => captureKeys?.includes('dataEntryForms'),
25-
},
23+
{ select: (captureKeys: Array<string> | null) => captureKeys?.includes('dataEntryForms') },
2624
);
2725

2826
const {
2927
data: dataEntryFormConfig,
3028
isFetched,
3129
isError,
3230
error,
33-
} = useApiMetadataQuery(['dataStore', 'capture', 'dataEntryForms', selectedScopeId], configQuery, {
31+
} = useApiMetadataQuery(['dataEntryFormConfig', selectedScopeId], configQuery, {
3432
enabled: !!configExists && !!selectedScopeId,
3533
select: (dataEntryFormConfigQuery: any) => dataEntryFormConfigQuery?.[selectedScopeId] ?? null,
3634
});
@@ -47,6 +45,13 @@ export const useDataEntryFormConfig = ({ selectedScopeId }: Props) => {
4745
const configIsFetched = (namespaceIsFetched && !configExists) || isFetched;
4846

4947
return namespaceIsError || isError
50-
? { dataEntryFormConfig: null, configIsFetched: true, isLoading: false }
51-
: { dataEntryFormConfig, configIsFetched, isLoading: !configIsFetched };
48+
? {
49+
dataEntryFormConfig: null,
50+
configIsFetched: true,
51+
isLoading: false,
52+
}
53+
: { dataEntryFormConfig,
54+
configIsFetched,
55+
isLoading: !configIsFetched,
56+
};
5257
};

0 commit comments

Comments
 (0)