Skip to content

Commit

Permalink
Merge pull request #1211 from bcgov/revert-1195-dev-rook-MD-3423
Browse files Browse the repository at this point in the history
Revert "3423 - Create errorToast for docReviewerService errors"
  • Loading branch information
milosdes authored Nov 8, 2024
2 parents bdc0416 + 9919941 commit acbc17d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 34 deletions.
37 changes: 7 additions & 30 deletions web/src/apiManager/services/docReviewerService.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { setRedactionInfo, setIsPageLeftOff, setSections,
import { store } from "../../services/StoreService";
import { number } from "yargs";
import { pageFlagTypes } from "../../constants/enum";
import { errorToast } from "../../helper/helper";


export const fetchDocuments = (
foiministryrequestid: number,
Expand Down Expand Up @@ -44,7 +44,6 @@ export const fetchDocuments = (
.catch((error:any) => {
console.log(error);
errorCallback("Error in fetching documents for a request");
errorToast('Error in fetching documents for a request.', { autoClose: false });
});
};

Expand All @@ -69,7 +68,6 @@ export const saveRotateDocumentPage = (
})
.catch((error:any) => {
errorCallback("Error in saving rotated page");
errorToast('Error in saving rotated page.', { autoClose: false });
});
};

Expand All @@ -95,7 +93,6 @@ export const fetchAnnotationsByPagination = (
})
.catch((error:any) => {
errorCallback("Error in fetching annotations for a document");
errorToast('Error in fetching annotations for a document.', { autoClose: false });
});
};

Expand All @@ -117,8 +114,7 @@ export const fetchDocumentAnnotations = (
}
})
.catch((error:any) => {
if (errorCallback) errorCallback("Error in fetching annotations for a document");
errorToast('Error in fetching annotations for a document.', { autoClose: false });
errorCallback("Error in fetching annotations for a document");
});
};
export const fetchAnnotationsInfo = (
Expand All @@ -139,7 +135,6 @@ export const fetchAnnotationsInfo = (
})
.catch((error:any) => {
errorCallback("Error in fetching annotations for a document");
errorToast('Error in fetching annotations for a document.', { autoClose: false });
});
};

Expand Down Expand Up @@ -188,7 +183,6 @@ export const saveAnnotation = (
})
.catch((error:any) => {
errorCallback("Error in saving an annotation");
errorToast('Error in saving an annotation.', { autoClose: false });
});
};

Expand All @@ -212,7 +206,6 @@ httpPOSTRequest({url: apiUrlPost, data: data, token: UserService.getToken() ?? '
})
.catch((error:any) => {
errorCallback("Error in deleting annotations");
errorToast('Error in deleting annotations.', { autoClose: false });
});
};

Expand All @@ -236,7 +229,6 @@ export const createOipcLayer= (
.catch((error:any) => {
if (errorCallback) {
errorCallback("Error while copying annotations to OIPC layer");
errorToast('Error while copying annotations to OIPC layer.', { autoClose: false });
} else {
throw new Error(`Error while copying annotations to OIPC layer`);
}
Expand All @@ -262,7 +254,6 @@ export const deleteRedaction = (
})
.catch((error:any) => {
errorCallback("Error in deleting redactions");
errorToast('Error in deleting redactions.', { autoClose: false });
});
};

Expand All @@ -283,8 +274,7 @@ export const fetchSections = (
}
})
.catch((error:any) => {
if (errorCallback) errorCallback("Error in fetching sections for a document");
errorToast('Error in fetching sections for a document.', { autoClose: false });
errorCallback("Error in fetching annotations for a document");
});
}

Expand All @@ -311,7 +301,6 @@ export const fetchPageFlagsMasterData = (
})
.catch((error:any) => {
errorCallback("Error in fetching pageflags master data");
errorToast('Error in fetching pageflags master data.', { autoClose: false });
});
};

Expand All @@ -337,7 +326,6 @@ export const savePageFlag = (
})
.catch((error:any) => {
errorCallback("Error in saving an page flag");
errorToast('Error in saving a page flag.', { autoClose: false });
});
};

