From e51994958ee9f180678bbb6a7f9bfae5d87fba3e Mon Sep 17 00:00:00 2001 From: yagin Date: Thu, 5 Dec 2024 10:30:37 +0700 Subject: [PATCH 1/2] [yagin] add bad reason filter and fix response --- cope2n-fe/src/pages/reviews2/api.ts | 9 +- cope2n-fe/src/pages/reviews2/index.tsx | 148 ++++++++++++++++++------- 2 files changed, 118 insertions(+), 39 deletions(-) diff --git a/cope2n-fe/src/pages/reviews2/api.ts b/cope2n-fe/src/pages/reviews2/api.ts index 229ac6c..4f32ff9 100644 --- a/cope2n-fe/src/pages/reviews2/api.ts +++ b/cope2n-fe/src/pages/reviews2/api.ts @@ -10,6 +10,8 @@ export const fetchAllRequests = async ( filterFeedbackResult: string, filterPredictResult: string, filterReviewedResult: string, + filterBadReason: string, + filterOtherReason: string, page = 1, page_size = 20, max_accuracy = 100, @@ -42,6 +44,11 @@ export const fetchAllRequests = async ( if (filterReviewedResult) { filterStr += `reviewed_result=${filterReviewedResult}&`; } + if (filterBadReason === 'other' && filterOtherReason.trim()) { + filterStr += `bad_reason=${filterOtherReason}&`; + } else if(filterBadReason !== 'other') { + filterStr += `bad_reason=${filterBadReason}&`; + } // if (startDate && endDate) { filterStr += `start_date=${startDate}&end_date=${endDate}&`; @@ -105,7 +112,7 @@ export const fetchRequest = async (id: string) => { }); return await ( await response.json() - ).subscription_requests?.[0] || null; + ).subscription_requests?.[0]; }; export const addRecentRequest = ( diff --git a/cope2n-fe/src/pages/reviews2/index.tsx b/cope2n-fe/src/pages/reviews2/index.tsx index d66c5ef..94197a3 100644 --- a/cope2n-fe/src/pages/reviews2/index.tsx +++ b/cope2n-fe/src/pages/reviews2/index.tsx @@ -76,6 +76,9 @@ const ReviewPage = () => { const [filterFeedbackResult, setFilterFeedbackResult] = useState(''); const [filterPredictResult, setFilterPredictResult] = useState(''); const [filterReviewedResult, setFilterReviewedResult] = useState(''); + const [filterBadReason, setFilterBadReason] = useState('other'); + const [filterOtherReason, setFilterOtherReason] = useState(''); + // const [requests, setRequests] = useState([]); const [currentRequest, setCurrentRequest] = useState(null); const [currentRequestIndex, setCurrentRequestIndex] = useState(1); @@ -118,6 +121,8 @@ const ReviewPage = () => { filterFeedbackResult, filterPredictResult, filterReviewedResult, + filterBadReason, + filterOtherReason, 1, 1, filterAccuracy, @@ -125,7 +130,7 @@ const ReviewPage = () => { setTotalPages(data?.page?.total_requests); setHasNextRequest(1 < data?.page?.total_requests); const firstRequest = fetchRequest( - data?.subscription_requests[0].RequestID, + data?.subscription_requests?.[0]?.RequestID, ); firstRequest.then(async (data) => { if (data) setCurrentRequest(data); @@ -231,6 +236,8 @@ const ReviewPage = () => { filterFeedbackResult, filterPredictResult, filterReviewedResult, + filterBadReason, + filterOtherReason, requestIndex, 1, filterAccuracy, @@ -290,6 +297,8 @@ const ReviewPage = () => { filterFeedbackResult, filterPredictResult, filterReviewedResult, + filterBadReason, + filterOtherReason, 1, 1, filterAccuracy, @@ -919,31 +928,75 @@ const ReviewPage = () => { style={{ marginTop: 30, }} + layout="vertical" > - - { - setFilterDateRange(dateString); - }} - style={{ width: 200 }} - /> - -
+ + { + setFilterDateRange(dateString); + }} + style={{ width: 300 }} + /> + +
+ + { + setFilterOtherReason(e.target.value); + }} + /> + + )} +
+
+
{ message: 'Please select a subsidiary', }, ]} + style={{ + flex: 1, + }} > { message: 'Please select test status', }, ]} - style={{ marginLeft: 16 }} + style={{ flex: 1 }} > { setFilterFeedbackResult(e.target.value)} /> @@ -1082,7 +1146,7 @@ const ReviewPage = () => {
{ setFilterPredictResult(e.target.value)} /> setFilterReviewedResult(e.target.value)} /> From 7841a775b7add98d46d2dc3b72e586e06088ed07 Mon Sep 17 00:00:00 2001 From: yagin Date: Thu, 5 Dec 2024 14:44:49 +0700 Subject: [PATCH 2/2] [yagin] change style form review2 --- .../pages/reviews2/DocumentCompareInfo.tsx | 69 ++++++++++++++ .../src/pages/reviews2/DocumentHeadInfo.tsx | 39 ++++++++ cope2n-fe/src/pages/reviews2/index.tsx | 90 +++---------------- 3 files changed, 121 insertions(+), 77 deletions(-) create mode 100644 cope2n-fe/src/pages/reviews2/DocumentCompareInfo.tsx create mode 100644 cope2n-fe/src/pages/reviews2/DocumentHeadInfo.tsx diff --git a/cope2n-fe/src/pages/reviews2/DocumentCompareInfo.tsx b/cope2n-fe/src/pages/reviews2/DocumentCompareInfo.tsx new file mode 100644 index 0000000..b1963fe --- /dev/null +++ b/cope2n-fe/src/pages/reviews2/DocumentCompareInfo.tsx @@ -0,0 +1,69 @@ +import React from 'react'; +import { Button, Descriptions, Input } from 'antd'; +import type { DescriptionsProps } from 'antd'; +import { CopyOutlined } from '@ant-design/icons'; +import { FEEDBACK_RESULT, PREDICTED_RESULT, REVIEWED_RESULT } from './const'; + +const DocumentCompareInfo = ({ key, data, selectedFileDataSource, updateRevisedByFeedback, handleUpdateFileInField, shouldRevised, disabledInput }) => { + const items: DescriptionsProps['items'] = [ + { + key: selectedFileDataSource[data]?.[FEEDBACK_RESULT] || '1', + label: 'Feedback', + children: selectedFileDataSource[data]?.[FEEDBACK_RESULT], + labelStyle: { color: '#333', padding: '4px 16px' }, + contentStyle: { padding: '4px 16px' }, + span: 3 + }, + { + key: selectedFileDataSource[data]?.[PREDICTED_RESULT] || '2', + label: 'Predicted', + children: selectedFileDataSource[data]?.[PREDICTED_RESULT], + labelStyle: { color: '#333', padding: '4px 16px' }, + contentStyle: { padding: '4px 16px' }, + span: 3 + }, + { + key: selectedFileDataSource[data]?.[REVIEWED_RESULT] || '3', + label: 'Revised', + children: + handleUpdateFileInField(data, e.target.value) + } + variant="borderless" + disabled={disabledInput === undefined || disabledInput === 0} + />, + labelStyle: { color: '#333', padding: '4px 16px' }, + contentStyle: { padding: '4px 16px' }, + span: 3 + }, + ]; + return ( +
+
+

{data}

+
+ +
+ ) +} + +export default DocumentCompareInfo; \ No newline at end of file diff --git a/cope2n-fe/src/pages/reviews2/DocumentHeadInfo.tsx b/cope2n-fe/src/pages/reviews2/DocumentHeadInfo.tsx new file mode 100644 index 0000000..50b811b --- /dev/null +++ b/cope2n-fe/src/pages/reviews2/DocumentHeadInfo.tsx @@ -0,0 +1,39 @@ +import React from 'react'; +import { Descriptions } from 'antd'; +import type { DescriptionsProps } from 'antd'; + +const DocumentHeadInfo = ({ currentRequest }) => { + const items: DescriptionsProps['items'] = [ + { + key: '1', + label: 'Request ID', + children: currentRequest?.RequestID, + span: 2, + labelStyle: { color: '#333', width: '200px' } + }, + { + key: '2', + label: 'Redemption ID', + children: currentRequest?.RedemptionID, + labelStyle: { color: '#333', width: '200px' } + }, + { + key: '3', + label: 'Raw accuracy', + children: currentRequest?.raw_accuracy, + span: 2, + labelStyle: { color: '#333', width: '200px' } + }, + { + key: '4', + label: 'Processing time', + children: currentRequest?.['Server Processing Time (ms)'], + labelStyle: { color: '#333', width: '200px' } + } + ]; + return ( + + ) +} + +export default DocumentHeadInfo; \ No newline at end of file diff --git a/cope2n-fe/src/pages/reviews2/index.tsx b/cope2n-fe/src/pages/reviews2/index.tsx index 94197a3..804a7d3 100644 --- a/cope2n-fe/src/pages/reviews2/index.tsx +++ b/cope2n-fe/src/pages/reviews2/index.tsx @@ -3,7 +3,6 @@ import { ArrowRightOutlined, CheckCircleOutlined, ClockCircleFilled, - CopyOutlined, FullscreenExitOutlined, FullscreenOutlined, } from '@ant-design/icons'; @@ -55,6 +54,8 @@ import { import FileCard from './FileCard'; import RecentRequest from './RecentRequest'; import './style.css'; +import DocumentHeadInfo from './DocumentHeadInfo'; +import DocumentCompareInfo from './DocumentCompareInfo'; const ReviewPage = () => { const [loading, setLoading] = useState(false); @@ -500,42 +501,10 @@ const ReviewPage = () => { > {fullscreen ? : } - {totalRequests && ( -
-
- Request ID:   - {currentRequest?.RequestID} -
{' '} -
- Created at:   - {currentRequest?.created_at} -
{' '} -
- Request time:   - {currentRequest?.['Client Request Time (ms)']} -
{' '} -
- Redemption ID:   - {currentRequest?.RedemptionID} -
{' '} -
- Raw accuracy:   - {currentRequest?.raw_accuracy} -
{' '} -
- Processing time:   - {currentRequest?.['Server Processing Time (ms)']} -
{' '} -
- )}
+ {totalRequests && ( + + )} {totalRequests > 0 && (
{ } } catch (error) { } return ( -
-
-

{data}

-
- - - - handleUpdateFileInField(data, e.target.value) - } - /> -
+ ); })} {t`Bad image reason:`}