refactor(FE-316): Use real data and formatting in uniformity results

This commit is contained in:
rstubryan
2025-12-28 13:52:59 +07:00
parent b24fb54856
commit c550922974
@@ -15,6 +15,7 @@ import toast from 'react-hot-toast';
import { UniformityApi } from '@/services/api/uniformity';
import { isResponseError } from '@/lib/api-helper';
import Badge from '@/components/Badge';
import { formatNumber } from '@/lib/helper';
const weightStatusColorMap: Record<string, string> = {
ideal: 'bg-[#00D39033]',
@@ -126,26 +127,28 @@ const UniformityResultForm = () => {
const samplingTableData: SamplingData[] = useMemo(() => {
if (!verifyUniformityResult) return [];
const { sampling } = verifyUniformityResult;
return [
{
id: 'sampling-size',
label: 'Sampling size',
value: `1,150 of Birds`,
value: `${formatNumber(sampling.chick_qty_of_weight)} of Birds`,
},
{
id: 'mean-weight',
label: 'Mean Weight',
value: `121 g`,
value: `${sampling.mean_weight} g`,
},
{
id: 'min-limit',
label: 'Min Limit (-10%)',
value: `109 g`,
value: `${sampling.mean_down} g`,
},
{
id: 'max-limit',
label: 'Max Limit (+10%)',
value: `133 g`,
value: `${sampling.mean_up} g`,
},
];
}, [verifyUniformityResult]);
@@ -169,21 +172,23 @@ const UniformityResultForm = () => {
const resultTableData: ResultData[] = useMemo(() => {
if (!verifyUniformityResult) return [];
const { result } = verifyUniformityResult;
return [
{
id: 'ideal-birds',
label: 'Ideal Birds',
value: `851 of Birds`,
value: `${formatNumber(result.uniform_qty)} of Birds`,
},
{
id: 'outside-range',
label: 'Outside Range',
value: `299 of Birds`,
value: `${formatNumber(result.outside_qty)} of Birds`,
},
{
id: 'uniformity',
label: 'Uniformity',
value: `74 %`,
value: `${result.uniformity} %`,
},
];
}, [verifyUniformityResult]);
@@ -250,11 +255,12 @@ const UniformityResultForm = () => {
statusIndicator={true}
variant='soft'
className={{
badge: `rounded-xl w-full justify-start border border-gray-200 text-black bg-[#00D39033]`,
status: 'bg-[#008000]',
badge:
'rounded-xl w-full justify-start border border-gray-200 text-black bg-info/10',
status: 'bg-info',
}}
>
Ideal
Unknown
</Badge>
);
},