Expand Down Expand Up @@ -365,12 +353,11 @@ export const fetchPageFlag = (
})
store.dispatch(setIsPageLeftOff(bookmarkedDoc?.length >0) as any);
} else {
throw new Error("Error while fetching page flags");
throw new Error("Error while triggering download redline");
}
})
.catch((error:any) => {
errorCallback("Error in fetching page flags:",error);
errorToast('Error in fetching page flags.', { autoClose: false });
errorCallback("Error in triggering download redline:",error);
});
};

Expand All @@ -389,7 +376,6 @@ export const fetchKeywordsMasterData = (
})
.catch((error:any) => {
errorCallback("Error in fetching keywords master data:",error);
errorToast('Error in fetching keywords master data.', { autoClose: false });
});
};

Expand All @@ -409,7 +395,6 @@ export const fetchRedactionLayerMasterData = (
})
.catch((error:any) => {
errorCallback("Error in fetching layers master data:",error);
errorToast('Error in fetching redaction layers master data.', { autoClose: false });
});
};

Expand All @@ -433,8 +418,7 @@ export const triggerDownloadRedlines = (
}
})
.catch((error:any) => {
if (errorCallback) errorCallback("Error in triggering download redline:",error);
errorToast('Error in triggering download redline.', { autoClose: false });
errorCallback("Error in triggering download redline:",error);
});
};

Expand All @@ -453,8 +437,7 @@ export const triggerDownloadFinalPackage = (
}
})
.catch((error:any) => {
if (errorCallback) errorCallback("Error in triggering download final package:",error);
errorToast('Error in triggering download final package.', { autoClose: false });
errorCallback("Error in triggering download final package:",error);
});
};

Expand All @@ -474,7 +457,6 @@ export const fetchPDFTronLicense = (
})
.catch((error:any) => {
errorCallback("Error in fetching PDFTronLicense:",error);
errorToast('Error in fetching PDFTronLicense.', { autoClose: false });
return "";
});
return response;
Expand All @@ -496,15 +478,13 @@ export const deleteDocumentPages = (
httpPOSTRequest({url: apiUrlPost, data: pagesDeleted, token: UserService.getToken() ?? '', isBearer: true})
.then((res:any) => {
if (res.data) {
throw new Error();
callback(res.data);
} else {
throw new Error(`Error while deleting document pages for (requestid# ${requestid})`);
}
})
.catch((error:any) => {
errorCallback("Error in deleting document pages");
errorToast('Error in deleting document pages.', { autoClose: false });
});
};

Expand All @@ -531,7 +511,6 @@ export const fetchDeletedDocumentPages = (
})
.catch((error:any) => {
errorCallback("Error in fetching deleted pages:",error);
errorToast('Error in fetching deleted pages.', { autoClose: false });
});
};

Expand All @@ -556,7 +535,6 @@ export const fetchPersonalAttributes = (
.catch((error:any) => {
console.log(error);
errorCallback("Error in fetching personal attributes");
errorToast('Error in fetching personal attributes.', { autoClose: false });
});
};

Expand All @@ -581,6 +559,5 @@ export const editPersonalAttributes = (
})
.catch((error:any) => {
errorCallback("Error in editing personal attributes");
errorToast('Error in editing personal attributes.', { autoClose: false });
});
};
7 changes: 3 additions & 4 deletions web/src/helper/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,17 +164,16 @@ const getFullnameTeamList = () => {
};


const errorToast = (errorMessage: any, options?: any) => {
const defaultOptions = {
const errorToast = (errorMessage: any) => {
return toast.error(errorMessage, {
position: "top-right",
autoClose: 3000,
hideProgressBar: true,
closeOnClick: true,
pauseOnHover: true,
draggable: true,
progress: undefined,
}
return toast.error(errorMessage, { ...defaultOptions, ...options });
});
};

export {
Expand Down

0 comments on commit acbc17d

Please sign in to comment.