Skip to content

Commit 539553c

Browse files
committed
refactor: reduce nesting in RegistrationForm submit flow
- extract language edge mapping to getLanguagesSpokenAtHomeEdges - replace inline nested map in updateProfile payload construction - address Sonar rule S2004 (excessive function nesting) Refs: KK-1521
1 parent 5a2c5ea commit 539553c

1 file changed

Lines changed: 9 additions & 6 deletions

File tree

src/domain/registration/form/RegistrationForm.tsx

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,12 @@ const getInitialFormData = (
9797
},
9898
});
9999

100+
const getLanguagesSpokenAtHomeEdges = (languages: string[]) => ({
101+
edges: languages.map((language) => ({
102+
node: { id: language, language },
103+
})),
104+
});
105+
100106
const RegistrationForm = () => {
101107
const { i18n, t } = useTranslation();
102108
const currentLocale = getCurrentLanguage(i18n);
@@ -213,13 +219,10 @@ const RegistrationForm = () => {
213219
({
214220
...prevStatus,
215221
...response.data?.submitChildrenAndGuardian?.guardian,
216-
languagesSpokenAtHome: {
217-
edges: values.guardian.languagesSpokenAtHome.map(
218-
(language) => ({
219-
node: { id: language, language },
220-
})
222+
languagesSpokenAtHome:
223+
getLanguagesSpokenAtHomeEdges(
224+
values.guardian.languagesSpokenAtHome
221225
),
222-
},
223226
}) as MyProfile
224227
);
225228
}

0 commit comments

Comments
 (0)