fix dashboard & submit bad reason review

This commit is contained in:
Vu Khanh Du 2024-03-18 14:30:34 +07:00
parent cfdced2618
commit 59b8036949
4 changed files with 655 additions and 380 deletions

View File

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

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