Merge pull request #139 from SDSRV-IDP/factory/review

fix bug
This commit is contained in:
Đỗ Xuân Tân 2024-06-19 15:37:38 +07:00 committed by GitHub Enterprise
commit 0a721e660f
2 changed files with 31 additions and 16 deletions

View File

@ -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 = () => {
</div>
)}
{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' ? (
<div
style={{
@ -686,7 +701,7 @@ const ReviewPage = () => {
style={{ minWidth: '120px' }}
onClick={handleConfirmReview}
>
Confirm request
Confirm request
</Button>
</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 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';