From 8817b7d5271fd6a4f02f7454b57b31d290025f28 Mon Sep 17 00:00:00 2001 From: Nina Kylstad Date: Thu, 7 Mar 2024 08:41:18 +0100 Subject: [PATCH] allow both uppercase and lowercase in model metadata response (#12458) * allow both uppercase and lowercase in model metadata response * keep the hack internal to the query --- .../src/hooks/queries/useDatamodelMetadataQuery.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/frontend/packages/ux-editor/src/hooks/queries/useDatamodelMetadataQuery.ts b/frontend/packages/ux-editor/src/hooks/queries/useDatamodelMetadataQuery.ts index 19f11f81ed1..8f5c841415a 100644 --- a/frontend/packages/ux-editor/src/hooks/queries/useDatamodelMetadataQuery.ts +++ b/frontend/packages/ux-editor/src/hooks/queries/useDatamodelMetadataQuery.ts @@ -15,9 +15,15 @@ export const useDatamodelMetadataQuery = ( queryFn: () => getDatamodelMetadata(org, app, layoutSetName).then((res) => { const dataModelFields: DatamodelFieldElement[] = []; - Object.keys(res.elements).forEach((dataModelField) => { + + // Hack because we don't know if the response is upper or lower cased. Should be reverted once + // https://github.com/Altinn/altinn-studio/pull/12457 is ready, this should fix the issue in the API. + const response = res as unknown as any; + const elements = response.elements || response.Elements; // End of hack. + + Object.keys(elements).forEach((dataModelField) => { if (dataModelField) { - dataModelFields.push(res.elements[dataModelField]); + dataModelFields.push(elements[dataModelField]); } }); return dataModelFields;