update feedback
This commit is contained in:
parent
5343623b59
commit
052556b682
@ -6,6 +6,7 @@ import {
|
|||||||
ensureMin,
|
ensureMin,
|
||||||
formatNumber,
|
formatNumber,
|
||||||
formatPercent,
|
formatPercent,
|
||||||
|
numberWithCommas,
|
||||||
} from 'utils/metric-format';
|
} from 'utils/metric-format';
|
||||||
|
|
||||||
interface DataType {
|
interface DataType {
|
||||||
@ -31,7 +32,7 @@ interface DataType {
|
|||||||
|
|
||||||
const columns: TableColumnsType<DataType> = [
|
const columns: TableColumnsType<DataType> = [
|
||||||
{
|
{
|
||||||
title: 'Subs',
|
title: 'Subsidiary',
|
||||||
dataIndex: 'subSidiaries',
|
dataIndex: 'subSidiaries',
|
||||||
key: 'subSidiaries',
|
key: 'subSidiaries',
|
||||||
width: '100px',
|
width: '100px',
|
||||||
@ -76,7 +77,7 @@ const columns: TableColumnsType<DataType> = [
|
|||||||
className: 'hide-border-right',
|
className: 'hide-border-right',
|
||||||
render: (_, record) => {
|
render: (_, record) => {
|
||||||
const value = record.snImeiTC + record.invoiceTC;
|
const value = record.snImeiTC + record.invoiceTC;
|
||||||
return <span>{value ? value : '-'}</span>;
|
return <span>{value ? numberWithCommas(value) : '-'}</span>;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -90,7 +91,7 @@ const columns: TableColumnsType<DataType> = [
|
|||||||
className: 'show-border-left',
|
className: 'show-border-left',
|
||||||
render: (_, record) => {
|
render: (_, record) => {
|
||||||
const value = record.snImeiTC;
|
const value = record.snImeiTC;
|
||||||
return <span>{value ? value : '-'}</span>;
|
return <span>{value ? numberWithCommas(value) : '-'}</span>;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -100,7 +101,7 @@ const columns: TableColumnsType<DataType> = [
|
|||||||
width: '50px',
|
width: '50px',
|
||||||
render: (_, record) => {
|
render: (_, record) => {
|
||||||
const value = record.invoiceTC;
|
const value = record.invoiceTC;
|
||||||
return <span>{value ? value : '-'}</span>;
|
return <span>{value ? numberWithCommas(value) : '-'}</span>;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
@ -111,6 +112,10 @@ const columns: TableColumnsType<DataType> = [
|
|||||||
key: 'totalImages',
|
key: 'totalImages',
|
||||||
width: '130px',
|
width: '130px',
|
||||||
className: 'hide-border-right',
|
className: 'hide-border-right',
|
||||||
|
render: (_, record) => {
|
||||||
|
const value = record.totalImages;
|
||||||
|
return <span>{value ? numberWithCommas(value) : '-'}</span>;
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '',
|
title: '',
|
||||||
@ -121,12 +126,20 @@ const columns: TableColumnsType<DataType> = [
|
|||||||
key: 'snOrImeiNumber',
|
key: 'snOrImeiNumber',
|
||||||
width: '50px',
|
width: '50px',
|
||||||
className: 'show-border-left',
|
className: 'show-border-left',
|
||||||
|
render: (_, record) => {
|
||||||
|
const value = record.snOrImeiNumber;
|
||||||
|
return <span>{value ? numberWithCommas(value) : '-'}</span>;
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'Invoice',
|
title: 'Invoice',
|
||||||
dataIndex: 'invoiceNumber',
|
dataIndex: 'invoiceNumber',
|
||||||
key: 'invoiceNumber',
|
key: 'invoiceNumber',
|
||||||
width: '50px',
|
width: '50px',
|
||||||
|
render: (_, record) => {
|
||||||
|
const value = record.invoiceNumber;
|
||||||
|
return <span>{value ? numberWithCommas(value) : '-'}</span>;
|
||||||
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
@ -138,6 +151,10 @@ const columns: TableColumnsType<DataType> = [
|
|||||||
dataIndex: 'successfulNumber',
|
dataIndex: 'successfulNumber',
|
||||||
key: 'successfulNumber',
|
key: 'successfulNumber',
|
||||||
width: '50px',
|
width: '50px',
|
||||||
|
render: (_, record) => {
|
||||||
|
const value = record.successfulNumber;
|
||||||
|
return <span>{value ? numberWithCommas(value) : '-'}</span>;
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'Successful (%)',
|
title: 'Successful (%)',
|
||||||
@ -153,6 +170,10 @@ const columns: TableColumnsType<DataType> = [
|
|||||||
dataIndex: 'badNumber',
|
dataIndex: 'badNumber',
|
||||||
key: 'badNumber',
|
key: 'badNumber',
|
||||||
width: '30px',
|
width: '30px',
|
||||||
|
render: (_, record) => {
|
||||||
|
const value = record.badNumber;
|
||||||
|
return <span>{value ? numberWithCommas(value) : '-'}</span>;
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'Bad (%)',
|
title: 'Bad (%)',
|
||||||
@ -175,7 +196,7 @@ const columns: TableColumnsType<DataType> = [
|
|||||||
title: 'Average accuracy rate (%) \n(※ character-based)',
|
title: 'Average accuracy rate (%) \n(※ character-based)',
|
||||||
children: [
|
children: [
|
||||||
{
|
{
|
||||||
title: 'IMEI / Serial no.',
|
title: 'SN/IMEI',
|
||||||
dataIndex: 'snImeiAAR',
|
dataIndex: 'snImeiAAR',
|
||||||
key: 'snImeiAAR',
|
key: 'snImeiAAR',
|
||||||
width: '130px',
|
width: '130px',
|
||||||
|
@ -5,10 +5,14 @@ import { useReportList } from 'queries/report';
|
|||||||
import React, { useState } from 'react';
|
import React, { useState } from 'react';
|
||||||
import { useNavigate } from 'react-router-dom';
|
import { useNavigate } from 'react-router-dom';
|
||||||
import { downloadReport } from 'request/report';
|
import { downloadReport } from 'request/report';
|
||||||
import { formatPercent, ensureMin, ensureMax, formatNumber } from 'utils/metric-format';
|
import {
|
||||||
|
ensureMax,
|
||||||
|
ensureMin,
|
||||||
|
formatNumber,
|
||||||
|
formatPercent,
|
||||||
|
} from 'utils/metric-format';
|
||||||
import { datetimeStrToDate } from 'utils/time';
|
import { datetimeStrToDate } from 'utils/time';
|
||||||
|
|
||||||
|
|
||||||
const ReportTable: React.FC = () => {
|
const ReportTable: React.FC = () => {
|
||||||
const { isLoading, data: reportData } = useReportList({
|
const { isLoading, data: reportData } = useReportList({
|
||||||
page_size: 100,
|
page_size: 100,
|
||||||
@ -22,7 +26,7 @@ const ReportTable: React.FC = () => {
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
const handleDownloadReport = async (report_id: string) => {
|
const handleDownloadReport = async (report_id: string) => {
|
||||||
const {file, filename} = await downloadReport(report_id);
|
const { file, filename } = await downloadReport(report_id);
|
||||||
const anchorElement = document.createElement('a');
|
const anchorElement = document.createElement('a');
|
||||||
anchorElement.href = URL.createObjectURL(file);
|
anchorElement.href = URL.createObjectURL(file);
|
||||||
anchorElement.download = filename;
|
anchorElement.download = filename;
|
||||||
@ -46,7 +50,11 @@ const ReportTable: React.FC = () => {
|
|||||||
dataIndex: 'Created Date',
|
dataIndex: 'Created Date',
|
||||||
key: 'Created Date',
|
key: 'Created Date',
|
||||||
render: (_, record) => {
|
render: (_, record) => {
|
||||||
return <span>{datetimeStrToDate(record['Created Date'], 'Asia/Singapore')}</span>;
|
return (
|
||||||
|
<span>
|
||||||
|
{datetimeStrToDate(record['Created Date'], 'Asia/Singapore')}
|
||||||
|
</span>
|
||||||
|
);
|
||||||
},
|
},
|
||||||
width: 110,
|
width: 110,
|
||||||
},
|
},
|
||||||
@ -55,7 +63,11 @@ const ReportTable: React.FC = () => {
|
|||||||
dataIndex: 'Start Date',
|
dataIndex: 'Start Date',
|
||||||
key: 'Start Date',
|
key: 'Start Date',
|
||||||
render: (_, record) => {
|
render: (_, record) => {
|
||||||
return <span>{datetimeStrToDate(record['Start Date'], 'Asia/Singapore')}</span>;
|
return (
|
||||||
|
<span>
|
||||||
|
{datetimeStrToDate(record['Start Date'], 'Asia/Singapore')}
|
||||||
|
</span>
|
||||||
|
);
|
||||||
},
|
},
|
||||||
width: 110,
|
width: 110,
|
||||||
},
|
},
|
||||||
@ -64,7 +76,9 @@ const ReportTable: React.FC = () => {
|
|||||||
dataIndex: 'End Date',
|
dataIndex: 'End Date',
|
||||||
key: 'End Date',
|
key: 'End Date',
|
||||||
render: (_, record) => {
|
render: (_, record) => {
|
||||||
return <span>{datetimeStrToDate(record['End Date'], 'Asia/Singapore')}</span>;
|
return (
|
||||||
|
<span>{datetimeStrToDate(record['End Date'], 'Asia/Singapore')}</span>
|
||||||
|
);
|
||||||
},
|
},
|
||||||
width: 110,
|
width: 110,
|
||||||
},
|
},
|
||||||
@ -74,7 +88,7 @@ const ReportTable: React.FC = () => {
|
|||||||
key: 'Subsidiary',
|
key: 'Subsidiary',
|
||||||
render: (_, record) => {
|
render: (_, record) => {
|
||||||
return <span>{String(record['Subsidiary']).toUpperCase()}</span>;
|
return <span>{String(record['Subsidiary']).toUpperCase()}</span>;
|
||||||
},
|
},
|
||||||
width: 110,
|
width: 110,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -144,7 +158,7 @@ const ReportTable: React.FC = () => {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'Avg. Accuracy',
|
title: 'Average Accuracy',
|
||||||
dataIndex: 'Avg. Accuracy',
|
dataIndex: 'Avg. Accuracy',
|
||||||
key: 'Avg. Accuracy',
|
key: 'Avg. Accuracy',
|
||||||
render: (_, record) => {
|
render: (_, record) => {
|
||||||
@ -157,7 +171,7 @@ const ReportTable: React.FC = () => {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'Avg. OCR Processing Time (ms)',
|
title: 'Average Processing Time (ms)',
|
||||||
dataIndex: 'Avg. OCR Processing Time',
|
dataIndex: 'Avg. OCR Processing Time',
|
||||||
key: 'Avg. OCR Processing Time',
|
key: 'Avg. OCR Processing Time',
|
||||||
render: (_, record) => {
|
render: (_, record) => {
|
||||||
|
@ -1,4 +1,8 @@
|
|||||||
export const formatPercent = (value: any, floatingPoint: number = 1, maskZero: boolean = false) => {
|
export const formatPercent = (
|
||||||
|
value: any,
|
||||||
|
floatingPoint: number = 1,
|
||||||
|
maskZero: boolean = false,
|
||||||
|
) => {
|
||||||
if (value === null || value === undefined || (value === 0 && maskZero)) {
|
if (value === null || value === undefined || (value === 0 && maskZero)) {
|
||||||
return '-';
|
return '-';
|
||||||
}
|
}
|
||||||
@ -8,7 +12,11 @@ export const formatPercent = (value: any, floatingPoint: number = 1, maskZero: b
|
|||||||
return value.toFixed(floatingPoint);
|
return value.toFixed(floatingPoint);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const formatNumber = (value: any, floatingPoint: number = 1, maskZero: boolean = false) => {
|
export const formatNumber = (
|
||||||
|
value: any,
|
||||||
|
floatingPoint: number = 1,
|
||||||
|
maskZero: boolean = false,
|
||||||
|
) => {
|
||||||
if (value === null || value === undefined || (value === 0 && maskZero)) {
|
if (value === null || value === undefined || (value === 0 && maskZero)) {
|
||||||
return '-';
|
return '-';
|
||||||
}
|
}
|
||||||
@ -44,3 +52,7 @@ export const ensureMax = (
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const numberWithCommas = (x: number) => {
|
||||||
|
return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',');
|
||||||
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user