Merge pull request #94 from SDSRV-IDP/fe/reviews

fix dashboard & submit bad reason review
This commit is contained in:
Đỗ Xuân Tân 2024-03-19 17:50:07 +07:00 committed by GitHub Enterprise
commit 8e18b69e0c
4 changed files with 655 additions and 380 deletions

View File

@ -1,7 +1,12 @@
import type { TableColumnsType } from 'antd'; import type { TableColumnsType } from 'antd';
import { Table } from 'antd'; import { Table } from 'antd';
import React from 'react'; import React from 'react';
import { ensureMax, ensureMin, formatPercent, formatNumber } from 'utils/metric-format'; import {
ensureMax,
ensureMin,
formatNumber,
formatPercent,
} from 'utils/metric-format';
interface DataType { interface DataType {
key: React.Key; key: React.Key;
@ -18,8 +23,7 @@ interface DataType {
purchaseDateAAR: number; purchaseDateAAR: number;
retailerNameAAR: number; retailerNameAAR: number;
invoiceNumberAAR: number; invoiceNumberAAR: number;
snImeiAPT: number; // APT: Average Processing Time avgAPT: number; // APT: Average Processing Time
invoiceAPT: number;
snImeiTC: number; // TC: transaction count snImeiTC: number; // TC: transaction count
invoiceTC: number; invoiceTC: number;
reviewProgress: number; reviewProgress: number;
@ -230,34 +234,16 @@ const columns: TableColumnsType<DataType> = [
}, },
{ {
title: 'Average Processing Time Per Image (Seconds)', title: 'Average Processing Time Per Image (Seconds)',
children: [ dataIndex: 'avgAPT',
{ key: 'avgAPT',
title: 'SN/IMEI', render: (_, record) => {
dataIndex: 'snImeiAPT', const isAbnormal = ensureMax(record.avgAPT, 2);
key: 'snImeiAPT', return (
render: (_, record) => { <span style={{ color: isAbnormal ? 'red' : '' }}>
const isAbnormal = ensureMax(record.snImeiAPT, 2); {formatNumber(record?.avgAPT)}
return ( </span>
<span style={{ color: isAbnormal ? 'red' : '' }}> );
{formatNumber(record?.snImeiAPT)} },
</span>
);
},
},
{
title: 'Invoice',
dataIndex: 'invoiceAPT',
key: 'invoiceAPT',
render: (_, record) => {
const isAbnormal = ensureMax(record.invoiceAPT, 2);
return (
<span style={{ color: isAbnormal ? 'red' : '' }}>
{formatNumber(record?.invoiceAPT)}
</span>
);
},
},
],
}, },
{ {
title: 'Review Progress', title: 'Review Progress',
@ -267,7 +253,9 @@ const columns: TableColumnsType<DataType> = [
render: (_, record) => { render: (_, record) => {
return ( return (
<span> <span>
{formatPercent(record.reviewProgress) === '-' ? 0 : formatPercent(record.reviewProgress)} {formatPercent(record.reviewProgress) === '-'
? 0
: formatPercent(record.reviewProgress)}
</span> </span>
); );
}, },
@ -301,11 +289,10 @@ const ReportOverViewTable: React.FC<ReportOverViewTableProps> = ({
purchaseDateAAR: item.average_accuracy_rate.purchase_date, purchaseDateAAR: item.average_accuracy_rate.purchase_date,
retailerNameAAR: item.average_accuracy_rate.retailername, retailerNameAAR: item.average_accuracy_rate.retailername,
invoiceNumberAAR: item.average_accuracy_rate.invoice_no, invoiceNumberAAR: item.average_accuracy_rate.invoice_no,
snImeiAPT: item.average_processing_time.imei, avgAPT: item.average_processing_time.avg,
invoiceAPT: item.average_processing_time.invoice,
snImeiTC: item.usage.imei, snImeiTC: item.usage.imei,
invoiceTC: item.usage.invoice, invoiceTC: item.usage.invoice,
reviewProgress:item.review_progress, reviewProgress: item.review_progress,
}; };
}, },
); );

File diff suppressed because it is too large Load Diff

View File

@ -1 +1,2 @@
export * from './reviews';
export * from './user'; export * from './user';

View File

@ -0,0 +1,32 @@
import { notification } from 'antd';
import { API } from './api';
type badQualityReasonSubmitParams = {
request_id: string;
request_image_id: string;
};
export async function badQualityReasonSubmit(
params: badQualityReasonSubmitParams,
reason: string,
) {
const data = { reason };
try {
const response = await API.post<{ message: string }>(
`/ctel/request_image/${params.request_id}/${params.request_image_id}/`,
data,
{
headers: {
'Content-Type': 'multipart/form-data',
},
},
);
return response.data;
} catch (error) {
notification.error({
message: `${error?.message}`,
});
console.log(error);
}
}