diff --git a/cope2n-fe/src/pages/reviews2/index.tsx b/cope2n-fe/src/pages/reviews2/index.tsx index 9b19d8f..09756c7 100644 --- a/cope2n-fe/src/pages/reviews2/index.tsx +++ b/cope2n-fe/src/pages/reviews2/index.tsx @@ -144,14 +144,16 @@ const ReviewPage = () => { if (isEmpty(tempData[k][REVIEWED_RESULT])) { isEmptyResult = true; } - if (Array.isArray(tempData[k][REVIEWED_RESULT]) && tempData[k][REVIEWED_RESULT].length > 0) { + if ( + Array.isArray(tempData[k][REVIEWED_RESULT]) && + tempData[k][REVIEWED_RESULT].length > 0 + ) { isEmptyResult = tempData[k][REVIEWED_RESULT].every((r: any) => isEmpty(r), ); } if (isEmptyResult) { tempData[k][REVIEWED_RESULT] = tempData[k][PREDICTED_RESULT]; - } } }); @@ -195,13 +197,17 @@ const ReviewPage = () => { } setSelectedFileName(fileName); - const response = await fetch(fileURL); - if (response.status === 200) { - setSelectedFileData(fileURL); - } else { + try { + const response = await fetch(fileURL); + if (response.status === 200) { + setSelectedFileData(fileURL); + } else { + setSelectedFileData('FAILED_TO_LOAD_FILE'); + } + } catch (error) { setSelectedFileData('FAILED_TO_LOAD_FILE'); - setImageLoading(false); } + setImageLoading(false); }; const loadCurrentRequest = (requestIndex) => { setLoading(true); @@ -310,13 +316,12 @@ const ReviewPage = () => { let request_file_result = {}; SOURCE_KEYS.forEach((k) => { request_file_result[k] = selectedFileDataSource[k][REVIEWED_RESULT]; - if(Array.isArray(selectedFileDataSource[k][REVIEWED_RESULT])){ - request_file_result[k] = selectedFileDataSource[k][REVIEWED_RESULT].toString(); - }else{ + if (Array.isArray(selectedFileDataSource[k][REVIEWED_RESULT])) { + request_file_result[k] = + selectedFileDataSource[k][REVIEWED_RESULT].toString(); + } else { request_file_result[k] = selectedFileDataSource[k][REVIEWED_RESULT]; } - - }); let data = { request_file_result, @@ -358,7 +363,7 @@ const ReviewPage = () => { const updateRevisedByFeedback = (fieldName) => { setSelectedFileDataSource((prevData) => { prevData[fieldName][REVIEWED_RESULT] = - prevData[fieldName][FEEDBACK_RESULT]; + prevData[fieldName][FEEDBACK_RESULT]; return { ...prevData, }; @@ -523,7 +528,17 @@ const ReviewPage = () => { )} {selectedFileData === 'FAILED_TO_LOAD_FILE' ? ( -

Failed to load file.

+
+

Failed to load file.

+
) : fileExtension === 'pdf' ? (
{ style={{ minWidth: '120px' }} onClick={handleConfirmReview} > - Confirm request + Confirm request
diff --git a/cope2n-fe/src/request/api.ts b/cope2n-fe/src/request/api.ts index 36cf3c5..2eecbfb 100644 --- a/cope2n-fe/src/request/api.ts +++ b/cope2n-fe/src/request/api.ts @@ -11,7 +11,7 @@ const environment = process.env.NODE_ENV; const AXIOS_TIMEOUT_MS = 30 * 60 * 1000; // This config sastified long-live upload file request const EXPIRED_PASSWORD_SIGNAL = 'expired_password'; -export const baseURL = environment === 'development' ? 'http://107.120.133.27:9000/api' : '/api'; +export const baseURL = environment === 'development' ? 'http://107.120.133.27:9881/api' : '/api'; // export const baseURL = '/api';