Skip to content

Commit

Permalink
fixed generate api issue (#734)
Browse files Browse the repository at this point in the history
Co-authored-by: Jagankumar <[email protected]>
  • Loading branch information
Bhavya-egov and jagankumar-egov authored May 29, 2024
1 parent 4c49e28 commit e9cc6dd
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,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 @@ -437,7 +438,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 @@ -616,13 +617,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 @@ -658,6 +659,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 @@ -686,6 +723,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 @@ -751,7 +790,7 @@ const UploadData = ({ formData, onSelect, ...props }) => {
};
useEffect(() => {
if (showToast) {
const t = setTimeout(closeToast, 5000);
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 e9cc6dd

Please sign in to comment.