Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
  • Loading branch information
jagankumar-egov and coderabbitai[bot] authored Dec 20, 2024
1 parent ce10d23 commit 9a32b78
Showing 1 changed file with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
/**
* Builds localization messages for the MDMS submission process.
* Used when creating new complaint types from the workbench to handle localization upserts.
*
* @param {Object} additionalProperties - The properties containing localization data
* @param {string} moduleName - The name of the module to be localized
* @param {string} locale - The locale identifier
* @returns {Array<Object>} Array of localization message objects
*/
export const buildLocalizationMessages = (additionalProperties, moduleName, locale) => {
if (!additionalProperties || typeof additionalProperties !== "object") return [];

Expand All @@ -6,10 +15,11 @@ export const buildLocalizationMessages = (additionalProperties, moduleName, loca

for (const fieldName in additionalProperties) {
if (Object.hasOwn(additionalProperties, fieldName)) {
const fieldProps = additionalProperties[fieldName];
const transformedLocCode = tranformLocModuleName(fieldProps?.localizationCode);

if (fieldProps?.localizationCode && fieldProps?.localizationMessage) {
const fieldProps = additionalProperties[fieldName] || {};
const { localizationCode, localizationMessage } = fieldProps;
const transformedLocCode = tranformLocModuleName(localizationCode);

if (localizationCode && localizationMessage) {
messages.push({
code: transformedLocCode,
message: fieldProps.localizationMessage,
Expand Down

0 comments on commit 9a32b78

Please sign in to comment.