feat : creation du composant datatable (WIP)
This commit is contained in:
@@ -11,13 +11,18 @@ export const formatBovinShipments = (value: unknown): string => {
|
||||
export const formatWeights = (value: unknown): string => {
|
||||
if (!Array.isArray(value) || value.length === 0) return '-'
|
||||
|
||||
return value
|
||||
.map((item: any) => {
|
||||
const type = item?.type === 'tare' ? 'Poids à vide': item?.type === 'gross' ? 'Poids à plein': (item?.type ?? 'Poids')
|
||||
const weight = item?.weight ?? '-'
|
||||
return `${type}: ${weight}`
|
||||
})
|
||||
.join('\n ')
|
||||
let gross = 0
|
||||
let tare = 0
|
||||
|
||||
for (const item of value as Array<{ type?: string; weight?:
|
||||
unknown }>) {
|
||||
const w = Number(item.weight)
|
||||
if (!Number.isFinite(w)) continue
|
||||
if (item.type === 'gross') gross += w
|
||||
else if (item.type === 'tare') tare += w
|
||||
}
|
||||
|
||||
return `${gross - tare} kg`
|
||||
}
|
||||
|
||||
export const formatRoleLabels = (
|
||||
|
||||
Reference in New Issue
Block a user