From 23e8b65a61cd0f4e0aca8825d7b0362bee754b6a Mon Sep 17 00:00:00 2001 From: Irakli Chalagashvili Date: Fri, 21 Apr 2023 22:26:44 +0400 Subject: [PATCH] ENG-4058 fix profile type composite attribute --- src/helpers/entities.js | 10 +++++----- test/helpers/entities.test.js | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/helpers/entities.js b/src/helpers/entities.js index 42d690bc9..4b15ea793 100644 --- a/src/helpers/entities.js +++ b/src/helpers/entities.js @@ -56,7 +56,7 @@ export const getPayloadForForm = ( userProfile.attributes.forEach((attr) => { const { - code, value, values, listElements, elements, + code, value, values, listElements, elements, compositeelements, } = attr; const attrType = @@ -117,9 +117,9 @@ export const getPayloadForForm = ( } case TYPE_COMPOSITE: { const childProfileType = selectedProfileType.find(item => item.code === code); - if (elements && childProfileType) { + if (compositeelements && childProfileType) { formAttr[code] = getPayloadForForm( - username, { attributes: elements }, + username, { attributes: compositeelements }, childProfileType.compositeAttributes, defaultLanguage, ); @@ -205,12 +205,12 @@ export const getPayloadForApi = ( } case TYPE_COMPOSITE: { const childProfileType = selectedProfileType.find(item => item.code === key); - const elements = getPayloadForApi( + const compositeelements = getPayloadForApi( profile[key], childProfileType.compositeAttributes, defaultLanguage, ).attributes; - attr.push({ code: key, elements }); + attr.push({ code: key, compositeelements }); break; } default: diff --git a/test/helpers/entities.test.js b/test/helpers/entities.test.js index fc9f23901..4d9927889 100644 --- a/test/helpers/entities.test.js +++ b/test/helpers/entities.test.js @@ -302,7 +302,7 @@ describe('getPayloadForForm', () => { attributes: [ { code: 'someComposite', - elements: [ + compositeelements: [ { code: 'textChild', values: { [DEFAULT_LANGUAGE]: 'random text' } }, { code: 'booleanChild', value: false }, ], @@ -604,7 +604,7 @@ describe('getPayloadForApi', () => { }], testAssertions: (formAttr) => { const attribute = formAttr.attributes.find(attr => attr.code === 'myAttribute'); - expect(attribute).toHaveProperty('elements', [ + expect(attribute).toHaveProperty('compositeelements', [ { code: 'textChild', values: { [DEFAULT_LANGUAGE]: 'random text' } }, { code: 'booleanChild', value: false }, ]);