File tree Expand file tree Collapse file tree 2 files changed +6
-8
lines changed Expand file tree Collapse file tree 2 files changed +6
-8
lines changed Original file line number Diff line number Diff line change 1
- import { useApplicationMetadata } from 'src/features/applicationMetadata/ApplicationMetadataProvider' ;
2
1
import type { IDataType } from 'src/types/shared' ;
3
2
4
- export function useAvailableDataModels ( ) {
5
- const dataTypes = useApplicationMetadata ( ) . dataTypes ;
6
- return dataTypes . filter ( ( dataType ) => getDataTypeVariant ( dataType ) === DataTypeVariant . DataModel ) ;
7
- }
8
-
9
3
export enum DataTypeVariant {
10
4
Pdf = 'pdf' ,
11
5
Attachment = 'attachment' ,
Original file line number Diff line number Diff line change @@ -4,8 +4,9 @@ import type { PropsWithChildren } from 'react';
4
4
import dot from 'dot-object' ;
5
5
6
6
import { ContextNotProvided , createContext } from 'src/core/contexts/context' ;
7
+ import { useApplicationMetadata } from 'src/features/applicationMetadata/ApplicationMetadataProvider' ;
7
8
import { getFirstDataElementId } from 'src/features/applicationMetadata/appMetadataUtils' ;
8
- import { useAvailableDataModels } from 'src/features/datamodel/useAvailableDataModels' ;
9
+ import { DataTypeVariant , getDataTypeVariant } from 'src/features/datamodel/useAvailableDataModels' ;
9
10
import { useFormDataQuery } from 'src/features/formData/useFormDataQuery' ;
10
11
import { useInstanceDataElements , useLaxInstanceId } from 'src/features/instance/InstanceContext' ;
11
12
import { useNavigationParam } from 'src/hooks/navigation' ;
@@ -102,7 +103,10 @@ export class DataModelReaders {
102
103
* to render FormDataReadersProvider somewhere inside if rendering in a form, and render DataModelFetcher.
103
104
*/
104
105
export function GlobalFormDataReadersProvider ( { children } : PropsWithChildren ) {
105
- const availableModels = useAvailableDataModels ( ) . map ( ( dm ) => dm . id ) ;
106
+ const dataTypes = useApplicationMetadata ( ) . dataTypes ;
107
+ const availableModels = dataTypes
108
+ . filter ( ( dataType ) => getDataTypeVariant ( dataType ) === DataTypeVariant . DataModel )
109
+ . map ( ( dm ) => dm . id ) ;
106
110
const [ readerMap , setReaderMap ] = useState < { [ name : string ] : DataModelReader } > ( { } ) ;
107
111
108
112
const updateModel = useCallback ( ( newModel : DataModelReader ) => {
You can’t perform that action at this time.
0 commit comments