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

fixed generate api issue #734

Merged
merged 3 commits into from
May 29, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
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 @@ -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);
jagankumar-egov marked this conversation as resolved.
Show resolved Hide resolved

useEffect(() => {
jagankumar-egov marked this conversation as resolved.
Show resolved Hide resolved
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
Loading