refactor(FE): Standardize unit labels and number formatting

This commit is contained in:
rstubryan
2026-01-21 13:45:12 +07:00
parent 507f53ace8
commit 99fc3f8cae
@@ -156,39 +156,39 @@ const productionStandardColumns: ColumnDef<StandardDetails>[] = [
}, },
{ {
accessorKey: 'egg_production_standard_detail.target_hen_house_production', accessorKey: 'egg_production_standard_detail.target_hen_house_production',
header: 'Target Hen House (%)', header: 'Target Hen House (btr)',
cell: (props) => cell: (props) =>
`${ formatNumber(
(props.row.original.egg_production_standard_detail (props.row.original.egg_production_standard_detail
?.target_hen_house_production as number) || 0 ?.target_hen_house_production as number) || 0
}%`, ),
}, },
{ {
accessorKey: 'egg_production_standard_detail.target_egg_weight', accessorKey: 'egg_production_standard_detail.target_egg_weight',
header: 'Target Egg Weight (gram)', header: 'Target Egg Weight (g)',
cell: (props) => cell: (props) =>
formatNumber( `${
(props.row.original.egg_production_standard_detail (props.row.original.egg_production_standard_detail
?.target_egg_weight as number) || 0 ?.target_egg_weight as number) || 0
), } g`,
}, },
{ {
accessorKey: 'egg_production_standard_detail.target_egg_mass', accessorKey: 'egg_production_standard_detail.target_egg_mass',
header: 'Target Egg Mass (gram)', header: 'Target Egg Mass (kg)',
cell: (props) => cell: (props) =>
formatNumber( `${
(props.row.original.egg_production_standard_detail (props.row.original.egg_production_standard_detail
?.target_egg_mass as number) || 0 ?.target_egg_mass as number) || 0
), } kg`,
}, },
{ {
accessorKey: 'egg_production_standard_detail.standard_fcr', accessorKey: 'egg_production_standard_detail.standard_fcr',
header: 'Standard FCR', header: 'Standard FCR (g)',
cell: (props) => cell: (props) =>
formatNumber( `${
(props.row.original.egg_production_standard_detail (props.row.original.egg_production_standard_detail
?.standard_fcr as number) || 0 ?.standard_fcr as number) || 0
), } g`,
}, },
]; ];
@@ -2107,38 +2107,33 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => {
</thead> </thead>
<tbody> <tbody>
<tr> <tr>
<td className='py-3 font-medium'>FCR</td> <td className='py-3 font-medium'>FCR (g)</td>
<td className='text-center py-3'> <td className='text-center py-3'>
<span className='font-semibold'> <span className='font-semibold'>
{initialValues.fcr_value != null {initialValues.fcr_value != null
? formatNumber(initialValues.fcr_value) ? `${formatNumber(initialValues.fcr_value)} g`
: '-'} : '-'}
</span> </span>
</td> </td>
<td className='text-center py-3 text-gray-600'> <td className='text-center py-3 text-gray-600'>
{initialValues.project_flock?.fcr?.fcr_std != null {initialValues.project_flock?.fcr?.fcr_std != null
? formatNumber( ? `${formatNumber(initialValues.project_flock?.fcr?.fcr_std)} g`
initialValues.project_flock?.fcr?.fcr_std
)
: '-'} : '-'}
</td> </td>
</tr> </tr>
<tr> <tr>
<td className='py-3 font-medium'>Feed Intake (KG)</td> <td className='py-3 font-medium'>Feed Intake (g)</td>
<td className='text-center py-3'> <td className='text-center py-3'>
<span className='font-semibold'> <span className='font-semibold'>
{initialValues.feed_intake != null {initialValues.feed_intake != null
? formatNumber(initialValues.feed_intake) ? `${formatNumber(initialValues.feed_intake)} g`
: '-'} : '-'}
</span> </span>
</td> </td>
<td className='text-center py-3 text-gray-600'> <td className='text-center py-3 text-gray-600'>
{initialValues.project_flock?.production_standart {initialValues.project_flock?.production_standart
?.feed_intake_std != null ?.feed_intake_std != null
? formatNumber( ? `${formatNumber(initialValues.project_flock?.production_standart?.feed_intake_std)} g`
initialValues.project_flock?.production_standart
?.feed_intake_std
)
: '-'} : '-'}
</td> </td>
</tr> </tr>
@@ -2218,51 +2213,43 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => {
</thead> </thead>
<tbody> <tbody>
<tr> <tr>
<td className='py-3 font-medium'>Egg Mass</td> <td className='py-3 font-medium'>Egg Mass (kg)</td>
<td className='text-center py-3'> <td className='text-center py-3'>
<span className='font-semibold'> <span className='font-semibold'>
{initialValues.egg_mass != null {initialValues.egg_mass != null
? formatNumber(initialValues.egg_mass) ? `${formatNumber(initialValues.egg_mass)} kg`
: '-'} : '-'}
</span> </span>
</td> </td>
<td className='text-center py-3 text-gray-600'> <td className='text-center py-3 text-gray-600'>
{initialValues.project_flock?.production_standart {initialValues.project_flock?.production_standart
?.egg_mass_std != null ?.egg_mass_std != null
? formatNumber( ? `${formatNumber(initialValues.project_flock?.production_standart?.egg_mass_std)} kg`
initialValues.project_flock
?.production_standart?.egg_mass_std
)
: '-'} : '-'}
</td> </td>
</tr> </tr>
<tr> <tr>
<td className='py-3 font-medium'> <td className='py-3 font-medium'>Egg Weight (g)</td>
Egg Weight (KG)
</td>
<td className='text-center py-3'> <td className='text-center py-3'>
<span className='font-semibold'> <span className='font-semibold'>
{initialValues.egg_weight != null {initialValues.egg_weight != null
? formatNumber(initialValues.egg_weight) ? `${formatNumber(initialValues.egg_weight)} g`
: '-'} : '-'}
</span> </span>
</td> </td>
<td className='text-center py-3 text-gray-600'> <td className='text-center py-3 text-gray-600'>
{initialValues.project_flock?.production_standart {initialValues.project_flock?.production_standart
?.egg_weight_std != null ?.egg_weight_std != null
? formatNumber( ? `${formatNumber(initialValues.project_flock?.production_standart?.egg_weight_std)} g`
initialValues.project_flock
?.production_standart?.egg_weight_std
)
: '-'} : '-'}
</td> </td>
</tr> </tr>
<tr> <tr>
<td className='py-3 font-medium'>Hen Day</td> <td className='py-3 font-medium'>Hen Day (%)</td>
<td className='text-center py-3'> <td className='text-center py-3'>
<span className='font-semibold'> <span className='font-semibold'>
{initialValues.hen_day != null {initialValues.hen_day != null
? formatNumber(initialValues.hen_day) ? `${formatNumber(initialValues.hen_day)}%`
: '-'} : '-'}
</span> </span>
</td> </td>
@@ -2274,18 +2261,20 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => {
</td> </td>
</tr> </tr>
<tr> <tr>
<td className='py-3 font-medium'>Hen House</td> <td className='py-3 font-medium'>
Hen House (btr)
</td>
<td className='text-center py-3'> <td className='text-center py-3'>
<span className='font-semibold'> <span className='font-semibold'>
{initialValues.hen_house != null {initialValues.hen_house != null
? formatNumber(initialValues.hen_house) ? `${formatNumber(initialValues.hen_house)} btr`
: '-'} : '-'}
</span> </span>
</td> </td>
<td className='text-center py-3 text-gray-600'> <td className='text-center py-3 text-gray-600'>
{initialValues.project_flock?.production_standart {initialValues.project_flock?.production_standart
?.hen_house_std != null ?.hen_house_std != null
? `${initialValues.project_flock?.production_standart?.hen_house_std}%` ? `${formatNumber(initialValues.project_flock?.production_standart?.hen_house_std)} btr`
: '-'} : '-'}
</td> </td>
</tr> </tr>