Skip to content

Commit

Permalink
fixed generate api issue
Browse files Browse the repository at this point in the history
  • Loading branch information
Bhavya-egov committed May 29, 2024
1 parent d420245 commit e3e4991
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ const UploadData = ({ formData, onSelect, ...props }) => {
const [sheetHeaders, setSheetHeaders] = useState({});
const [translatedSchema, setTranslatedSchema] = useState({});
const [readMeInfo, setReadMeInfo] = useState({});
const [enabled, setEnabled] = useState(false);

useEffect(() => {
if (type === "facilityWithBoundary") {
Expand Down Expand Up @@ -436,7 +437,7 @@ const UploadData = ({ formData, onSelect, ...props }) => {
return;
}
}
if (type === "boundary" && workbook?.SheetNames?.length > 3) {
if (type === "boundary" && workbook?.SheetNames?.length >= 3) {
if (!validateMultipleTargets(workbook)) {
return;
}
Expand Down Expand Up @@ -615,13 +616,13 @@ const UploadData = ({ formData, onSelect, ...props }) => {
}
} else {
setIsValidation(false);
setShowToast({ key: "error", label: t("HCM_VALIDATION_FAILED") });
setShowToast({ key: "error", label: t("HCM_VALIDATION_FAILED"), transitionTime: 5000000 });
const processedFileStore = temp?.processedFilestoreId;
if (!processedFileStore) {
setShowToast({ key: "error", label: t("HCM_VALIDATION_FAILED") });
setShowToast({ key: "error", label: t("HCM_VALIDATION_FAILED"), transitionTime: 5000000 });
return;
} else {
setShowToast({ key: "warning", label: t("HCM_CHECK_FILE_AGAIN") });
setShowToast({ key: "warning", label: t("HCM_CHECK_FILE_AGAIN"), transitionTime: 5000000 });
setIsError(true);
const { data: { fileStoreIds: fileUrl } = {} } = await Digit.UploadServices.Filefetch([processedFileStore], tenantId);
const fileData = fileUrl
Expand Down Expand Up @@ -657,6 +658,42 @@ 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: {
Expand Down Expand Up @@ -685,6 +722,8 @@ const UploadData = ({ formData, onSelect, ...props }) => {
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;
Expand Down Expand Up @@ -740,7 +779,6 @@ const UploadData = ({ formData, onSelect, ...props }) => {
);
};


// useEffect(() => {
// if (showToast) {
// setTimeout(closeToast, 5000);
Expand All @@ -751,8 +789,8 @@ const UploadData = ({ formData, onSelect, ...props }) => {
};
useEffect(() => {
if (showToast) {
const t = setTimeout(closeToast, 5000);
return () => clearTimeout(t);
const t = setTimeout(closeToast, 50000);
return () => clearTimeout(t);
}
}, [showToast]);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -386,8 +386,6 @@ const SetupCampaign = ({ hierarchyType }) => {
setTimeout(() => {
setEnabled(fetchUpload || (fetchBoundary && currentKey > 6));
}, 3000);

// return () => clearTimeout(timeoutId);
}, [fetchUpload, fetchBoundary, currentKey]);

const { data: facilityId, isLoading: isFacilityLoading, refetch: refetchFacility } = Digit.Hooks.campaign.useGenerateIdCampaign({
Expand All @@ -402,16 +400,9 @@ const SetupCampaign = ({ hierarchyType }) => {
},
});

// useEffect(() => {
// if (filteredBoundaryData) {
// refetchBoundary();
// }
// }, [filteredBoundaryData]);

const { data: boundaryId, isLoading: isBoundaryLoading, refetch: refetchBoundary } = Digit.Hooks.campaign.useGenerateIdCampaign({
type: "boundary",
hierarchyType: hierarchyType,
// filters: filteredBoundaryData,
campaignId: id,
// config: {
// enabled: fetchUpload || (fetchBoundary && currentKey > 6),
Expand Down

0 comments on commit e3e4991

Please sign in to comment.