This commit is contained in:
phanphan 2024-06-19 15:33:33 +07:00
parent 64c9804c98
commit 6279fdc30c
2 changed files with 31 additions and 16 deletions

View File

@ -144,14 +144,16 @@ const ReviewPage = () => {
if (isEmpty(tempData[k][REVIEWED_RESULT])) { if (isEmpty(tempData[k][REVIEWED_RESULT])) {
isEmptyResult = true; 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) => isEmptyResult = tempData[k][REVIEWED_RESULT].every((r: any) =>
isEmpty(r), isEmpty(r),
); );
} }
if (isEmptyResult) { if (isEmptyResult) {
tempData[k][REVIEWED_RESULT] = tempData[k][PREDICTED_RESULT]; tempData[k][REVIEWED_RESULT] = tempData[k][PREDICTED_RESULT];
} }
} }
}); });
@ -195,13 +197,17 @@ const ReviewPage = () => {
} }
setSelectedFileName(fileName); setSelectedFileName(fileName);
const response = await fetch(fileURL); try {
if (response.status === 200) { const response = await fetch(fileURL);
setSelectedFileData(fileURL); if (response.status === 200) {
} else { setSelectedFileData(fileURL);
} else {
setSelectedFileData('FAILED_TO_LOAD_FILE');
}
} catch (error) {
setSelectedFileData('FAILED_TO_LOAD_FILE'); setSelectedFileData('FAILED_TO_LOAD_FILE');
setImageLoading(false);
} }
setImageLoading(false);
}; };
const loadCurrentRequest = (requestIndex) => { const loadCurrentRequest = (requestIndex) => {
setLoading(true); setLoading(true);
@ -310,13 +316,12 @@ const ReviewPage = () => {
let request_file_result = {}; let request_file_result = {};
SOURCE_KEYS.forEach((k) => { SOURCE_KEYS.forEach((k) => {
request_file_result[k] = selectedFileDataSource[k][REVIEWED_RESULT]; request_file_result[k] = selectedFileDataSource[k][REVIEWED_RESULT];
if(Array.isArray(selectedFileDataSource[k][REVIEWED_RESULT])){ if (Array.isArray(selectedFileDataSource[k][REVIEWED_RESULT])) {
request_file_result[k] = selectedFileDataSource[k][REVIEWED_RESULT].toString(); request_file_result[k] =
}else{ selectedFileDataSource[k][REVIEWED_RESULT].toString();
} else {
request_file_result[k] = selectedFileDataSource[k][REVIEWED_RESULT]; request_file_result[k] = selectedFileDataSource[k][REVIEWED_RESULT];
} }
}); });
let data = { let data = {
request_file_result, request_file_result,
@ -358,7 +363,7 @@ const ReviewPage = () => {
const updateRevisedByFeedback = (fieldName) => { const updateRevisedByFeedback = (fieldName) => {
setSelectedFileDataSource((prevData) => { setSelectedFileDataSource((prevData) => {
prevData[fieldName][REVIEWED_RESULT] = prevData[fieldName][REVIEWED_RESULT] =
prevData[fieldName][FEEDBACK_RESULT]; prevData[fieldName][FEEDBACK_RESULT];
return { return {
...prevData, ...prevData,
}; };
@ -523,7 +528,17 @@ const ReviewPage = () => {
</div> </div>
)} )}
{selectedFileData === 'FAILED_TO_LOAD_FILE' ? ( {selectedFileData === 'FAILED_TO_LOAD_FILE' ? (
<p style={{ color: '#333' }}>Failed to load file.</p> <div
style={{
flexGrow: 1,
overflow: 'auto',
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
}}
>
<p style={{ color: '#333' }}>Failed to load file.</p>
</div>
) : fileExtension === 'pdf' ? ( ) : fileExtension === 'pdf' ? (
<div <div
style={{ style={{
@ -686,7 +701,7 @@ const ReviewPage = () => {
style={{ minWidth: '120px' }} style={{ minWidth: '120px' }}
onClick={handleConfirmReview} onClick={handleConfirmReview}
> >
Confirm request Confirm request
</Button> </Button>
</div> </div>
</div> </div>

View File

@ -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 AXIOS_TIMEOUT_MS = 30 * 60 * 1000; // This config sastified long-live upload file request
const EXPIRED_PASSWORD_SIGNAL = 'expired_password'; 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'; // export const baseURL = '/api';