Skip to content

Commit

Permalink
HLM-6270: Date logic changes, added localisation code (#953)
Browse files Browse the repository at this point in the history
Co-authored-by: nabeelmd-eGov <[email protected]>
  • Loading branch information
nabeelmd-eGov and nabeelmd-eGov authored Jun 25, 2024
1 parent 2110558 commit 8dbc883
Show file tree
Hide file tree
Showing 9 changed files with 39 additions and 37 deletions.
2 changes: 1 addition & 1 deletion micro-ui/web/micro-ui-internals/example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"devDependencies": {
"@egovernments/digit-ui-libraries": "1.8.2-beta.1",
"@egovernments/digit-ui-module-workbench": "1.0.2-beta.3",
"@egovernments/digit-ui-components": "0.0.2-beta.1",
"@egovernments/digit-ui-components": "0.0.2-beta.8",
"@egovernments/digit-ui-module-core": "1.8.2-beta.2",
"@egovernments/digit-ui-module-utilities": "1.0.1-beta.30",
"@egovernments/digit-ui-react-components": "1.8.2-beta.6",
Expand Down
2 changes: 1 addition & 1 deletion micro-ui/web/micro-ui-internals/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"lodash": "4.17.21",
"microbundle-crl": "0.13.11",
"@egovernments/digit-ui-react-components": "1.8.2-beta.6",
"@egovernments/digit-ui-components": "0.0.2-beta.1",
"@egovernments/digit-ui-components": "0.0.2-beta.8",
"react": "17.0.2",
"react-dom": "17.0.2",
"react-hook-form": "6.15.8",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
},
"dependencies": {
"@egovernments/digit-ui-react-components": "1.8.2-beta.6",
"@egovernments/digit-ui-components": "0.0.2-beta.1",
"@egovernments/digit-ui-components": "0.0.2-beta.8",
"@rjsf/core": "5.10.0",
"@rjsf/utils": "5.10.0",
"@rjsf/validator-ajv8": "5.10.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ const AddProductField = ({ onSelect }) => {
return (
<Card className="add-new-product-container">
<div className="heading-bar">
<CardText>Product {field?.key}</CardText>
<CardText>{t(`ES_ADD_PRODUCT_TITLE`)} {field?.key}</CardText>
{productFieldData?.length > 1 && (
<div
onClick={() => deleteProductField(field.key)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,18 +100,18 @@ const CycleDataPreview = ({ data, items, index, errors, onErrorClick, cardErrors
{rules?.attributes?.length > 0 && (
<DetailsTable
className="campaign-attribute-table"
cardHeader={{ value: `Condition ${ruleIndex + 1}` }}
cardHeader={{ value: `${t("CAMPAIGN_CONDITION")} ${ruleIndex + 1}` }}
columnsData={[
{
Header: t("Attribute"),
Header: t("CAMPAIGN_ATTRIBUTE_LABEL"),
accessor: "attribute",
},
{
Header: t("Operator"),
Header: t("CAMPAIGN_OPERATOR_LABEL"),
accessor: "operator",
},
{
Header: t("Value"),
Header: t("CAMPAIGN_VALUE_LABEL"),
accessor: "value",
},
]}
Expand All @@ -124,11 +124,11 @@ const CycleDataPreview = ({ data, items, index, errors, onErrorClick, cardErrors
// cardHeader={{ value: "Product Details" }}
columnsData={[
{
Header: t("Product"),
Header: t("CAMPAIGN_PRODUCT_LABEL"),
accessor: "name",
},
{
Header: t("Count"),
Header: t("CAMPAIGN_COUNT_LABEL"),
accessor: "count",
},
]}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1137,6 +1137,7 @@ const UploadData = ({ formData, onSelect, ...props }) => {
onClick={() => {
downloadTemplate(), setShowPopUp(false);
}}
title={t("HCM_CAMPAIGN_DOWNLOAD_TEMPLATE")}
/>,
]}
sortFooterChildren={true}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ function cycleDataRemap(data) {
return uniqueCycleObjects.map((i, n) => {
return {
key: i.cycleNumber,
fromDate: i?.startDate ? new Date(i?.startDate)?.toISOString()?.split("T")?.[0] : null,
toDate: i?.endDate ? new Date(i?.endDate)?.toISOString()?.split("T")?.[0] : null,
fromDate: i?.startDate ? Digit.DateUtils.ConvertEpochToDate(i?.startDate)?.split("/")?.reverse()?.jon("-") : null,
toDate: i?.endDate ? Digit.DateUtils.ConvertEpochToDate(i?.endDate)?.split("/")?.reverse()?.jon("-") : null,
};
});
}
Expand Down Expand Up @@ -351,8 +351,8 @@ const SetupCampaign = ({ hierarchyType }) => {
},
HCM_CAMPAIGN_DATE: {
campaignDates: {
startDate: draftData?.startDate ? new Date(draftData?.startDate)?.toISOString()?.split("T")?.[0] : "",
endDate: draftData?.endDate ? new Date(draftData?.endDate)?.toISOString()?.split("T")?.[0] : "",
startDate: draftData?.startDate ? Digit.DateUtils.ConvertEpochToDate(draftData?.startDate)?.split("/")?.reverse()?.join("-") : "",
endDate: draftData?.endDate ? Digit.DateUtils.ConvertEpochToDate(draftData?.endDate)?.split("/")?.reverse()?.join("-") : "",
},
},
HCM_CAMPAIGN_CYCLE_CONFIGURE: {
Expand All @@ -379,19 +379,22 @@ const SetupCampaign = ({ hierarchyType }) => {
},
},
HCM_CAMPAIGN_UPLOAD_BOUNDARY_DATA: {
uploadBoundary: { uploadedFile: draftData?.resources?.filter((i) => i?.type === "boundaryWithTarget"),
isSuccess : draftData?.resources?.filter((i) => i?.type === "boundaryWithTarget").length>0
uploadBoundary: {
uploadedFile: draftData?.resources?.filter((i) => i?.type === "boundaryWithTarget"),
isSuccess: draftData?.resources?.filter((i) => i?.type === "boundaryWithTarget").length > 0,
},
},
HCM_CAMPAIGN_UPLOAD_FACILITY_DATA: {
uploadFacility: { uploadedFile: draftData?.resources?.filter((i) => i?.type === "facility") ,
isSuccess : draftData?.resources?.filter((i) => i?.type === "facility").length>0
}
uploadFacility: {
uploadedFile: draftData?.resources?.filter((i) => i?.type === "facility"),
isSuccess: draftData?.resources?.filter((i) => i?.type === "facility").length > 0,
},
},
HCM_CAMPAIGN_UPLOAD_USER_DATA: {
uploadUser: { uploadedFile: draftData?.resources?.filter((i) => i?.type === "user") ,
isSuccess : draftData?.resources?.filter((i) => i?.type === "user").length>0
},
uploadUser: {
uploadedFile: draftData?.resources?.filter((i) => i?.type === "user"),
isSuccess: draftData?.resources?.filter((i) => i?.type === "user").length > 0,
},
},
};
setParams({ ...restructureFormData });
Expand Down Expand Up @@ -496,8 +499,8 @@ const SetupCampaign = ({ hierarchyType }) => {
cycle.deliveries.forEach((delivery, index) => {
delivery.deliveryRules.forEach((rule) => {
const restructuredRule = {
startDate: Digit.Utils.date.convertDateToEpoch(dateData?.find((i) => i.key == cycle.cycleIndex)?.fromDate), // Hardcoded for now
endDate: Digit.Utils.date.convertDateToEpoch(dateData?.find((i) => i?.key == cycle?.cycleIndex)?.toDate), // Hardcoded for now
startDate: Digit.Utils.pt.convertDateToEpoch(dateData?.find((i) => i.key == cycle.cycleIndex)?.fromDate, "daystart"), // Hardcoded for now
endDate: Digit.Utils.pt.convertDateToEpoch(dateData?.find((i) => i?.key == cycle?.cycleIndex)?.toDate), // Hardcoded for now
cycleNumber: parseInt(cycle.cycleIndex),
deliveryNumber: parseInt(delivery.deliveryIndex),
deliveryType: rule?.deliveryType,
Expand Down Expand Up @@ -585,10 +588,10 @@ const SetupCampaign = ({ hierarchyType }) => {
let payloadData = { ...draftData };
payloadData.hierarchyType = hierarchyType;
payloadData.startDate = totalFormData?.HCM_CAMPAIGN_DATE?.campaignDates?.startDate
? Digit.Utils.date.convertDateToEpoch(totalFormData?.HCM_CAMPAIGN_DATE?.campaignDates?.startDate)
? Digit.Utils.pt.convertDateToEpoch(totalFormData?.HCM_CAMPAIGN_DATE?.campaignDates?.startDate, "daystart")
: null;
payloadData.endDate = totalFormData?.HCM_CAMPAIGN_DATE?.campaignDates?.endDate
? Digit.Utils.date.convertDateToEpoch(totalFormData?.HCM_CAMPAIGN_DATE?.campaignDates?.endDate)
? Digit.Utils.pt.convertDateToEpoch(totalFormData?.HCM_CAMPAIGN_DATE?.campaignDates?.endDate)
: null;
payloadData.tenantId = tenantId;
payloadData.action = "create";
Expand Down Expand Up @@ -660,12 +663,12 @@ const SetupCampaign = ({ hierarchyType }) => {
payloadData.hierarchyType = hierarchyType;
if (totalFormData?.HCM_CAMPAIGN_DATE?.campaignDates?.startDate) {
payloadData.startDate = totalFormData?.HCM_CAMPAIGN_DATE?.campaignDates?.startDate
? Digit.Utils.date.convertDateToEpoch(totalFormData?.HCM_CAMPAIGN_DATE?.campaignDates?.startDate)
? Digit.Utils.pt.convertDateToEpoch(totalFormData?.HCM_CAMPAIGN_DATE?.campaignDates?.startDate, "daystart")
: null;
}
if (totalFormData?.HCM_CAMPAIGN_DATE?.campaignDates?.endDate) {
payloadData.endDate = totalFormData?.HCM_CAMPAIGN_DATE?.campaignDates?.endDate
? Digit.Utils.date.convertDateToEpoch(totalFormData?.HCM_CAMPAIGN_DATE?.campaignDates?.endDate)
? Digit.Utils.pt.convertDateToEpoch(totalFormData?.HCM_CAMPAIGN_DATE?.campaignDates?.endDate)
: null;
}
payloadData.tenantId = tenantId;
Expand Down Expand Up @@ -717,12 +720,12 @@ const SetupCampaign = ({ hierarchyType }) => {
payloadData.hierarchyType = hierarchyType;
if (totalFormData?.HCM_CAMPAIGN_DATE?.campaignDates?.startDate) {
payloadData.startDate = totalFormData?.HCM_CAMPAIGN_DATE?.campaignDates?.startDate
? Digit.Utils.date.convertDateToEpoch(totalFormData?.HCM_CAMPAIGN_DATE?.campaignDates?.startDate)
? Digit.Utils.pt.convertDateToEpoch(totalFormData?.HCM_CAMPAIGN_DATE?.campaignDates?.startDate, "daystart")
: null;
}
if (totalFormData?.HCM_CAMPAIGN_DATE?.campaignDates?.endDate) {
payloadData.endDate = totalFormData?.HCM_CAMPAIGN_DATE?.campaignDates?.endDate
? Digit.Utils.date.convertDateToEpoch(totalFormData?.HCM_CAMPAIGN_DATE?.campaignDates?.endDate)
? Digit.Utils.pt.convertDateToEpoch(totalFormData?.HCM_CAMPAIGN_DATE?.campaignDates?.endDate)
: null;
}
payloadData.tenantId = tenantId;
Expand Down Expand Up @@ -1089,7 +1092,6 @@ const SetupCampaign = ({ hierarchyType }) => {
formData?.boundaryType?.selectedData,
totalFormData?.HCM_CAMPAIGN_SELECTING_BOUNDARY_DATA?.boundaryType?.selectedData
);
console.log("HSHSHS", checkEqual);
setFetchUpload(true);
setRefetchGenerate(checkEqual === false ? true : false);
return true;
Expand Down Expand Up @@ -1365,12 +1367,11 @@ const SetupCampaign = ({ hierarchyType }) => {
const relatedSteps = campaignConfig?.[0]?.form.filter((step) => nonNullFormDataKeys.includes(step.name));

const highestStep = relatedSteps.reduce((max, step) => Math.max(max, parseInt(step.stepCount)), 0);
if(isDraft == "true"){
if (isDraft == "true") {
const filteredSteps = campaignConfig?.[0]?.form.find((item) => item.key === keyParam)?.stepCount;
setActive(filteredSteps);
}
else{
setActive(highestStep);
} else {
setActive(highestStep);
}

// setActive(highestStep);
Expand Down
2 changes: 1 addition & 1 deletion micro-ui/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"@egovernments/digit-ui-module-core": "1.8.2-beta.2",
"@egovernments/digit-ui-module-hrms": "1.8.0-beta.2",
"@egovernments/digit-ui-react-components": "1.8.2-beta.6",
"@egovernments/digit-ui-components": "0.0.2-beta.1",
"@egovernments/digit-ui-components": "0.0.2-beta.8",
"@egovernments/digit-ui-module-dss": "1.8.0-beta",
"@egovernments/digit-ui-module-common": "1.8.0-beta",
"@egovernments/digit-ui-module-utilities": "1.0.0-beta",
Expand Down
2 changes: 1 addition & 1 deletion micro-ui/web/workbench/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"dependencies": {
"@egovernments/digit-ui-libraries": "1.8.2-beta.1",
"@egovernments/digit-ui-module-workbench": "1.0.2-beta.3",
"@egovernments/digit-ui-components": "0.0.2-beta.1",
"@egovernments/digit-ui-components": "0.0.2-beta.8",
"@egovernments/digit-ui-module-core": "1.8.2-beta.2",
"@egovernments/digit-ui-module-utilities": "1.0.1-beta.30",
"@egovernments/digit-ui-react-components": "1.8.2-beta.6",
Expand Down

0 comments on commit 8dbc883

Please sign in to comment.