Skip to content

Commit

Permalink
added my microplan screen
Browse files Browse the repository at this point in the history
  • Loading branch information
Bhavya-egov committed Nov 14, 2024
1 parent 34c2409 commit c075921
Show file tree
Hide file tree
Showing 8 changed files with 249 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,12 @@ const CampaignCard = () => {
roles: ROLES.CAMPAIGN_MANAGER,
// count: isLoading?"-":data
},
{
label: t("MICROPLAN_CAMPAIGN"),
link: `/${window?.contextPath}/employee/campaign/my-microplan`,
roles: ROLES.CAMPAIGN_MANAGER,
// count: isLoading?"-":data
},
];

links = links.filter((link) => (link?.roles && link?.roles?.length > 0 ? Digit.Utils.didEmployeeHasAtleastOneRole(link?.roles) : true));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const CampaignSelection = ({ onSelect, formData, formState, ...props }) => {
const searchParams = new URLSearchParams(location.search);
const [currentStep , setCurrentStep] = useState(1);
const currentKey = searchParams.get("key");
const productType = searchParams.get("type");
const [key, setKey] = useState(() => {
const keyParam = searchParams.get("key");
return keyParam ? parseInt(keyParam) : 1;
Expand Down Expand Up @@ -118,7 +119,7 @@ const CampaignSelection = ({ onSelect, formData, formState, ...props }) => {
<div
className="campaign-type-wrapper"
onClick={(e) => {
if (props?.props?.sessionData?.HCM_CAMPAIGN_TYPE?.projectType && !canUpdate) {
if (props?.props?.sessionData?.HCM_CAMPAIGN_TYPE?.projectType && !canUpdate && productType!=="microplan") {
setShowPopUp(true);
return;
}
Expand All @@ -143,6 +144,8 @@ const CampaignSelection = ({ onSelect, formData, formState, ...props }) => {
setStartValidation(true);
handleChange(value);
}}
disabled = {productType === "microplan"}

/>
{error?.message && <ErrorMessage message={t(error?.message)} showIcon={true} />}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -299,11 +299,66 @@ export const UICustomizations = {
}}
/>
</>
)
);
}

},
},
MicroplanCampaignSearchConfig: {
preProcess: (data, additionalDetails) => {
const { name, status } = data?.state?.searchForm || {};
data.body.PlanConfigurationSearchCriteria = {};
data.body.PlanConfigurationSearchCriteria.limit = data?.state?.tableForm?.limit;
// data.body.PlanConfigurationSearchCriteria.limit = 10
data.body.PlanConfigurationSearchCriteria.offset = data?.state?.tableForm?.offset;
data.body.PlanConfigurationSearchCriteria.name = name;
data.body.PlanConfigurationSearchCriteria.tenantId = Digit.ULBService.getCurrentTenantId();
data.body.PlanConfigurationSearchCriteria.userUuid = Digit.UserService.getUser().info.uuid;
// delete data.body.PlanConfigurationSearchCriteria.pagination
data.body.PlanConfigurationSearchCriteria.status = status?.status;
data.body.PlanConfigurationSearchCriteria.name = data?.state?.searchForm?.microplanName;
data.body.PlanConfigurationSearchCriteria.campaignType = data?.state?.searchForm?.campaignType?.[0]?.code;
return data;
},
additionalCustomizations: (row, key, column, value, t, searchResult) => {
switch (key) {
case "NAME_OF_MICROPLAN":
if (value && value !== "NA") {
return (
<div
style={{
maxWidth: "15rem", // Set the desired maximum width
wordWrap: "break-word", // Allows breaking within words
whiteSpace: "normal", // Ensures text wraps normally
overflowWrap: "break-word", // Break long words at the edge
}}
>
<p>{t(value)}</p>
</div>
);
} else {
return (
<div>
<p>{t("NA")}</p>
</div>
);
}

case "CAMPAIGN_TYPE":
if (value && value != "NA") {
return <p>{t(Digit.Utils.locale.getTransformedLocale("MICROPLAN_TYPE_" + value))}</p>;
} else {
return (
<div>
<p>{t("NA")}</p>
</div>
);
}
case "LAST_MODIFIED_TIME":
return Digit.DateUtils.ConvertEpochToDate(value);
default:
return null; // Handle any unexpected keys here if needed
}
},
},
MyCampaignConfigOngoing: {
preProcess: (data, additionalDetails) => {
Expand Down Expand Up @@ -886,7 +941,7 @@ export const UICustomizations = {
return value ? t("CM_UPDATE_REQUEST") : t("CM_CREATE_REQUEST");
case "CAMPAIGN_START_DATE":
return Digit.DateUtils.ConvertEpochToDate(value);
case "CAMPAIGN_END_DATE":
case "LAST_MODIFIED_TIME":
return Digit.DateUtils.ConvertEpochToDate(value);
default:
return "case_not_found";
Expand Down Expand Up @@ -993,7 +1048,8 @@ export const UICustomizations = {
</Link>
</span>
);

case "CM_DRAFT_TYPE":
return value ? t("CM_UPDATE_REQUEST") : t("CM_CREATE_REQUEST");
case "CAMPAIGN_START_DATE":
return Digit.DateUtils.ConvertEpochToDate(value);
case "CAMPAIGN_END_DATE":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -524,11 +524,16 @@ export const myCampaignConfig = {
additionalCustomization: true,
// disableSortBy: true,
},
// {
// label: "CAMPAIGN_END_DATE",
// jsonPath: "endDate",
// additionalCustomization: true,
// // disableSortBy: true,
// },
{
label: "CAMPAIGN_END_DATE",
jsonPath: "endDate",
additionalCustomization: true,
// disableSortBy: true,
label:"LAST_MODIFIED_TIME",
jsonPath:"auditDetails.lastModifiedTime",
additionalCustomization:true
},
],
enableGlobalSearch: false,
Expand Down Expand Up @@ -637,6 +642,11 @@ export const myCampaignConfig = {
jsonPath: "campaignName",
// additionalCustomization: true,
},
{
label: "CM_DRAFT_TYPE",
jsonPath: "parentId",
additionalCustomization: true,
},
{
label: "CAMPAIGN_TYPE",
jsonPath: "projectType",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@


const tenantId = Digit.ULBService.getCurrentTenantId();
const mdms_context_path = window?.globalConfigs?.getConfig("MDMS_V2_CONTEXT_PATH") || "mdms-v2";
export const MicroplanCampaignSearchConfig = [
{
label: "MICROPLAN_SEARCH",
type: "search",
apiDetails: {
serviceName: "/plan-service/config/_search",
requestParam: {
},
requestBody: {
"PlanConfigurationSearchCriteria": {
"limit": 10,
"offset": 0,
"tenantId": "mz",
"userUuid": "ff4ca65b-de7a-48de-ab9d-23c7728dc1aa"
},
},
masterName: "commonUiConfig",
moduleName: "MicroplanCampaignSearchConfig",
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:{
microplanName: "",
campaignType: "",
},
fields: [
{
label: "Name of the microplan",
isMandatory: false,
key: "microplanName",
type: "text",
populators: {
name: "microplanName"
},
},
{
label: "CAMPAIGN_SEARCH_TYPE",
type: "apidropdown",
isMandatory: false,
disable: false,
populators: {
optionsCustomStyle: {
top: "2.3rem",
},
name: "campaignType",
optionsKey: "code",
allowMultiSelect: false,
masterName: "commonUiConfig",
moduleName: "MyCampaignConfigDrafts",
customfn: "populateCampaignTypeReqCriteria",
},
},
],
},

show: true,
},
searchResult: {
uiConfig: {
columns: [
{
label: "NAME_OF_MICROPLAN",
jsonPath: "name",
additionalCustomization:true
},
{
label:"CAMPAIGN_TYPE",
jsonPath:"campaignDetails.projectType",
additionalCustomization:true
},
{
label:"LAST_MODIFIED_TIME",
jsonPath:"auditDetails.lastModifiedTime",
additionalCustomization:true
},
],
resultsJsonPath: "PlanConfiguration",

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

},
customHookName:"microplanv1.useSavedMicroplans"
},
];


Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import { Header, InboxSearchComposer } from "@egovernments/digit-ui-react-components";
import React, { useState, useEffect } from "react";
import { useTranslation } from "react-i18next";
import { useHistory } from "react-router-dom";
import { MicroplanCampaignSearchConfig } from "../../configs/myMicroplanConfig";



const defaultSearchValues = {

};

const MyMicroplans = () => {
const { t } = useTranslation();
const [defaultValues, setDefaultValues] = useState(defaultSearchValues); // State to hold default values for search fields
const history = useHistory();
useEffect(() => {
// Set default values when component mounts
setDefaultValues(defaultSearchValues);
}, []);

const onTabChange = (n) => {

setTabData((prev) => prev.map((i, c) => ({ ...i, active: c === n ? true : false }))); //setting tab enable which is being clicked
// setConfig(TabSearchconfig?.TabSearchconfig?.[n]);// as per tab number filtering the config
const url = new URL(window.location.href);
url.searchParams.set("tabId", `${n}`);
window.history.replaceState({}, "", url);

};
const onClickRow = ({ original: row }) => {
history.push(`/${window.contextPath}/employee/campaign/setup-campaign?id=${row.campaignId}&draft=true&fetchBoundary=true&draftBoundary=true&type=microplan`);
};
return (
<React.Fragment>

<Header styles={{ fontSize: "32px" }}>{t("MY_MICROPLANS_HEADING")}</Header>
<div className="inbox-search-wrapper">
{/* Pass defaultValues as props to InboxSearchComposer */}
<InboxSearchComposer
configs={MicroplanCampaignSearchConfig?.[0]}
additionalConfig={{
resultsTable: {
onClickRow,
},
}}
></InboxSearchComposer>
</div>
</React.Fragment>
);
};
export default MyMicroplans;
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ const SetupCampaign = ({ hierarchyType, hierarchyData }) => {
const isDateRestricted = searchParams.get("date");
const isChangeDates = searchParams.get("changeDates");
const actionBar = searchParams.get("actionBar");
const type = searchParams.get("type");
const [isDraftCreated, setIsDraftCreated] = useState(false);
const [currentKey, setCurrentKey] = useState(() => {
const keyParam = searchParams.get("key");
Expand Down Expand Up @@ -112,9 +113,12 @@ const SetupCampaign = ({ hierarchyType, hierarchyData }) => {
setIsDraftCreated(true);
if (isSkip === "false") {
if (currentKey === 1) setCurrentKey(1);
} else if (isDateRestricted === "true") {
setCurrentKey(3);
} else {
} else if (type === "microplan") {
setCurrentKey(2);
}else if (isDateRestricted === "true") {
setCurrentKey(3);
}
else {
if(draftData?.additionalDetails?.key === 7 || draftData?.additionalDetails?.key === 8){
setCurrentKey(6);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import ViewHierarchy from "./ViewHierarchy";
import ViewChecklist from "./ViewChecklist";
import UpdateChecklist from "./UpdateChecklist";
import BoundaryHome from "./BoundaryHome";
import MyMicroplans from "./MyMicroplans";
/**
* The CampaignBreadCrumb function generates breadcrumb navigation for a campaign setup page in a React
* application.
Expand Down Expand Up @@ -148,6 +149,7 @@ const App = ({ path, BOUNDARY_HIERARCHY_TYPE, hierarchyData }) => {
<PrivateRoute path={`${path}/boundary/view-all-hierarchy`} component={()=> <ViewBoundary />} />
<PrivateRoute path={`${path}/boundary/data`} component={()=> <ViewHierarchy />} />
<PrivateRoute path={`${path}/update-campaign`} component={() => <UpdateCampaign />} />
<PrivateRoute path={`${path}/my-microplan`} component={() => <MyMicroplans />} />
</AppContainer>
</Switch>
</React.Fragment>
Expand Down

0 comments on commit c075921

Please sign in to comment.