Skip to content

Commit

Permalink
Merge branch 'console' into facility_pop_up_fix
Browse files Browse the repository at this point in the history
  • Loading branch information
rachana-egov authored Nov 21, 2024
2 parents d3d9938 + 3c0f86f commit 124bdb1
Show file tree
Hide file tree
Showing 9 changed files with 86 additions and 45 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
},
"dependencies": {
"@cyntler/react-doc-viewer": "1.10.3",
"@egovernments/digit-ui-components":"0.0.2-beta.54",
"@egovernments/digit-ui-components": "0.0.2-beta.54",
"@egovernments/digit-ui-react-components": "1.8.10",
"@rjsf/core": "5.10.0",
"@rjsf/utils": "5.10.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -429,4 +429,4 @@ const TimelineComponent = ({ campaignId, resourceId }) => {
);
};

export default TimelineComponent;
export default TimelineComponent;
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ const BoundaryRelationCreate = () => {

const pollForTemplateGeneration = async () => {
const pollInterval = 2000; // Poll every 2 seconds
const maxRetries = 50; // Maximum number of retries
const maxRetries = 200; // Maximum number of retries
let retries = 0;

return new Promise((resolve, reject) => {
Expand Down Expand Up @@ -199,7 +199,7 @@ const BoundaryRelationCreate = () => {

const pollForStatusCompletion = async (id, typeOfData) => {
const pollInterval = 2000;
const maxRetries = 100;
const maxRetries = 200;
let retries = 0;
let pollTimer = null;
let timeoutTimer = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ import { Svgicon } from "../../utils/Svgicon";
import { useHistory } from "react-router-dom";
import { useLocation } from "react-router-dom";
import MapView from "../../components/MapView";
import * as XLSX from "xlsx";
import { CONSOLE_MDMS_MODULENAME } from "../../Module";

const ViewHierarchy = () => {
const { t } = useTranslation();
const location = useLocation();
Expand All @@ -31,6 +34,9 @@ const ViewHierarchy = () => {
const [disable, setDisable] = useState(false);
const [disableFile, setDisableFile] = useState(false);
const [dataCreationGoing, setDataCreationGoing] = useState(false);
const [noOfRows, setNoOfRows] = useState(100);

const { data: baseTimeOut } = Digit.Hooks.useCustomMDMS(tenantId, CONSOLE_MDMS_MODULENAME, [{ name: "baseTimeOut" }]);

const callSearch = async(hierarchy) =>{
const res = await Digit.CustomService.getResponse({
Expand Down Expand Up @@ -133,16 +139,33 @@ const ViewHierarchy = () => {
let fileDataTemp = {};
fileDataTemp.fileName = file?.name

const response = await Digit.UploadServices.Filestorage(module, file, tenantId);
fileDataTemp.fileStoreId = response?.data?.[0]?.fileStoreId;
let fileStoreIdTemp = response?.data?.files?.[0]?.fileStoreId;
setFileStoreId(response?.data?.files?.[0]?.fileStoreId);
const { data: { fileStoreIds: fileUrlTemp } = {} } = await Digit.UploadServices.Filefetch([fileStoreIdTemp], tenantId);
fileDataTemp.url = fileUrlTemp?.[0]?.url;
const reader = new FileReader();
reader.onload = async (event) => {
const data = new Uint8Array(event.target.result);
const workbook = XLSX.read(data, { type: "array" });

setFileUrl(fileDataTemp?.url);
setFileData(fileDataTemp);
};
// Assume the first sheet
const sheetName = workbook.SheetNames[0];
const sheet = workbook.Sheets[sheetName];

// Convert sheet to JSON and count rows
const rows = XLSX.utils.sheet_to_json(sheet);

// After parsing locally, upload to API
const response = await Digit.UploadServices.Filestorage(module, file, tenantId);
fileDataTemp.fileStoreId = response?.data?.[0]?.fileStoreId;
let fileStoreIdTemp = response?.data?.files?.[0]?.fileStoreId;
setFileStoreId(response?.data?.files?.[0]?.fileStoreId);
const { data: { fileStoreIds: fileUrlTemp } = {} } = await Digit.UploadServices.Filefetch([fileStoreIdTemp], tenantId);
fileDataTemp.url = fileUrlTemp?.[0]?.url;

setFileUrl(fileDataTemp?.url);
setFileData(fileDataTemp);
};

reader.readAsArrayBuffer(file); // Read the file as an array buffer

};

const callCreateDataApi = async () => {
setDisable(true);
Expand Down Expand Up @@ -274,9 +297,12 @@ const ViewHierarchy = () => {
// };

const pollForStatusCompletion = async (id, typeOfData) => {
const pollInterval = 2000; // Poll every 1 second
const maxRetries = 100; // Maximum number of retries
// const pollInterval = 2000; // Poll every 1 second
const maxRetries = 20; // Maximum number of retries
let retries = 0;
const baseDelay = baseTimeOut?.["HCM-ADMIN-CONSOLE"]?.baseTimeOut?.[0]?.baseTimeOut;
const maxTime = baseTimeOut?.["HCM-ADMIN-CONSOLE"]?.baseTimeOut?.[0]?.maxTime;
const pollInterval = Math.max(baseDelay * noOfRows , maxTime);

return new Promise((resolve, reject) => {
const poll = async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,7 @@ const FormulaConfigWrapper = ({ onSelect, props: customProps }) => {

<div className="card-container" style={{ width: "77vw", marginBottom: "2.5rem" }}>
<FormulaConfiguration
category={`FORMULA_${ruleConfigurationCategories[formulaInternalKey - 1]?.category}`}
category={ruleConfigurationCategories[formulaInternalKey - 1]?.category}
formulas={[...filteredFormulas?.filter((item) => !deletedFormulas?.includes(item.output)), ...customFormula]}
onSelect={onSelect}
customProps={customProps}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ const FormulaConfiguration = ({ onSelect, category, customProps, formulas: initi
return (
<>
<Card className="middle-child">
<Header className="uploader-sub-heading">{t(category)}</Header>
<Header className="uploader-sub-heading">{t(`FORMULA_HEADER_${category}`)}</Header>
{(category==="FORMULA_CAMPAIGN_VEHICLES")? <p className="mp-description">{t(`FORMULA_VEHICLE_DESCRIPTION`)}</p>:
<p className="mp-description">{t(`FORMULA_CONFIGURATION_DESCRIPTION`)}</p>
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,31 @@ const Hypothesis = ({ category, assumptions: initialAssumptions, setShowToast, a
variation={"primary"}
label={t("YES")}
onClick={() => {
//here if assumption name is not given then show a toast message and return
if(!selectedDeletedAssumption){
setShowToast({
key: "error",
label: t("PLS_SELECT_ASSUMPTION"),
transitionTime: 3000,
style:{
zIndex:1000000
}
});
return;
}

if(selectedDeletedAssumption?.code === "NEW_ASSUMPTION" && !selectedDeletedAssumption?.name){
setShowToast({
key: "error",
label: t("PLS_ENTER_ASSUMPTION_NAME"),
transitionTime: 3000,
style:{
zIndex:1000000
}
});
return;
}
//If no issues then go ahead and add assumption
addNewAssumption();
}}
/>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,7 @@ const HypothesisWrapper = ({ onSelect, props: customProps }) => {
setShowToast(false);
}}
isDleteBtn={true}
style={showToast.style ? showToast.style : {}}
/>
)}
</Fragment>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@ import FacilityCatchmentMapping from "./FacilityCatchmentMapping";
import PlanInbox from "./PlanInbox";
import MapViewComponent from "../../components/MapViewComponent";




// const bredCrumbStyle = { maxWidth: "min-content" };
const ProjectBreadCrumb = ({ location }) => {
const { t } = useTranslation();
Expand All @@ -38,8 +35,9 @@ const ProjectBreadCrumb = ({ location }) => {
{
internalLink: `/${window?.contextPath}/employee/microplan/user-management`,
content: t("USER_MANAGEMENT"),
show: Digit.Utils.locale.getTransformedLocale(location.pathname.split("/").pop()) === "UPLOAD_USER" || Digit.Utils.locale.getTransformedLocale(location.pathname.split("/").pop()) === "USER_DOWNLOAD"

show:
Digit.Utils.locale.getTransformedLocale(location.pathname.split("/").pop()) === "UPLOAD_USER" ||
Digit.Utils.locale.getTransformedLocale(location.pathname.split("/").pop()) === "USER_DOWNLOAD",
},
{
internalLink: `/${window?.contextPath}/employee`,
Expand Down Expand Up @@ -73,14 +71,13 @@ const App = ({ path, stateCode, userType, tenants, BOUNDARY_HIERARCHY_TYPE, hier
}
return () => {
if (window.location.pathname !== `/${window.contextPath}/employee/microplan/setup-microplan`) {
window.Digit.SessionStorage.del("MICROPLAN_DATA");
window.Digit.SessionStorage.del("HYPOTHESIS_DATA");
window.Digit.SessionStorage.del("FORMULA_DATA");
window.Digit.SessionStorage.del("MICROPLAN_DATA");
window.Digit.SessionStorage.del("HYPOTHESIS_DATA");
window.Digit.SessionStorage.del("FORMULA_DATA");
}
};
}, []);


const { isLoading: isLoadingMdmsMicroplanData, data: MicroplanMdmsData } = Digit.Hooks.useCustomMDMS(
Digit.ULBService.getCurrentTenantId(),
"hcm-microplanning",
Expand All @@ -102,7 +99,7 @@ const App = ({ path, stateCode, userType, tenants, BOUNDARY_HIERARCHY_TYPE, hier
{ name: "facilityType" },
{ name: "facilityStatus" },
{ name: "VehicleDetails" },
{ name: "ContextPathForUser" }
{ name: "ContextPathForUser" },
],
{
cacheTime: Infinity,
Expand All @@ -113,18 +110,15 @@ const App = ({ path, stateCode, userType, tenants, BOUNDARY_HIERARCHY_TYPE, hier
...data?.["hcm-microplanning"],
},
});
}
},
},
{ schemaCode: "BASE_MASTER_DATA" } //mdmsv2
);

const { isLoading: isLoadingMdmsAdditionalData, data: AdditionalMdmsData } = Digit.Hooks.useCustomMDMS(
Digit.ULBService.getCurrentTenantId(),
"HCM-ADMIN-CONSOLE",
[
{ name: "hierarchyConfig" },

],
[{ name: "hierarchyConfig" }],
{
cacheTime: Infinity,
select: (data) => {
Expand Down Expand Up @@ -159,9 +153,8 @@ const App = ({ path, stateCode, userType, tenants, BOUNDARY_HIERARCHY_TYPE, hier
// ],
// ...data?.["HCM-ADMIN-CONSOLE"],
// },

// });
}
},
},
{ schemaCode: "ADDITIONAL_MASTER_DATA" } //mdmsv2
);
Expand All @@ -186,7 +179,7 @@ const App = ({ path, stateCode, userType, tenants, BOUNDARY_HIERARCHY_TYPE, hier
state: {
boundaryHierarchy: data?.BoundaryHierarchy?.[0]?.boundaryHierarchy,
hierarchyType: BOUNDARY_HIERARCHY_TYPE,
lowestHierarchy
lowestHierarchy,
},
});
return data?.BoundaryHierarchy?.[0];
Expand All @@ -195,24 +188,24 @@ const App = ({ path, stateCode, userType, tenants, BOUNDARY_HIERARCHY_TYPE, hier
};
const { data: hierarchyDefinition, isLoading: isBoundaryHierarchyLoading } = Digit.Hooks.useCustomAPIHook(reqCriteria);



if (isLoadingMdmsMicroplanData || isLoadingMdmsAdditionalData || isBoundaryHierarchyLoading) {
return <Loader />
return <Loader />;
}

//TODO: Hardcode jurisdiction in state for now, need a microplan with complete setup done with all selected boundaries(in campaign), need superviser users with jurisdiction and tagging


return (
<Switch>
<AppContainer className="ground-container">
<React.Fragment>
<ProjectBreadCrumb location={location} />
</React.Fragment>
<PrivateRoute path={`${path}/setup-microplan`} component={() => <SetupMicroplan hierarchyType={BOUNDARY_HIERARCHY_TYPE} hierarchyData={hierarchyData} />} />
<PrivateRoute
path={`${path}/setup-microplan`}
component={() => <SetupMicroplan hierarchyType={BOUNDARY_HIERARCHY_TYPE} hierarchyData={hierarchyData} />}
/>
<PrivateRoute path={`${path}/microplan-search`} component={() => <MicroplanSearch></MicroplanSearch>} />
<PrivateRoute path={`${path}/user-management`} component={() => <UserManagement ></UserManagement>} />
<PrivateRoute path={`${path}/user-management`} component={() => <UserManagement></UserManagement>} />
<PrivateRoute path={`${path}/user-download`} component={() => <UserDownload />} />
<PrivateRoute path={`${path}/select-activity`} component={() => <ChooseActivity />} />
<PrivateRoute path={`${path}/campaign-boundary`} component={() => <CampaignBoundary />} />
Expand All @@ -230,10 +223,6 @@ const App = ({ path, stateCode, userType, tenants, BOUNDARY_HIERARCHY_TYPE, hier
<PrivateRoute path={`${path}/village-finalise-success`} component={() => <Response />} />
<PrivateRoute path={`${path}/microplan-success`} component={() => <Response />} />
<PrivateRoute path={`${path}/map-view`} component={() => <MapViewComponent />} />




</AppContainer>
</Switch>
);
Expand Down

0 comments on commit 124bdb1

Please sign in to comment.