diff --git a/cope2n-fe/src/pages/reviews/consts.ts b/cope2n-fe/src/pages/reviews/consts.ts new file mode 100644 index 0000000..6f5ddcf --- /dev/null +++ b/cope2n-fe/src/pages/reviews/consts.ts @@ -0,0 +1,10 @@ +export const counter_measure_map = { + invalid_image: 'Remove this image from the evaluation report', + missing_information: 'Remove this image from the evaluation report', + too_blurry_text: 'Remove this image from the evaluation report', + too_small_text: 'Remove this image from the evaluation report', + ocr_cannot_extract: 'Improve OCR', + wrong_feedback: 'Update revised result and re-calculate accuracy', + handwritten: 'Remove this image from the evaluation report', + other: 'other', +}; diff --git a/cope2n-fe/src/pages/reviews/index.tsx b/cope2n-fe/src/pages/reviews/index.tsx index f3fc856..59f42f9 100644 --- a/cope2n-fe/src/pages/reviews/index.tsx +++ b/cope2n-fe/src/pages/reviews/index.tsx @@ -36,6 +36,7 @@ import '@react-pdf-viewer/core/lib/styles/index.css'; import { badQualityReasonSubmit } from 'request'; import { normalizeData } from 'utils/field-value-process'; +import { counter_measure_map } from './consts'; const { Sider, Content } = Layout; const siderStyle: React.CSSProperties = { @@ -301,6 +302,15 @@ const ReviewPage = () => { const [pageIndexToGoto, setPageIndexToGoto] = useState(1); const [reason, setReason] = useState(''); + const [otherReason, setOtherReason] = useState(''); + const [solution, setSolution] = useState(''); + const [otherSolution, setOtherSolution] = useState(''); + + useEffect(() => { + if (reason) { + setSolution(counter_measure_map[reason]); + } + }, [reason]); const setAndLoadSelectedFile = async (requestData, index) => { setSelectedFileId(index); @@ -1117,14 +1127,43 @@ const ReviewPage = () => { width={700} onOk={async () => { // call submit api - if (!reason) { - notification.warning({ message: 'Please select a reason' }); + if (!reason || !solution) { + notification.warning({ + message: 'Please select a reason or a solution', + }); } else { const params = { request_id: currentRequest?.RequestID, request_image_id: selectedFileName.replace(/\.[^/.]+$/, ''), }; - const res = await badQualityReasonSubmit(params, reason); + + let submitReason = reason; + let submitSolution = solution; + + if (reason === 'other') { + if (!otherReason) { + notification.warning({ + message: 'Please input other reason', + }); + return; + } + submitReason = otherReason; + } + if (solution === 'other') { + if (!otherSolution) { + notification.warning({ + message: 'Please input other solution', + }); + return; + } + submitSolution = otherSolution; + } + + const res = await badQualityReasonSubmit( + params, + submitReason, + submitSolution, + ); if (res.message) { notification.success({ message: 'Update reason success' }); @@ -1136,33 +1175,92 @@ const ReviewPage = () => { setIsReasonModalOpen(false); }} > -