Skip to content
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
b0372ed
app config console commit
NabeelAyubee Sep 29, 2025
6ee037e
Merge branch 'console' into new-app-config-console
NabeelAyubee Sep 29, 2025
a0dcfb4
clean up 1.0
NabeelAyubee Sep 29, 2025
5b4ad14
clean up 2.0
NabeelAyubee Sep 30, 2025
8066433
clean up 3.0
NabeelAyubee Sep 30, 2025
287f097
clean up 4.0
NabeelAyubee Sep 30, 2025
1e9e145
clean up 6.0
NabeelAyubee Sep 30, 2025
89c3225
Merge branch 'console' into new-app-config-console
nabeelmd-eGov Sep 30, 2025
e5281f0
clearing consoles 7.0
NabeelAyubee Sep 30, 2025
e4ad1a9
clean up
NabeelAyubee Sep 30, 2025
ddce73b
clean up
NabeelAyubee Sep 30, 2025
034cb02
clean up
NabeelAyubee Sep 30, 2025
b7dbb5b
performance: Improve commit message readability
NabeelAyubee Sep 30, 2025
6812f30
integrate flows, roles, template
NabeelAyubee Oct 6, 2025
7530a16
added debounce
NabeelAyubee Oct 6, 2025
8096660
integrate fieldPanelPropertiesSlice
NabeelAyubee Oct 7, 2025
1dc2c85
added integration with mdms
NabeelAyubee Oct 9, 2025
01d410d
Layout Renderer fixes
Ramkrishna-egov Oct 10, 2025
24dff66
added template integration & ui ux fix
NabeelAyubee Oct 14, 2025
0e26590
integrated mdms config
NabeelAyubee Oct 17, 2025
6b725cf
Dependent Field Changes (#3269)
Ramkrishna-egov Oct 22, 2025
5748f60
mdms integrated flow and page
NabeelAyubee Oct 27, 2025
317d116
page fix for forms
NabeelAyubee Oct 27, 2025
1ea0976
update localisation
NabeelAyubee Oct 27, 2025
d701b5b
tranform integration
NabeelAyubee Oct 27, 2025
6b765e0
Fixed Layout renderer for Template
Ramkrishna-egov Oct 27, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import MobileBezelFrame from "./MobileBezelFrame";
import GenericTemplateScreen from "./GenericTemplateScreen";
import DynamicSVG from "./DynamicSVGComponent";
import RenderSelectionField from "./RenderSelectionField";
import ComponentToRender from "./ComponentToRender";
// import { useCustomT } from "../pages/employee/NewAppConfiguration/hooks/useCustomT";

const MdmsDropdown = ({
t,
Expand Down Expand Up @@ -137,7 +139,7 @@ const getFieldType = (field) => {
return "text";
case "number":
return "number";
case "textArea":
case "textarea":
return "textarea";
case "time":
return "time";
Expand Down Expand Up @@ -169,112 +171,114 @@ const getFieldType = (field) => {
return "button";
}
};
const AppPreview = ({ data = {}, selectedField, t }) => {
const AppPreview = ({ data = {}, selectedField, t, onFieldClick }) => {
console.log("datadata", data);
return (
<MobileBezelFrame>
{/* <div className="app-preview"> */}
<div className="mobile-bezel-child-container">
{data?.cards?.map((card, index) => (
<Card key={index} className="app-card" style={{}}>
{card.headerFields.map((headerField, headerIndex) => (
<div key={headerIndex}>
{headerField.jsonPath === "ScreenHeading" ? (
<CardHeader>{t(headerField.value)}</CardHeader>
) : (
<CardText className="app-preview-sub-heading">{t(headerField.value)}</CardText>
)}
</div>
))}
{data.type !== "template" &&
card?.fields
?.filter((field) => field.active && (field.hidden == false || field.deleteFlag == true)) //added logic to hide fields in display
?.map((field, fieldIndex) => {
if (getFieldType(field) === "checkbox") {
<Card className="app-card" style={{}}>
{data.headerFields?.map((headerField, headerIndex) => (
<div key={headerIndex}>
{headerField.jsonPath === "ScreenHeading" ? (
<CardHeader>{t(headerField.value)}</CardHeader>
) : (
<CardText className="app-preview-sub-heading">{t(headerField.value)}</CardText>
)}
</div>
))}
{data?.cards?.map((card, index) => (
<Card key={index} className="app-card" style={{}}>
{data.type !== "template" &&
card?.fields
?.filter((field) => field.active && !field.hidden) //added logic to hide fields in display
?.map((field, fieldIndex) => {
const isSelected =
selectedField &&
((selectedField.jsonPath && selectedField.jsonPath === field.jsonPath) || (selectedField.id && selectedField.id === field.id));

return (
<div
className={`app-preview-field-pair ${
selectedField?.jsonPath && selectedField?.jsonPath === field?.jsonPath
? `app-preview-selected`
: selectedField?.id && selectedField?.id === field?.id
? `app-preview-selected`
: ``
}`}
key={fieldIndex}
onClick={() => onFieldClick && onFieldClick(field, data, card)}
style={{
cursor: "pointer",
border: isSelected ? "2px solid #0B4B66" : "2px solid transparent",
borderRadius: "4px",
padding: "8px",
margin: "4px 0",
backgroundColor: isSelected ? "#f0f8ff" : "transparent",
}}
>
Comment on lines 28 to 39
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Fix a11y: clickable div must be keyboard‑accessible.

Add role, tabIndex, and key handler for Enter/Space. Also satisfies lint a11y errors.

-                      <div
+                      <div
                         key={fieldIndex}
-                        onClick={() => onFieldClick && onFieldClick(field, data, card)}
+                        role="button"
+                        tabIndex={0}
+                        aria-label={t(field?.label) || "Select field"}
+                        onClick={() => onFieldClick && onFieldClick(field, data, card)}
+                        onKeyDown={(e) => {
+                          if (e.key === "Enter" || e.key === " ") {
+                            e.preventDefault();
+                            onFieldClick && onFieldClick(field, data, card);
+                          }
+                        }}
                         style={{
                           cursor: "pointer",
                           border: isSelected ? "2px solid #0B4B66" : "2px solid transparent",
                           borderRadius: "4px",
                           padding: "8px",
                           margin: "4px 0",
                           backgroundColor: isSelected ? "#f0f8ff" : "transparent",
                         }}
                       >

I can run a quick pass to add roles/keys where needed elsewhere too.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
<div
className={`app-preview-field-pair ${
selectedField?.jsonPath && selectedField?.jsonPath === field?.jsonPath
? `app-preview-selected`
: selectedField?.id && selectedField?.id === field?.id
? `app-preview-selected`
: ``
}`}
key={fieldIndex}
onClick={() => onFieldClick && onFieldClick(field, data, card)}
style={{
cursor: "pointer",
border: isSelected ? "2px solid #0B4B66" : "2px solid transparent",
borderRadius: "4px",
padding: "8px",
margin: "4px 0",
backgroundColor: isSelected ? "#f0f8ff" : "transparent",
}}
>
<div
key={fieldIndex}
role="button"
tabIndex={0}
aria-label={t(field?.label) || "Select field"}
onClick={() => onFieldClick && onFieldClick(field, data, card)}
onKeyDown={(e) => {
if (e.key === "Enter" || e.key === " ") {
e.preventDefault();
onFieldClick && onFieldClick(field, data, card);
}
}}
style={{
cursor: "pointer",
border: isSelected ? "2px solid #0B4B66" : "2px solid transparent",
borderRadius: "4px",
padding: "8px",
margin: "4px 0",
backgroundColor: isSelected ? "#f0f8ff" : "transparent",
}}
>
🧰 Tools
🪛 Biome (2.1.2)

[error] 201-212: Static Elements should not be interactive.

To add interactivity such as a mouse or key event listener to a static element, give the element an appropriate role value.

(lint/a11y/noStaticElementInteractions)


[error] 201-212: Enforce to have the onClick mouse event with the onKeyUp, the onKeyDown, or the onKeyPress keyboard event.

Actions triggered using mouse events should have corresponding keyboard events to account for keyboard-only navigation.

(lint/a11y/useKeyWithClickEvents)

🤖 Prompt for AI Agents
In
health/micro-ui/web/packages/modules/campaign-manager/src/components/AppPreview.js
around lines 201-212, the clickable div is not keyboard-accessible; add
role="button", tabIndex={0}, and an onKeyDown handler that triggers the same
action as onClick when Enter or Space is pressed (handle Space with
preventDefault to avoid page scroll), keeping the existing onClick and styles;
ensure the onKeyDown calls onFieldClick(field, data, card) only if onFieldClick
is defined.

<CheckBox
mainClassName={"app-config-checkbox-main"}
labelClassName={`app-config-checkbox-label ${field?.["toArray.required"] ? "required" : ""}`}
onChange={(e) => {}}
value={""}
label={t(field?.label)}
isLabelFirst={false}
disabled={field?.readOnly || false}
/>
<ComponentToRender field={field} t={t} selectedField={selectedField} />
</div>
);
})}
{data.type !== "template" && (
<Button
className="app-preview-action-button"
variation="primary"
label={t(data?.actionLabel)}
title={t(data?.actionLabel)}
onClick={() => {}}
/>
)}
{data.type === "template" && (
<GenericTemplateScreen components={card.fields} selectedField={selectedField} t={t} templateName={data.name} />
)}
</Card>
))}
{/* Rendering Footer */}
{data?.footer?.length > 0 &&
data?.footer?.map((footer_item, footer_index) => {
return (
<FieldV1
config={{ step: "" }}
description={null}
error={null}
infoMessage={null}
label={
getFieldType(footer_item) === "checkbox" || getFieldType(footer_item) === "button" || getFieldType(footer_item) === "custom"
? null
: footer_item?.isMdms
? t(footer_item?.label)
: footer_item?.label
}
onChange={function noRefCheck() {}}
placeholder={t(footer_item?.innerLabel) || ""}
populators={{
t: footer_item?.isMdms ? null : t,
title: footer_item?.label,
fieldPairClassName: `app-preview-field-pair ${
selectedField?.jsonPath && selectedField?.jsonPath === footer_item?.jsonPath
? `app-preview-selected`
: selectedField?.id && selectedField?.id === footer_item?.id
? `app-preview-selected`
: ``
}`,
mdmsConfig: footer_item?.isMdms
? {
moduleName: footer_item?.schemaCode?.split(".")[0],
masterName: footer_item?.schemaCode?.split(".")[1],
}
: null,
options: footer_item?.isMdms ? null : footer_item?.dropDownOptions,
optionsKey: footer_item?.isMdms ? "code" : "name",
component:
getFieldType(footer_item) === "button" || getFieldType(footer_item) === "select" || getFieldType(footer_item) === "custom"
? renderField(footer_item, t)
: null,
}}
required={getFieldType(footer_item) === "custom" ? null : footer_item?.["toArray.required"]}
type={
getFieldType(footer_item) === "button" || getFieldType(footer_item) === "select" ? "custom" : getFieldType(footer_item) || "text"
}
return (
<FieldV1
charCount={field?.charCount}
config={{
step: "",
}}
description={field?.isMdms ? t(field?.helpText) : field?.helpText || null}
error={field?.isMdms ? t(field?.errorMessage) : field?.errorMessage || null}
infoMessage={field?.isMdms ? t(field?.tooltip) : field?.tooltip || null}
label={
getFieldType(field) === "checkbox" || getFieldType(field) === "button" || getFieldType(field) === "custom"
? null
: field?.isMdms
? t(field?.label)
: field?.label
}
onChange={function noRefCheck() {}}
placeholder={t(field?.innerLabel) || ""}
populators={{
t: field?.isMdms ? null : t,
prefix: field?.prefixText,
suffix: field?.suffixText,
title: field?.label,
fieldPairClassName: `app-preview-field-pair ${
selectedField?.jsonPath && selectedField?.jsonPath === field?.jsonPath
? `app-preview-selected`
: selectedField?.id && selectedField?.id === field?.id
? `app-preview-selected`
: ``
} ${field?.["toArray.required"] && getFieldType(field) !== "custom" ? `required` : ``}`,
mdmsConfig: field?.isMdms
? {
moduleName: field?.schemaCode?.split(".")[0],
masterName: field?.schemaCode?.split(".")[1],
}
: null,
options: field?.isMdms ? null : field?.dropDownOptions,
optionsKey: field?.isMdms ? "code" : "name",
component:
getFieldType(field) === "button" || getFieldType(field) === "select" || getFieldType(field) === "custom"
? renderField(field, t)
: null,
}}
type={getFieldType(field) === "button" || getFieldType(field) === "select" ? "custom" : getFieldType(field) || "text"}
value={field?.value === true ? "" : field?.value || ""}
disabled={field?.readOnly || false}
/>
);
})}
{data.type !== "template" && (
<Button
className="app-preview-action-button"
variation="primary"
label={t(data?.actionLabel)}
title={t(data?.actionLabel)}
onClick={() => {}}
/>
)}
{data.type === "template" && (
<GenericTemplateScreen components={card.fields} selectedField={selectedField} t={t} templateName={data.name} />
)}
</Card>
))}
value={footer_item?.value === true ? "" : footer_item?.value || ""}
disabled={footer_item?.readOnly || false}
/>
);
})}
Comment on lines 48 to 59
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Add keys to footer list items.

Each mapped element needs a stable key to avoid React warnings.

-          {data?.footer?.length > 0 &&
-            data?.footer?.map((footer_item, footer_index) => {
-              return (
-                <FieldV1
+          {data?.footer?.length > 0 &&
+            data?.footer?.map((footer_item, footer_index) => {
+              const footerKey = footer_item?.id ?? footer_item?.jsonPath ?? `${footer_item?.type}-${footer_index}`;
+              return (
+                <FieldV1
+                  key={footerKey}
                   config={{ step: "" }}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
{data?.footer?.length > 0 &&
data?.footer?.map((footer_item, footer_index) => {
return (
<FieldV1
config={{ step: "" }}
description={null}
error={null}
infoMessage={null}
label={
getFieldType(footer_item) === "checkbox" || getFieldType(footer_item) === "button" || getFieldType(footer_item) === "custom"
? null
: footer_item?.isMdms
? t(footer_item?.label)
: footer_item?.label
}
onChange={function noRefCheck() {}}
placeholder={t(footer_item?.innerLabel) || ""}
populators={{
t: footer_item?.isMdms ? null : t,
title: footer_item?.label,
fieldPairClassName: `app-preview-field-pair ${
selectedField?.jsonPath && selectedField?.jsonPath === footer_item?.jsonPath
? `app-preview-selected`
: selectedField?.id && selectedField?.id === footer_item?.id
? `app-preview-selected`
: ``
}`,
mdmsConfig: footer_item?.isMdms
? {
moduleName: footer_item?.schemaCode?.split(".")[0],
masterName: footer_item?.schemaCode?.split(".")[1],
}
: null,
options: footer_item?.isMdms ? null : footer_item?.dropDownOptions,
optionsKey: footer_item?.isMdms ? "code" : "name",
component:
getFieldType(footer_item) === "button" || getFieldType(footer_item) === "select" || getFieldType(footer_item) === "custom"
? renderField(footer_item, t)
: null,
}}
required={getFieldType(footer_item) === "custom" ? null : footer_item?.["toArray.required"]}
type={
getFieldType(footer_item) === "button" || getFieldType(footer_item) === "select" ? "custom" : getFieldType(footer_item) || "text"
}
return (
<FieldV1
charCount={field?.charCount}
config={{
step: "",
}}
description={field?.isMdms ? t(field?.helpText) : field?.helpText || null}
error={field?.isMdms ? t(field?.errorMessage) : field?.errorMessage || null}
infoMessage={field?.isMdms ? t(field?.tooltip) : field?.tooltip || null}
label={
getFieldType(field) === "checkbox" || getFieldType(field) === "button" || getFieldType(field) === "custom"
? null
: field?.isMdms
? t(field?.label)
: field?.label
}
onChange={function noRefCheck() {}}
placeholder={t(field?.innerLabel) || ""}
populators={{
t: field?.isMdms ? null : t,
prefix: field?.prefixText,
suffix: field?.suffixText,
title: field?.label,
fieldPairClassName: `app-preview-field-pair ${
selectedField?.jsonPath && selectedField?.jsonPath === field?.jsonPath
? `app-preview-selected`
: selectedField?.id && selectedField?.id === field?.id
? `app-preview-selected`
: ``
} ${field?.["toArray.required"] && getFieldType(field) !== "custom" ? `required` : ``}`,
mdmsConfig: field?.isMdms
? {
moduleName: field?.schemaCode?.split(".")[0],
masterName: field?.schemaCode?.split(".")[1],
}
: null,
options: field?.isMdms ? null : field?.dropDownOptions,
optionsKey: field?.isMdms ? "code" : "name",
component:
getFieldType(field) === "button" || getFieldType(field) === "select" || getFieldType(field) === "custom"
? renderField(field, t)
: null,
}}
type={getFieldType(field) === "button" || getFieldType(field) === "select" ? "custom" : getFieldType(field) || "text"}
value={field?.value === true ? "" : field?.value || ""}
disabled={field?.readOnly || false}
/>
);
})}
{data.type !== "template" && (
<Button
className="app-preview-action-button"
variation="primary"
label={t(data?.actionLabel)}
title={t(data?.actionLabel)}
onClick={() => {}}
/>
)}
{data.type === "template" && (
<GenericTemplateScreen components={card.fields} selectedField={selectedField} t={t} templateName={data.name} />
)}
</Card>
))}
value={footer_item?.value === true ? "" : footer_item?.value || ""}
disabled={footer_item?.readOnly || false}
/>
);
})}
{data?.footer?.length > 0 &&
data?.footer?.map((footer_item, footer_index) => {
const footerKey = footer_item?.id
?? footer_item?.jsonPath
?? `${footer_item?.type}-${footer_index}`;
return (
<FieldV1
key={footerKey}
config={{ step: "" }}
description={null}
error={null}
infoMessage={null}
label={
getFieldType(footer_item) === "checkbox" || getFieldType(footer_item) === "button" || getFieldType(footer_item) === "custom"
? null
: footer_item?.isMdms
? t(footer_item?.label)
: footer_item?.label
}
onChange={function noRefCheck() {}}
placeholder={t(footer_item?.innerLabel) || ""}
populators={{
t: footer_item?.isMdms ? null : t,
title: footer_item?.label,
fieldPairClassName: `app-preview-field-pair ${
selectedField?.jsonPath && selectedField?.jsonPath === footer_item?.jsonPath
? `app-preview-selected`
: selectedField?.id && selectedField?.id === footer_item?.id
? `app-preview-selected`
: ``
}`,
mdmsConfig: footer_item?.isMdms
? {
moduleName: footer_item?.schemaCode?.split(".")[0],
masterName: footer_item?.schemaCode?.split(".")[1],
}
: null,
options: footer_item?.isMdms ? null : footer_item?.dropDownOptions,
optionsKey: footer_item?.isMdms ? "code" : "name",
component:
getFieldType(footer_item) === "button" || getFieldType(footer_item) === "select" || getFieldType(footer_item) === "custom"
? renderField(footer_item, t)
: null,
}}
required={getFieldType(footer_item) === "custom" ? null : footer_item?.["toArray.required"]}
type={
getFieldType(footer_item) === "button" || getFieldType(footer_item) === "select" ? "custom" : getFieldType(footer_item) || "text"
}
value={footer_item?.value === true ? "" : footer_item?.value || ""}
disabled={footer_item?.readOnly || false}
/>
);
})}
🤖 Prompt for AI Agents
In
health/micro-ui/web/packages/modules/campaign-manager/src/components/AppPreview.js
around lines 232 to 280, the mapped footer items lack a React key causing
warnings; add a stable key prop to the top-level FieldV1 component such as
key={footer_item?.id || footer_item?.jsonPath || footer_index} (use id first,
fallback to jsonPath, then index) so each item has a unique, stable key.

</Card>
</div>
</MobileBezelFrame>
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useTranslation } from "react-i18next";

import React, { Fragment , useEffect } from "react";
import React, { Fragment, useEffect } from "react";
import { EmployeeModuleCard } from "@egovernments/digit-ui-react-components";

const ROLES = {
Expand All @@ -27,9 +27,9 @@ const CampaignCard = () => {
const { t } = useTranslation();
const microplanStatus = "RESOURCE_ESTIMATIONS_APPROVED";

useEffect(() => {
sessionStorage.removeItem("HCM_SELECTED_TAB_INDEX");
}, []);
useEffect(() => {
sessionStorage.removeItem("HCM_SELECTED_TAB_INDEX");
}, []);
Comment on lines +30 to +32
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

Move useEffect above the early return.

The useEffect hook is called after a conditional early return (line 24), violating React's Rules of Hooks. Hooks must be called unconditionally and in the same order on every render. When the employee lacks required roles, the component returns null before reaching the useEffect, breaking the hook calling order.

Apply this diff to fix the hook placement:

 const CampaignCard = () => {
+  useEffect(() => {
+    sessionStorage.removeItem("HCM_SELECTED_TAB_INDEX");
+  }, []);
+
   if (!Digit.Utils.didEmployeeHasAtleastOneRole(Object.values(ROLES).flatMap((e) => e))) {
     return null;
   }
 
   const { t } = useTranslation();
   const microplanStatus = "RESOURCE_ESTIMATIONS_APPROVED";
 
-  useEffect(() => {
-    sessionStorage.removeItem("HCM_SELECTED_TAB_INDEX");
-  }, []);
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
useEffect(() => {
sessionStorage.removeItem("HCM_SELECTED_TAB_INDEX");
}, []);
// health/micro-ui/web/packages/modules/campaign-manager/src/components/CampaignCard.js
const CampaignCard = () => {
// Move this hook above the early return so it always runs in the same order
useEffect(() => {
sessionStorage.removeItem("HCM_SELECTED_TAB_INDEX");
}, []);
if (!Digit.Utils.didEmployeeHasAtleastOneRole(Object.values(ROLES).flatMap((e) => e))) {
return null;
}
const { t } = useTranslation();
const microplanStatus = "RESOURCE_ESTIMATIONS_APPROVED";
// ...rest of the component...
};
🧰 Tools
🪛 Biome (2.1.2)

[error] 30-30: This hook is being called conditionally, but all hooks must be called in the exact same order in every component render.

Hooks should not be called after an early return.

For React to preserve state between calls, hooks needs to be called unconditionally and always in the same order.
See https://reactjs.org/docs/hooks-rules.html#only-call-hooks-at-the-top-level

(lint/correctness/useHookAtTopLevel)

🤖 Prompt for AI Agents
In
health/micro-ui/web/packages/modules/campaign-manager/src/components/CampaignCard.js
around lines 30 to 32, the useEffect that calls
sessionStorage.removeItem("HCM_SELECTED_TAB_INDEX") is placed after an early
return (line 24), violating React's Rules of Hooks; move the useEffect so it
sits above the conditional return so it executes (and hooks are called)
unconditionally on every render, keep the empty dependency array to run it once,
and ensure no other hooks are reordered when making this change.


let links = [
// {
Expand All @@ -55,6 +55,12 @@ const CampaignCard = () => {
roles: ROLES.CAMPAIGN_MANAGER,
// count: isLoading?"-":data
},
{
label: t("NEW APP CONFIGURATION"),
link: `/${window?.contextPath}/employee/campaign/new-app-configuration-redesign?variant=app&masterName=FormConfig&fieldType=FieldTypeMappingConfig&prefix=CMP-2025-09-29-009540&localeModule=APPONE&tenantId=mz&campaignNumber=CMP-2025-09-29-009540&formId=default&projectType=Schisto`,
roles: ROLES.CAMPAIGN_MANAGER,
// count: isLoading?"-":data
},
{
label: t("ACTION_TEST_SETUP_CAMPAIGN_FROM_MICROPLAN"),
link: `/${window?.contextPath}/employee/campaign/setup-from-microplan?status=${microplanStatus}`,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import { FieldV1 } from "@egovernments/digit-ui-components";
import React from "react";
import { useTranslation } from "react-i18next";
import { useSelector } from "react-redux";

// Simple helper function to get field type
const getFieldType = (field, fieldTypeMasterData) => {
if (!fieldTypeMasterData || !Array.isArray(fieldTypeMasterData)) {
return "textInput";
}

// Find matching field type based on type and format
const matched = fieldTypeMasterData.find((item) => item?.metadata?.type === field.type && item?.metadata?.format === field.format);

return matched?.fieldType || "textInput";
};

const ComponentToRender = ({ field, t: customT, selectedField }) => {
const { byName } = useSelector((state) => state.fieldTypeMaster);
const { t } = useTranslation();
console.log("responsePanelComponent", field, byName);
// Get field type mapping from the field master data
const fieldTypeMasterData = byName?.FieldTypeMappingConfig || [];

// Get the field type
const fieldType = getFieldType(field, fieldTypeMasterData);

console.log("fieldType", fieldType);

return (
<FieldV1
charCount={field?.charCount}
config={{
step: "",
}}
description={field?.isMdms ? t(field?.helpText) : field?.helpText || null}
error={field?.isMdms ? t(field?.errorMessage) : field?.errorMessage || null}
infoMessage={field?.isMdms ? t(field?.tooltip) : field?.tooltip || null}
label={field?.label}
onChange={function noRefCheck() {}}
placeholder={t(field?.innerLabel) || ""}
populators={{
t: field?.isMdms ? null : customT,
fieldPairClassName: `app-preview-field-pair ${
selectedField?.jsonPath && selectedField?.jsonPath === field?.jsonPath
? `app-preview-selected`
: selectedField?.id && selectedField?.id === field?.id
? `app-preview-selected`
: ``
}`,
}}
required={getFieldType(field) === "custom" ? null : field?.["toArray.required"]}
type={fieldType}
value={field?.value === true ? "" : field?.value || ""}
disabled={field?.readOnly || false}
/>
);
};

export default ComponentToRender;
Loading