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

added IRS changes in console #1305

Merged
merged 3 commits into from
Aug 22, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -133,6 +133,26 @@ const fetchResourceFile = async (tenantId, resourceIdArr) => {
});
return res?.ResourceDetails;
};
const fetchcd = async (tenantId, projectId) => {
const reqCriteriaResource = {
url: `/health-project/v1/_search?limit=1000&offset=0&tenantId=mz`,
Bhavya-egov marked this conversation as resolved.
Show resolved Hide resolved
body: {
Projects: [
{
tenantId: tenantId, // Ensure tenantId is defined and in scope
id: projectId
}
]
}
};
try{
const res = await Digit.CustomService.getResponse(reqCriteriaResource);
return res?.Project?.[0];
}
catch(e) {
console.log("error", e);
}
};

const CampaignSummary = (props) => {
const { t } = useTranslation();
Expand All @@ -149,6 +169,11 @@ const CampaignSummary = (props) => {
const [userErrors, setUserErrors] = useState(null);
const [cycleDatesError, setCycleDatesError] = useState(null);
const [summaryErrors, setSummaryErrors] = useState(null);
const [projectId, setprojectId] = useState(null);
const [startDate, setStartDate] = useState(null);
const [endDate, setEndDate] = useState(null);
const [cycles, setCycles] = useState([]);
const [cards, setCards] = useState([]);
const isPreview = searchParams.get("preview");
const handleRedirect = (step, activeCycle) => {
const urlParams = new URLSearchParams(window.location.search);
Expand Down Expand Up @@ -196,6 +221,21 @@ const CampaignSummary = (props) => {
// }
}, [props?.props?.summaryErrors]);

useEffect(() => {
const fun = async () => {
let temp = await fetchcd(tenantId, projectId);
if (temp) {
await new Promise((resolve) => {
setStartDate(temp?.startDate);
setEndDate(temp?.endDate);
setCycles(temp?.additionalDetails?.projectType?.cycles);
resolve();
});
}
};
fun();
}, [projectId]);

const { isLoading, data, error, refetch } = Digit.Hooks.campaign.useSearchCampaign({
tenantId: tenantId,
filter: {
Expand All @@ -209,7 +249,11 @@ const CampaignSummary = (props) => {
resourceIdArr.push(i?.createResourceId);
}
});
setStartDate(data?.[0]?.startDate);
setEndDate(data?.[0]?.endDate);
let processid;
setprojectId(data?.[0]?.projectId);
setCards(data?.cards);

const ss = async () => {
let temp = await fetchResourceFile(tenantId, resourceIdArr);
Expand Down Expand Up @@ -260,11 +304,13 @@ const CampaignSummary = (props) => {
},
{
key: "CAMPAIGN_START_DATE",
value: Digit.Utils.date.convertEpochToDate(data?.[0]?.startDate) || t("CAMPAIGN_SUMMARY_NA"),
// value: Digit.Utils.date.convertEpochToDate(data?.[0]?.startDate) || t("CAMPAIGN_SUMMARY_NA"),
value: Digit.Utils.date.convertEpochToDate(startDate) || t("CAMPAIGN_SUMMARY_NA")
},
{
key: "CAMPAIGN_END_DATE",
value: Digit.Utils.date.convertEpochToDate(data?.[0]?.endDate) || t("CAMPAIGN_SUMMARY_NA"),
// value: Digit.Utils.date.convertEpochToDate(data?.[0]?.endDate) || t("CAMPAIGN_SUMMARY_NA"),
value: Digit.Utils.date.convertEpochToDate(endDate) || t("CAMPAIGN_SUMMARY_NA")
},
],
},
Expand Down Expand Up @@ -470,6 +516,38 @@ const CampaignSummary = (props) => {
fetchUser();
}
}, [data]);

const updatedObject= { ...data };

useEffect(()=> {
// Update startDate and endDate in the `data` object
updatedObject.data.startDate = startDate;
updatedObject.data.endDate = endDate;
updatedObject.cards[1].sections[0].values[2].value=Digit.Utils.date.convertEpochToDate(startDate);
updatedObject.cards[1].sections[0].values[3].value=Digit.Utils.date.convertEpochToDate(endDate);
}, [startDate, endDate]);

