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)} />