diff --git a/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/UploadData.js b/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/UploadData.js index 30bfffef456..80f6fc3f088 100644 --- a/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/UploadData.js +++ b/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/UploadData.js @@ -887,42 +887,6 @@ const UploadData = ({ formData, onSelect, ...props }) => { fetchData(); }, [errorsType]); - const { data: facilityId, isLoading: isFacilityLoading, refetch: refetchFacility } = Digit.Hooks.campaign.useGenerateIdCampaign({ - type: "facilityWithBoundary", - hierarchyType: params?.hierarchyType, - campaignId: id, - // config: { - // enabled: setTimeout(fetchUpload || (fetchBoundary && currentKey > 6)), - // }, - config: { - enabled: enabled, - }, - }); - - const { data: boundaryId, isLoading: isBoundaryLoading, refetch: refetchBoundary } = Digit.Hooks.campaign.useGenerateIdCampaign({ - type: "boundary", - hierarchyType: params?.hierarchyType, - campaignId: id, - // config: { - // enabled: fetchUpload || (fetchBoundary && currentKey > 6), - // }, - config: { - enabled: enabled, - }, - }); - - const { data: userId, isLoading: isUserLoading, refetch: refetchUser } = Digit.Hooks.campaign.useGenerateIdCampaign({ - type: "userWithBoundary", - hierarchyType: params?.hierarchyType, - campaignId: id, - // config: { - // enabled: fetchUpload || (fetchBoundary && currentKey > 6), - // }, - config: { - enabled: enabled, - }, - }); - const Template = { url: "/project-factory/v1/data/_download", params: { @@ -935,35 +899,35 @@ const UploadData = ({ formData, onSelect, ...props }) => { const mutation = Digit.Hooks.useCustomAPIMutationHook(Template); const downloadTemplate = async () => { - if (type === "boundary" && params?.isBoundaryLoading) { - setDownloadError(true); - setShowToast({ key: "info", label: t("HCM_PLEASE_WAIT_TRY_IN_SOME_TIME") }); - return; - } - if (type === "facilityWithBoundary" && params?.isFacilityLoading) { - setDownloadError(true); - setShowToast({ key: "info", label: t("HCM_PLEASE_WAIT_TRY_IN_SOME_TIME") }); - return; - } - if (type === "userWithBoundary" && params?.isUserLoading) { - setDownloadError(true); - setShowToast({ key: "info", label: t("HCM_PLEASE_WAIT_TRY_IN_SOME_TIME") }); - return; - } - if (!params?.boundaryId || !params?.facilityId || !params?.userId) { - setEnabled(true); + // if (type === "boundary" && params?.isBoundaryLoading) { + // setDownloadError(true); + // setShowToast({ key: "info", label: t("HCM_PLEASE_WAIT_TRY_IN_SOME_TIME") }); + // return; + // } + // if (type === "facilityWithBoundary" && params?.isFacilityLoading) { + // setDownloadError(true); + // setShowToast({ key: "info", label: t("HCM_PLEASE_WAIT_TRY_IN_SOME_TIME") }); + // return; + // } + // if (type === "userWithBoundary" && params?.isUserLoading) { + // setDownloadError(true); + // setShowToast({ key: "info", label: t("HCM_PLEASE_WAIT_TRY_IN_SOME_TIME") }); + // return; + // } + // if (!params?.boundaryId || !params?.facilityId || !params?.userId) { + // setEnabled(true); - setDownloadError(true); - setShowToast({ key: "info", label: t("HCM_PLEASE_WAIT_TRY_IN_SOME_TIME") }); - return; - } + // setDownloadError(true); + // setShowToast({ key: "info", label: t("HCM_PLEASE_WAIT_TRY_IN_SOME_TIME") }); + // return; + // } await mutation.mutate( { params: { tenantId: tenantId, type: type, hierarchyType: params?.hierarchyType, - id: type === "boundary" ? params?.boundaryId : type === "facilityWithBoundary" ? params?.facilityId : params?.userId, + campaignId: id, }, }, { @@ -973,6 +937,11 @@ const UploadData = ({ formData, onSelect, ...props }) => { setShowToast({ key: "error", label: t("ERROR_WHILE_DOWNLOADING") }); return; } + if (result?.GeneratedResource?.[0]?.status === "inprogress") { + setDownloadError(true); + setShowToast({ key: "info", label: t("HCM_PLEASE_WAIT_TRY_IN_SOME_TIME") }); + return; + } if (!result?.GeneratedResource?.[0]?.fileStoreid || result?.GeneratedResource?.length == 0) { setDownloadError(true); setShowToast({ key: "info", label: t("HCM_PLEASE_WAIT_TRY_IN_SOME_TIME") }); diff --git a/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/configs/UICustomizations.js b/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/configs/UICustomizations.js index 63954b2a810..a883900ed9a 100644 --- a/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/configs/UICustomizations.js +++ b/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/configs/UICustomizations.js @@ -23,8 +23,8 @@ export const UICustomizations = { status: ["creating", "created"], createdBy: Digit.UserService.getUser().info.uuid, campaignsIncludeDates: true, - startDate: Date.now(), - endDate: Date.now(), + startDate: Digit.Utils.pt.convertDateToEpoch(new Date().toISOString().split("T")[0], "daystart"), + endDate: Digit.Utils.pt.convertDateToEpoch(new Date().toISOString().split("T")[0]), pagination: { sortBy: "createdTime", sortOrder: "desc", @@ -114,7 +114,7 @@ export const UICustomizations = { data.body.CampaignDetails = { tenantId: tenantId, status: ["creating", "created"], - endDate: Date.now() - 24 * 60 * 60 * 1000, + endDate: Digit.Utils.pt.convertDateToEpoch(new Date(Date.now() - 24 * 60 * 60 * 1000).toISOString().split("T")[0]), createdBy: Digit.UserService.getUser().info.uuid, pagination: { sortBy: "createdTime", @@ -207,7 +207,7 @@ export const UICustomizations = { status: ["creating", "created"], createdBy: Digit.UserService.getUser().info.uuid, campaignsIncludeDates: false, - startDate: Date.now() + 24 * 60 * 60 * 1000, + startDate: Digit.Utils.pt.convertDateToEpoch(new Date(Date.now() + 24 * 60 * 60 * 1000).toISOString().split("T")[0], "daystart"), pagination: { sortBy: "createdTime", sortOrder: "desc", diff --git a/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/SetupCampaign.js b/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/SetupCampaign.js index caf9295b5a7..37ee24e47bb 100644 --- a/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/SetupCampaign.js +++ b/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/SetupCampaign.js @@ -265,7 +265,7 @@ const SetupCampaign = ({ hierarchyType }) => { const [userEnabled, setUserEnabled] = useState(false); const [active, setActive] = useState(0); const { data: hierarchyConfig } = Digit.Hooks.useCustomMDMS(tenantId, "HCM-ADMIN-CONSOLE", [{ name: "hierarchyConfig" }]); - const [refetchGenerate, setRefetchGenerate] = useState(null); + // const [refetchGenerate, setRefetchGenerate] = useState(null); // const hierarchyType = hierarchyConfig?.["HCM-ADMIN-CONSOLE"]?.hierarchyConfig?.[0]?.hierarchy; // const lowestHierarchy = hierarchyConfig?.["HCM-ADMIN-CONSOLE"]?.hierarchyConfig?.[0]?.lowestHierarchy; @@ -403,53 +403,53 @@ const SetupCampaign = ({ hierarchyType }) => { setParams({ ...restructureFormData }); }, [params, draftData, isLoading, projectType]); - useEffect(() => { - setTimeout(() => { - setEnabled(fetchUpload || (fetchBoundary && currentKey > 3)); - setFacilityEnabled(refetchGenerate || (!dataParams?.boundaryId && (fetchUpload || (fetchBoundary && currentKey > 3)))); - setTargetEnabled(refetchGenerate || (!dataParams?.facilityId && (fetchUpload || (fetchBoundary && currentKey > 3)))); - setUserEnabled(refetchGenerate || (!dataParams?.userId && (fetchUpload || (fetchBoundary && currentKey > 3)))); - }, 3000); - if (refetchGenerate === true) { - setRefetchGenerate(false); - } - }, [fetchUpload, fetchBoundary, currentKey, dataParams, refetchGenerate]); - - const { data: facilityId, isLoading: isFacilityLoading, refetch: refetchFacility } = Digit.Hooks.campaign.useGenerateIdCampaign({ - type: "facilityWithBoundary", - hierarchyType: hierarchyType, - campaignId: id, - // config: { - // enabled: setTimeout(fetchUpload || (fetchBoundary && currentKey > 6)), - // }, - config: { - enabled: facilityEnabled, - }, - }); - - const { data: boundaryId, isLoading: isBoundaryLoading, refetch: refetchBoundary } = Digit.Hooks.campaign.useGenerateIdCampaign({ - type: "boundary", - hierarchyType: hierarchyType, - campaignId: id, - // config: { - // enabled: fetchUpload || (fetchBoundary && currentKey > 6), - // }, - config: { - enabled: targetEnabled, - }, - }); - - const { data: userId, isLoading: isUserLoading, refetch: refetchUser } = Digit.Hooks.campaign.useGenerateIdCampaign({ - type: "userWithBoundary", - hierarchyType: hierarchyType, - campaignId: id, - // config: { - // enabled: fetchUpload || (fetchBoundary && currentKey > 6), - // }, - config: { - enabled: userEnabled, - }, - }); + // useEffect(() => { + // setTimeout(() => { + // setEnabled(fetchUpload || (fetchBoundary && currentKey > 3)); + // setFacilityEnabled(refetchGenerate || (!dataParams?.boundaryId && (fetchUpload || (fetchBoundary && currentKey > 3)))); + // setTargetEnabled(refetchGenerate || (!dataParams?.facilityId && (fetchUpload || (fetchBoundary && currentKey > 3)))); + // setUserEnabled(refetchGenerate || (!dataParams?.userId && (fetchUpload || (fetchBoundary && currentKey > 3)))); + // }, 3000); + // if (refetchGenerate === true) { + // setRefetchGenerate(false); + // } + // }, [fetchUpload, fetchBoundary, currentKey, dataParams, refetchGenerate]); + + // const { data: facilityId, isLoading: isFacilityLoading, refetch: refetchFacility } = Digit.Hooks.campaign.useGenerateIdCampaign({ + // type: "facilityWithBoundary", + // hierarchyType: hierarchyType, + // campaignId: id, + // // config: { + // // enabled: setTimeout(fetchUpload || (fetchBoundary && currentKey > 6)), + // // }, + // config: { + // enabled: facilityEnabled, + // }, + // }); + + // const { data: boundaryId, isLoading: isBoundaryLoading, refetch: refetchBoundary } = Digit.Hooks.campaign.useGenerateIdCampaign({ + // type: "boundary", + // hierarchyType: hierarchyType, + // campaignId: id, + // // config: { + // // enabled: fetchUpload || (fetchBoundary && currentKey > 6), + // // }, + // config: { + // enabled: targetEnabled, + // }, + // }); + + // const { data: userId, isLoading: isUserLoading, refetch: refetchUser } = Digit.Hooks.campaign.useGenerateIdCampaign({ + // type: "userWithBoundary", + // hierarchyType: hierarchyType, + // campaignId: id, + // // config: { + // // enabled: fetchUpload || (fetchBoundary && currentKey > 6), + // // }, + // config: { + // enabled: userEnabled, + // }, + // }); useEffect(() => { if (draftData?.additionalDetails?.facilityId && draftData?.additionalDetails?.targetId && draftData?.additionalDetails?.userId) { @@ -462,24 +462,17 @@ const SetupCampaign = ({ hierarchyType }) => { hierarchy: hierarchyDefinition?.BoundaryHierarchy?.[0], }); } - }, [isBoundaryLoading, isFacilityLoading, isUserLoading, facilityId, boundaryId, userId, hierarchyDefinition?.BoundaryHierarchy?.[0], draftData]); // Only run if dataParams changes - + }, [hierarchyDefinition?.BoundaryHierarchy?.[0], draftData]); // Only run if dataParams changes useEffect(() => { - if (hierarchyDefinition?.BoundaryHierarchy?.[0]) { + if (hierarchyDefinition?.BoundaryHierarchy?.[0]) { setDataParams({ ...dataParams, - facilityId: facilityId, - boundaryId: boundaryId, - userId: userId, hierarchyType: hierarchyType, hierarchy: hierarchyDefinition?.BoundaryHierarchy?.[0], - isBoundaryLoading, - isFacilityLoading, - isUserLoading, }); } - }, [isBoundaryLoading, isFacilityLoading, isUserLoading, facilityId, boundaryId, userId, hierarchyDefinition?.BoundaryHierarchy?.[0], draftData]); + }, [hierarchyDefinition?.BoundaryHierarchy?.[0], draftData]); useEffect(() => { setCampaignConfig(CampaignConfig(totalFormData, dataParams, isSubmitting, summaryErrors)); }, [totalFormData, dataParams, isSubmitting, summaryErrors]); @@ -1096,7 +1089,7 @@ const SetupCampaign = ({ hierarchyType }) => { totalFormData?.HCM_CAMPAIGN_SELECTING_BOUNDARY_DATA?.boundaryType?.selectedData ); setFetchUpload(true); - setRefetchGenerate(checkEqual === false ? true : false); + // setRefetchGenerate(checkEqual === false ? true : false); return true; } else { setShowToast({ key: "error", label: `${t("HCM_SELECT_BOUNDARY")}` });