if(updatedObject?.cards?.[1]?.sections?.[0]?.values?.[0].value=="Configuration for Multi Round Campaigns")
{
updatedObject.cards.forEach((card) => {
if (card.name && card.name.startsWith("CYCLE_")) {
const cycleId = card.name.split("_")[1];
const cycleData = cycles.find((cycle) => cycle.id === cycleId);

if (cycleData) {
card.sections.forEach((section) => {
if (section.props && section.props.data) {
section.props.data.startDate = new Date(cycleData.startDate).toLocaleDateString('en-GB');
// section.props.data.startDate = Digit.Utils.date.convertEpochToDate(cycleData.startDate) || t("CAMPAIGN_SUMMARY_NA");
section.props.data.endDate = new Date(cycleData.endDate).toLocaleDateString('en-GB');
// section.props.data.startDate = Digit.Utils.date.convertEpochToDate(cycleData.endDate) || t("CAMPAIGN_SUMMARY_NA");
}
});
}
}
});
}

return (
<>
<div style={{ display: "flex", justifyContent: "space-between" }}>
Expand All @@ -486,7 +564,7 @@ const CampaignSummary = (props) => {
)} */}
</div>
<div className="campaign-summary-container">
<ViewComposer data={data} cardErrors={summaryErrors} />
<ViewComposer data={updatedObject} cardErrors={summaryErrors} />
{showToast && (
<Toast
type={showToast?.key === "error" ? "error" : showToast?.key === "info" ? "info" : "success"}
Expand All @@ -497,6 +575,6 @@ const CampaignSummary = (props) => {
</div>
</>
);
};
}

