submit solution
This commit is contained in:
parent
fdeee58560
commit
9c9d324e42
10
cope2n-fe/src/pages/reviews/consts.ts
Normal file
10
cope2n-fe/src/pages/reviews/consts.ts
Normal file
@ -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',
|
||||||
|
};
|
@ -36,6 +36,7 @@ import '@react-pdf-viewer/core/lib/styles/index.css';
|
|||||||
|
|
||||||
import { badQualityReasonSubmit } from 'request';
|
import { badQualityReasonSubmit } from 'request';
|
||||||
import { normalizeData } from 'utils/field-value-process';
|
import { normalizeData } from 'utils/field-value-process';
|
||||||
|
import { counter_measure_map } from './consts';
|
||||||
|
|
||||||
const { Sider, Content } = Layout;
|
const { Sider, Content } = Layout;
|
||||||
const siderStyle: React.CSSProperties = {
|
const siderStyle: React.CSSProperties = {
|
||||||
@ -301,6 +302,15 @@ const ReviewPage = () => {
|
|||||||
const [pageIndexToGoto, setPageIndexToGoto] = useState(1);
|
const [pageIndexToGoto, setPageIndexToGoto] = useState(1);
|
||||||
|
|
||||||
const [reason, setReason] = useState('');
|
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) => {
|
const setAndLoadSelectedFile = async (requestData, index) => {
|
||||||
setSelectedFileId(index);
|
setSelectedFileId(index);
|
||||||
@ -1117,14 +1127,43 @@ const ReviewPage = () => {
|
|||||||
width={700}
|
width={700}
|
||||||
onOk={async () => {
|
onOk={async () => {
|
||||||
// call submit api
|
// call submit api
|
||||||
if (!reason) {
|
if (!reason || !solution) {
|
||||||
notification.warning({ message: 'Please select a reason' });
|
notification.warning({
|
||||||
|
message: 'Please select a reason or a solution',
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
const params = {
|
const params = {
|
||||||
request_id: currentRequest?.RequestID,
|
request_id: currentRequest?.RequestID,
|
||||||
request_image_id: selectedFileName.replace(/\.[^/.]+$/, ''),
|
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) {
|
if (res.message) {
|
||||||
notification.success({ message: 'Update reason success' });
|
notification.success({ message: 'Update reason success' });
|
||||||
@ -1136,33 +1175,92 @@ const ReviewPage = () => {
|
|||||||
setIsReasonModalOpen(false);
|
setIsReasonModalOpen(false);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
<div style={{ display: 'flex', justifyContent: 'flex-start' }}>
|
||||||
<Form
|
<Form
|
||||||
style={{
|
style={{
|
||||||
marginTop: 30,
|
marginTop: 30,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Form.Item
|
<Form.Item name='reason' label={t`Reason for bad quality:`}>
|
||||||
name='reason'
|
|
||||||
label={t`Reason for bad quality:`}
|
|
||||||
style={{
|
|
||||||
marginBottom: 10,
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Select
|
<Select
|
||||||
placeholder='Select a reason'
|
placeholder='Select a reason'
|
||||||
style={{ width: 200 }}
|
style={{ width: 200 }}
|
||||||
options={[
|
options={[
|
||||||
{ value: 'invalid_image', label: t`Invalid image` },
|
{ value: 'invalid_image', label: t`Invalid image` },
|
||||||
{ value: 'missing_information', label: t`Missing information` },
|
{
|
||||||
|
value: 'missing_information',
|
||||||
|
label: t`Missing information`,
|
||||||
|
},
|
||||||
{ value: 'too_blurry_text', label: t`Too blurry text` },
|
{ value: 'too_blurry_text', label: t`Too blurry text` },
|
||||||
{ value: 'too_small_text', label: t`Too small text` },
|
{ value: 'too_small_text', label: t`Too small text` },
|
||||||
{ value: 'handwritten', label: t`Handwritten` },
|
{ value: 'handwritten', label: t`Handwritten` },
|
||||||
{ value: 'recheck', label: t`Recheck` },
|
{ value: 'wrong_feedback', label: t`Wrong Feedback` },
|
||||||
|
{ value: 'ocr_cannot_extract', label: t`Ocr cannot extract` },
|
||||||
|
{ value: 'other', label: t`Other` },
|
||||||
]}
|
]}
|
||||||
onChange={setReason}
|
onChange={setReason}
|
||||||
|
value={reason}
|
||||||
/>
|
/>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
</Form>
|
</Form>
|
||||||
|
{reason === 'other' && (
|
||||||
|
<Input
|
||||||
|
placeholder='Other reason'
|
||||||
|
value={otherReason}
|
||||||
|
onChange={(e) => {
|
||||||
|
setOtherReason(e.target.value);
|
||||||
|
}}
|
||||||
|
style={{
|
||||||
|
width: 200,
|
||||||
|
marginTop: 30,
|
||||||
|
marginBottom: 24,
|
||||||
|
marginLeft: 10,
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
<div style={{ display: 'flex', justifyContent: 'flex-start' }}>
|
||||||
|
<Form>
|
||||||
|
<Form.Item name='reason' label={t`Solution:`}>
|
||||||
|
<span style={{ display: 'none' }}>
|
||||||
|
{counter_measure_map[reason]}
|
||||||
|
</span>
|
||||||
|
<Select
|
||||||
|
placeholder='Select a solution'
|
||||||
|
style={{ width: 200 }}
|
||||||
|
options={[
|
||||||
|
{
|
||||||
|
value: 'Remove this image from the evaluation report',
|
||||||
|
label: t`Remove this image from the evaluation report`,
|
||||||
|
},
|
||||||
|
{ value: 'Improve OCR', label: t`Improve OCR` },
|
||||||
|
{
|
||||||
|
value: 'Update revised result and re-calculate accuracy',
|
||||||
|
label: t`Update revised result and re-calculate accuracy`,
|
||||||
|
},
|
||||||
|
{ value: 'other', label: t`Other` },
|
||||||
|
]}
|
||||||
|
onChange={setSolution}
|
||||||
|
value={solution}
|
||||||
|
// defaultValue={solution}
|
||||||
|
/>
|
||||||
|
</Form.Item>
|
||||||
|
</Form>
|
||||||
|
{solution === 'other' && (
|
||||||
|
<Input
|
||||||
|
placeholder='Other solution'
|
||||||
|
value={otherSolution}
|
||||||
|
onChange={(e) => {
|
||||||
|
setOtherSolution(e.target.value);
|
||||||
|
}}
|
||||||
|
style={{
|
||||||
|
width: 200,
|
||||||
|
marginBottom: 24,
|
||||||
|
marginLeft: 10,
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
</Modal>
|
</Modal>
|
||||||
{totalRequests > 0 && (
|
{totalRequests > 0 && (
|
||||||
<div
|
<div
|
||||||
|
@ -9,8 +9,9 @@ type badQualityReasonSubmitParams = {
|
|||||||
export async function badQualityReasonSubmit(
|
export async function badQualityReasonSubmit(
|
||||||
params: badQualityReasonSubmitParams,
|
params: badQualityReasonSubmitParams,
|
||||||
reason: string,
|
reason: string,
|
||||||
|
solution: string,
|
||||||
) {
|
) {
|
||||||
const data = { reason };
|
const data = { reason, solution };
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await API.post<{ message: string }>(
|
const response = await API.post<{ message: string }>(
|
||||||
|
Loading…
Reference in New Issue
Block a user