diff --git a/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/CreateChecklist.js b/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/CreateChecklist.js index e1219b2b03..c0fdf068f3 100644 --- a/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/CreateChecklist.js +++ b/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/CreateChecklist.js @@ -43,6 +43,7 @@ const CreateChecklist = () => { const history = useHistory(); const [serviceCode, setServiceCode] = useState(null); const [def_data, setDef_Data] = useState(null); + const [helpText, setHelpText] = useState(""); module = "hcm-checklist"; @@ -428,7 +429,8 @@ const CreateChecklist = () => { value: { name: checklistName, type: checklistType, - role: role + role: role, + helpText: helpText } } ] @@ -447,28 +449,38 @@ const CreateChecklist = () => { } setSubmitting(true); try { - const data = await mutateAsync(payload); // Use mutateAsync for await support - // Handle successful checklist creation - // Proceed with localization if needed + // Prepare localization data let checklistTypeTemp = checklistType.toUpperCase().replace(/ /g, "_"); if (checklistTypeCode) checklistTypeTemp = checklistTypeCode; let roleTemp = role.toUpperCase().replace(/ /g, "_"); + let helpTextCode = helpText.toUpperCase().replace(/ /g, "_"); uniqueLocal.push({ code: `${campaignName}.${checklistTypeTemp}.${roleTemp}`, locale: locale, message: `${t(checklistTypeLocal)} ${t(roleLocal)}`, module: "hcm-checklist" }); + uniqueLocal.push({ + code: `${campaignName}.${checklistTypeTemp}.${roleTemp}.${helpTextCode}`, + locale: locale, + message: helpText, + module: "hcm-checklist" + }); + + // Call upsert first + const localisations = uniqueLocal; + const localisationResult = await localisationMutateAsync(localisations); + + if (!localisationResult.success) { + // Exit if upsert (localisation) fails + setShowToast({ label: "LOCALIZATION_FAILED_PLEASE_TRY_AGAIN", isError: "true" }); + return; + } + + // Proceed to create checklist + const data = await mutateAsync(payload); + if (data.success) { // Replace with your actual condition - const localisations = uniqueLocal; - const localisationResult = await localisationMutateAsync(localisations); - // Check if localization succeeded - if (!localisationResult.success) { - setShowToast({ label: "CHECKLIST_CREATED_LOCALISATION_ERROR", isError: "true" }); - return; // Exit if localization fails - } - - // setShowToast({ label: "CHECKLIST_AND_LOCALISATION_CREATED_SUCCESSFULLY"}); history.push(`/${window.contextPath}/employee/campaign/response?isSuccess=${true}`, { message: "ES_CHECKLIST_CREATE_SUCCESS_RESPONSE", preText: "ES_CHECKLIST_CREATE_SUCCESS_RESPONSE_PRE_TEXT", @@ -610,6 +622,19 @@ const CreateChecklist = () => { placeholder={"Checklist Name"} /> +
+
{t("CHECKLIST_HELP_TEXT")}
+ setHelpText(event.target.value)} + placeholder={t("CHECKLIST_HELP_TEXT_PALCEHOLDER")} + /> +
{ const [previewData, setPreviewData] = useState([]); const [showPopUp, setShowPopUp] = useState(false); const [curActive, setCurActive] = useState(false); + const [helpText, setHelpText] = useState(""); const popShow = () => { @@ -73,6 +74,7 @@ const UpdateChecklist = () => { select: (res) => { if (res?.ServiceDefinitions?.[0]?.attributes) { setCurActive(res?.ServiceDefinitions?.[0].isActive); + setHelpText(res?.ServiceDefinitions?.[0]?.additionalFields?.fields?.[0]?.value?.helpText); let temp_data = res?.ServiceDefinitions?.[0]?.attributes let formatted_data = temp_data.map((item) => item.additionalFields?.fields?.[0]?.value); let nvd = formatted_data.filter((value, index, self) => @@ -375,7 +377,8 @@ const UpdateChecklist = () => { value: { name: checklistName, type: checklistType, - role: role + role: role, + helpText: helpText } } ] @@ -398,12 +401,19 @@ const UpdateChecklist = () => { let checklistTypeTemp = checklistType.toUpperCase().replace(/ /g, "_"); if (checklistTypeCode) checklistTypeTemp = checklistTypeCode; let roleTemp = role.toUpperCase().replace(/ /g, "_"); + let helpTextCode = helpText.toUpperCase().replace(/ /g, "_"); uniqueLocal.push({ code: `${campaignName}.${checklistTypeTemp}.${roleTemp}`, locale: locale, message: `${t(checklistTypeLocal)} ${t(roleLocal)}`, module: "hcm-checklist" }); + uniqueLocal.push({ + code: `${campaignName}.${checklistTypeTemp}.${roleTemp}.${helpTextCode}`, + locale: locale, + message: helpText, + module: "hcm-checklist" + }); // Call upsert first const localisations = uniqueLocal; @@ -454,6 +464,7 @@ const UpdateChecklist = () => { { label: "CHECKLIST_ROLE", value: roleLocal }, { label: "TYPE_OF_CHECKLIST", value: checklistTypeLocal }, { label: "CAMPAIGN_NAME", value: campaignName }, + // { label: "CHECKLIST_HELP_TEXT", value: helpText } // { label: "CHECKLIST_NAME", value: name} ]; @@ -532,6 +543,21 @@ const UpdateChecklist = () => { {index !== fieldPairs.length - 1 &&
} ))} + { +
+
{t("CHECKLIST_HELP_TEXT")}
+ setHelpText(event.target.value)} + placeholder={t("CHECKLIST_HELP_TEXT_PALCEHOLDER")} + /> +
+ }
{!isLoading && { const [config, setConfig] = useState(null); const [showPopUp, setShowPopUp] = useState(false); const [previewData, setPreviewData] = useState([]); + const [helpText, setHelpText] = useState(""); const [viewData, setViewData] = useState(null); @@ -43,6 +44,7 @@ const ViewChecklist = () => { select: (res) => { if (res?.ServiceDefinitions?.[0]?.attributes) { setServiceDefId(res?.ServiceDefinitions?.[0]?.id); + setHelpText(res?.ServiceDefinitions?.[0]?.additionalFields?.fields?.[0]?.value?.helpText); const temp_data = res?.ServiceDefinitions?.[0]?.attributes const formatted_data = temp_data.map((item) => item.additionalFields?.fields?.[0]?.value); const nvd = formatted_data.filter((value, index, self) => @@ -253,6 +255,21 @@ const ViewChecklist = () => { {index !== fieldPairs.length - 1 &&
} ))} + { +
+
{t("CHECKLIST_HELP_TEXT")}
+ setHelpText(event.target.value)} + placeholder={t("CHECKLIST_HELP_TEXT_PALCEHOLDER")} + /> +
+ }