export default CampaignSummary;
export default CampaignSummary;
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ const TimelineComponent = ({campaignId, resourceId}) => {
return (
<React.Fragment>
<div className="timeline-user">
{inProgressTimelines?.length > 0 || upcomingTimelines?.length > 0 ? (
{upcomingTimelines?.length > 0 || inProgressTimelines?.length > 0 ? (
<TimelineMolecule>
{/* <Timeline label={t("HCM_UPCOMING")} variant="upcoming" subElements={subElements2} className={"upcoming-timeline"} showConnector={true} /> */}

Expand All @@ -271,7 +271,7 @@ const TimelineComponent = ({campaignId, resourceId}) => {
/>
))}

{inProgressTimelines?.map((timeline, index) => (
{inProgressTimelines?.map((timeline, index) => (
<Timeline key={index} label={timeline?.label} subElements={timeline?.subElements} variant="inprogress" showConnector={true} />
))}

Expand All @@ -280,16 +280,14 @@ const TimelineComponent = ({campaignId, resourceId}) => {
))}
</TimelineMolecule>
) : (
<TimelineMolecule initialVisibleCount={1} hideFutureLabel={true}>
<TimelineMolecule
initialVisibleCount={1}
hideFutureLabel={true}
viewLessLabelForPast={t("HCM_SHOW_LESS")}
viewMoreLabelForPast={t("HCM_SHOW_MORE")}
>
{completedTimelines?.map((timeline, index) => (
<Timeline
key={index}
label={timeline?.label}
subElements={timeline?.subElements}
variant="completed"
viewLessLabelForPast={t("HCM_SHOW_LESS")}
viewMoreLabelForPast={t("HCM_SHOW_MORE")}
showConnector={true} />
<Timeline key={index} label={timeline?.label} subElements={timeline?.subElements} variant="completed" showConnector={true} />
))}
</TimelineMolecule>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,10 +179,7 @@ export const UICustomizations = {
onOverlayClick={() => setTimeline(false)}
onClose={() => setTimeline(false)}
>
<TimelineComponent
campaignId={row?.id}
resourceId={resourceIdArr}
/>
<TimelineComponent campaignId={row?.id} resourceId={resourceIdArr} />
</PopUp>
)}
</>
Expand Down Expand Up @@ -418,6 +415,7 @@ export const UICustomizations = {
name: row?.campaignName,
data: row,
projectId: row?.projectId,
campaignId: row?.id,
},
"",
`/${window.contextPath}/employee/campaign/update-dates-boundary?id=${row?.id}`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,24 @@ export const deliveryConfig = [
label: "Custom",
attrType: "text",
attrValue: "CAMPAIGN_BEDNET_INDIVIDUAL_LABEL",
operatorValue: "LESS_THAN_EQUAL_TO",
value: 3,
},
{
key: 2,
label: "Custom",
attrType: "text",
attrValue: "CAMPAIGN_BEDNET_HOUSEHOLD_LABEL",
operatorValue: "LESS_THAN_EQUAL_TO",
value: 1.8,
},
],
productConfig: [
{
key: 1,
count: 1,
value: "PVAR-2024-05-03-000305",
name: "SP - 250mg",
value: "PVAR-2024-03-15-000043",
name: "SP 500mg",
},
],
},
Expand All @@ -51,7 +55,6 @@ export const deliveryConfig = [
conditionConfig: [
{
deliveryType: "DIRECT",
disableDeliveryType: true,
attributeConfig: [
{
key: 1,
Expand All @@ -67,19 +70,18 @@ export const deliveryConfig = [
{
key: 1,
count: 1,
value: "PVAR-2024-01-24-000079",
name: "AQ - 75mg",
value: "PVAR-2024-03-15-000043",
name: "SP 500mg",
},
{
key: 1,
key: 2,
count: 1,
value: "PVAR-2024-05-03-000305",
name: "SP - 250mg",
value: "PVAR-2024-03-15-000044",
name: "AQ 75mg",
},
],
},
{
disableDeliveryType: true,
deliveryType: "DIRECT",
attributeConfig: [
{
Expand All @@ -96,8 +98,8 @@ export const deliveryConfig = [
{
key: 1,
count: 1,
value: "PVAR-2024-01-24-000078",
name: "AQ - 150mg",
value: "PVAR-2024-03-15-000043",
name: "SP 500mg",
},
],
},
Expand All @@ -123,8 +125,8 @@ export const deliveryConfig = [
{
key: 1,
count: 1,
value: "PVAR-2024-01-24-000079",
name: "AQ - 75mg",
value: "PVAR-2024-03-15-000043",
name: "SP 500mg",
},
],
},
Expand All @@ -145,8 +147,8 @@ export const deliveryConfig = [
{
key: 1,
count: 1,
value: "PVAR-2024-01-24-000078",
name: "AQ - 150mg",
value: "PVAR-2024-03-15-000043",
name: "SP 500mg",
},
],
},
Expand All @@ -172,8 +174,8 @@ export const deliveryConfig = [
{
key: 1,
count: 1,
value: "PVAR-2024-01-24-000079",
name: "AQ - 75mg",
value: "PVAR-2024-03-15-000043",
name: "SP 500mg",
},
],
},
Expand All @@ -194,13 +196,47 @@ export const deliveryConfig = [
{
key: 1,
count: 1,
value: "PVAR-2024-01-24-000078",
name: "AQ - 150mg",
value: "PVAR-2024-03-15-000043",
name: "SP 500mg",
},
],
},
],
},
],
},
{
projectType: "IRS-mz",
attrAddDisable: true,
deliveryAddDisable: false,
customAttribute: true,
productCountHide: true,
cycleConfig: {
cycle: 1,
deliveries: 1,
IsDisable: true
},
deliveryConfig: [
{
attributeConfig: [
{
key: 1,
label: "Custom",
attrType: "text",
attrValue: "TYPE_OF_STRUCTURE",
operatorValue: "EQUAL_TO",
value: "CEMENT",
},
],
productConfig: [
{
key: 1,
count: 1,
value: "PVAR-2024-03-15-000043",
name: "SP 500mg",
},
],
},
],
},
];
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const useProductList = (tenantId) => {
export const useProductList = (tenantId,projectType) => {
const reqCriteriaVariant = {
url: `/product/variant/v1/_search`,
params: { tenantId: tenantId, limit: 1000, offset: 0 },
Expand All @@ -8,7 +8,11 @@ export const useProductList = (tenantId) => {
config: {
enabled: true,
select: (data) => {
return data?.ProductVariant;

const filteredData = data?.ProductVariant?.filter(item =>
item.additionalFields?.fields?.some(field => field.key === "projectType" && field.value === projectType)
);
return filteredData;
},
},
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const useProjectUpdateWithBoundary = async ({ formData }) => {
const requests = formData.map((item) => {
return Digit.CustomService.getResponse({
url: "/health-project/v1/_update", // todo should be picked up from globalconfig
url: "/health-project/v1/_update",
body: {
Projects: [item],
isCascadingProjectDateUpdate: true,
Expand Down
Loading