Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open microplan screen #1549

Merged
merged 8 commits into from
Oct 17, 2024
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
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 @@ -18,7 +18,7 @@
<link rel="stylesheet" href="https://unpkg.com/@egovernments/[email protected]/dist/index.css" />

<link rel="stylesheet" href="https://unpkg.com/@egovernments/[email protected]/dist/index.css" />
<link rel="stylesheet" href="https://unpkg.com/@egovernments/[email protected].82-campaign/dist/index.css" />
<link rel="stylesheet" href="https://unpkg.com/@egovernments/[email protected].83-campaign/dist/index.css" />
abishekTa-egov marked this conversation as resolved.
Show resolved Hide resolved


<link rel="stylesheet" href="https://unpkg.com/@egovernments/[email protected]/dist/index.css" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@egovernments/digit-ui-css",
"version": "1.0.82-campaign",
"version": "1.0.83-campaign",
"license": "MIT",
"main": "dist/index.css",
"author": "Jagankumar <[email protected]>",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
import React from 'react';
import { Card } from '@egovernments/digit-ui-components';
import { useMyContext } from '../utils/context';
import { useTranslation } from 'react-i18next';
const BoundaryKpi = ({ data }) => {
const {state:{boundaryHierarchy}} = useMyContext()
const { state: { boundaryHierarchy } } = useMyContext()
const { t } = useTranslation();
return (
<Card className="kpi-container">
{Object.keys(data).map((key) => (
<div key={key} className="kpi-card">
<h2>{String(data[key]).padStart(2, '0')}</h2>
<p>{key}</p>
</div>
))}
{Object.keys(data).map((key) => {
return (
<div key={key} className="kpi-card">
<h2>{String(data[key]).padStart(2, '0')}</h2>
<p>{t(`MICROPLAN_${key.toUpperCase()}`)}</p> {/* Correct use of t with template literal */}
</div>
);
})}
abishekTa-egov marked this conversation as resolved.
Show resolved Hide resolved
</Card>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,24 @@ import { EmployeeModuleCard, WorksMgmtIcon } from "@egovernments/digit-ui-react-
import React from "react";
import { useTranslation } from "react-i18next";


const ROLES = {
MICROPLAN: ["MICROPLAN_ADMIN"],
};

const OTHERS={
OTHERS:[
"PLAN_ESTIMATION_APPROVER",
"ROOT_PLAN_ESTIMATION_APPROVER",
"POPULATION_DATA_APPROVER",
"ROOT_POPULATION_DATA_APPROVER",
"FACILITY_CATCHMENT_MAPPER",
"ROOT_FACILITY_CATCHMENT_MAPPER",
"MICROPLAN_VIEWER"
]

}
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Improve constant naming and structure for consistency

The new OTHERS constant could be improved for better clarity and consistency:

  1. The name OTHERS is not descriptive. Consider a more specific name like ADDITIONAL_ROLES.
  2. The structure is inconsistent with the existing ROLES constant.

To address these issues and incorporate the suggestion from a previous review, consider merging this into the ROLES object:

const ROLES = {
  MICROPLAN: ["MICROPLAN_ADMIN"],
  ADDITIONAL: [
    "PLAN_ESTIMATION_APPROVER",
    "ROOT_PLAN_ESTIMATION_APPROVER",
    "POPULATION_DATA_APPROVER",
    "ROOT_POPULATION_DATA_APPROVER",
    "FACILITY_CATCHMENT_MAPPER",
    "ROOT_FACILITY_CATCHMENT_MAPPER",
    "MICROPLAN_VIEWER"
  ]
};

This approach centralizes role definitions and maintains consistency.


const MicroplanCard = () => {
const { t } = useTranslation();
const tenantId = Digit.ULBService.getCurrentTenantId();
Expand All @@ -18,7 +32,20 @@ const MicroplanCard = () => {
};
};

let links = [generateLink("SETUP_MICROPLAN","setup-microplan"),generateLink("SEARCH_MICROPLANS","microplan-search"),generateLink("USER_MANAGEMENT","user-management")];
const generateOtherLink = (labelKey, pathSuffix) => {
return {
label: t(labelKey),
link: `/${window?.contextPath}/employee/microplan/${pathSuffix}`,
roles: ROLES.OTHERS,
};
};
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

⚠️ Potential issue

Remove or modify the redundant generateOtherLink function

The generateOtherLink function is nearly identical to generateLink, introducing unnecessary code duplication. Additionally, it uses ROLES.OTHERS, which is incorrect. Consider the following options:

  1. If no differentiation is needed, remove generateOtherLink and use generateLink for all links.

  2. If different behavior is intended for "other" links, update the function accordingly:

const generateAdditionalLink = (labelKey, pathSuffix) => {
  return {
    label: t(labelKey),
    link: `/${window?.contextPath}/employee/microplan/${pathSuffix}`,
    roles: ROLES.ADDITIONAL, // Use the newly defined ADDITIONAL roles
  };
};

This approach aligns with the suggested changes to the ROLES constant and provides a clear distinction between different types of links.


let links = [
generateLink("SETUP_MICROPLAN","setup-microplan"),
generateLink("SEARCH_MICROPLANS","microplan-search"),
generateLink("USER_MANAGEMENT","user-management"),
generateOtherLink("MY_MICROPLANS","my-microplans")
];
Comment on lines +41 to +46
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Use consistent link generation in the links array

The "MY_MICROPLANS" link is added using generateOtherLink, which is inconsistent with other links. To maintain consistency and reduce potential issues, update this section to use a single link generation function:

let links = [
  generateLink("SETUP_MICROPLAN", "setup-microplan"),
  generateLink("SEARCH_MICROPLANS", "microplan-search"),
  generateLink("USER_MANAGEMENT", "user-management"),
  generateLink("MY_MICROPLANS", "my-microplans")
];

If different role requirements are needed for "MY_MICROPLANS", ensure that the link generation function (whether generateLink or a modified version) can handle different role sets appropriately.


links = links.filter((link) => (link?.roles && link?.roles?.length > 0 ? Digit.Utils.didEmployeeHasAtleastOneRole(link?.roles) : true));

Expand All @@ -31,4 +58,4 @@ const MicroplanCard = () => {
return <EmployeeModuleCard {...propsForModuleCard} />;
};

export default MicroplanCard;
export default MicroplanCard;
Original file line number Diff line number Diff line change
Expand Up @@ -2,126 +2,125 @@

// default values of search input component
const defaultSearchValues = {
microplanName: "",
microplanName: "",

};


};
//config for tab search sceeen
export const TabSearchconfig = {
// moduleName: "commonCampaignUiConfig",
showTab: true, // setting true will enable tab screen
TabSearchconfig: [ // all tab config should be added in json array
abishekTa-egov marked this conversation as resolved.
Show resolved Hide resolved
{
label: "MY_MICROPLANS",
type: "search",
apiDetails: {
serviceName: "/plan-service/config/_search", //! Note
requestParam: {},
requestBody: {},
masterName: "commonUiConfig",
moduleName: "MicroplanSearchConfig",
minParametersForSearchForm: 0,
tableFormJsonPath: "requestBody.PlanConfigurationSearchCriteria.pagination",
// filterFormJsonPath: "requestBody.MdmsCriteria.customs",
searchFormJsonPath: "requestBody.PlanConfigurationSearchCriteria",
},

sections: {
search: {
uiConfig: {
formClassName: "custom-both-clear-search",
primaryLabel: "ES_COMMON_SEARCH",
secondaryLabel: "ES_COMMON_CLEAR_SEARCH",
minReqFields: 0,
defaultValues: defaultSearchValues, // Set default values for search fields
fields: [
{
label: "Name of the microplan",
isMandatory: false,
key: "microplanName",
type: "text",
populators: {
name: "microplanName",
error: "Required",
validation: { pattern: /^[A-Za-z]+$/i },
},
abishekTa-egov marked this conversation as resolved.
Show resolved Hide resolved
},
// {
// label: "Phone number",
// isMandatory: false,
// key: "Phone number",
// type: "number",
// disable: false,
// populators: { name: "mobileNumber", error: "sample error message", validation: { min: 0, max: 999999999 } },
// },
// {
// label: "Individual Id ",
// isMandatory: false,
// type: "text",
// disable: false,
// populators: {
// name: "individualId",
// },
// },
],
abishekTa-egov marked this conversation as resolved.
Show resolved Hide resolved
},


//config for tab search sceeen
export const TabSearchconfig = {
// moduleName: "commonCampaignUiConfig",
showTab: true, // setting true will enable tab screen
TabSearchconfig: [ // all tab config should be added in json array
{
label: "ALL",
type: "search",
apiDetails: {
serviceName: "/plan-service/config/_search", //! Note
requestParam: {},
requestBody: {},
masterName: "commonUiConfig",
moduleName: "MicroplanSearchConfig",
minParametersForSearchForm: 0,
tableFormJsonPath: "requestBody.PlanConfigurationSearchCriteria.pagination",
// filterFormJsonPath: "requestBody.MdmsCriteria.customs",
searchFormJsonPath: "requestBody.PlanConfigurationSearchCriteria",
show: true,
},
searchResult: {
uiConfig: {
columns: [
{
label: "Name of the Microplan",
jsonPath: "name",
additionalCustomization:true
},

sections: {
search: {
uiConfig: {
formClassName: "custom-both-clear-search",
primaryLabel: "ES_COMMON_SEARCH",
secondaryLabel: "ES_COMMON_CLEAR_SEARCH",
minReqFields: 0,
defaultValues: defaultSearchValues, // Set default values for search fields
fields: [
{
label: "Name of the microplan",
isMandatory: false,
key: "microplanName",
type: "text",
populators: {
name: "microplanName",
error: "Required",
validation: { pattern: /^[A-Za-z]+$/i },
},
},
// {
// label: "Phone number",
// isMandatory: false,
// key: "Phone number",
// type: "number",
// disable: false,
// populators: { name: "mobileNumber", error: "sample error message", validation: { min: 0, max: 999999999 } },
// },
// {
// label: "Individual Id ",
// isMandatory: false,
// type: "text",
// disable: false,
// populators: {
// name: "individualId",
// },
// },
],
},

show: true,
},
searchResult: {
uiConfig: {
columns: [
{
label: "Name of the Microplan",
jsonPath: "name",
additionalCustomization:true
},

{
label: "Microplan Status",
jsonPath: "status",
},
{
label: "Campaign Disease",
jsonPath: "CampaignDetails.campaignName",
},
{
label:"Camapaign Type",
jsonPath:"CampaignDetails.startDate"
},
{
label:"Distribution Strategy",
jsonPath:" proposalDate"
},
{
label:"Actions",
jsonPath:"",
additionalCustomization:true
}
],
resultsJsonPath: "PlanConfiguration",

enableColumnSort: true,
// resultsJsonPath: "mdms",
},
show: true,
{
label: "Microplan Status",
jsonPath: "status",
},
{
label: "Campaign Disease",
jsonPath: "additionalDetails.disease",
},
{
label:"Camapaign Type",
abishekTa-egov marked this conversation as resolved.
Show resolved Hide resolved
jsonPath:"additionalDetails.campaignType"
},
{
label:"Distribution Strategy",
jsonPath:"additionalDetails.resourceDistributionStrategyCode"
},
{
label:"Actions",
jsonPath:"",
additionalCustomization:true
}
],
resultsJsonPath: "PlanConfiguration",

enableColumnSort: true,
// resultsJsonPath: "mdms",
},
// customHookName: "microplanv1.useSavedMicroplans", //! Note

show: true,
},
customHookName:"microplanv1.useSavedMicroplans"
// customHookName: "microplanv1.useSavedMicroplans", //! Note

},
customHookName:"microplanv1.useSavedMicroplans"
},


{label: "DRAFTED_SETUP"},
{label: "EXECUTION_TO_BE_DONE",},
{label:"EXECUTION_IN_PROGRESS"},
{label:"MICROPLAN_EXECUTED"},


],
};


{label: "DRAFTED_SETUP"},
{label: "EXECUTION_TO_BE_DONE",},
{label:"EXECUTION_IN_PROGRESS"},
{label:"MICROPLAN_EXECUTED"},


],
};




Loading