feat : creation du composant datatable (WIP)
This commit is contained in:
41
frontend/utils/datatable-formatters.ts
Normal file
41
frontend/utils/datatable-formatters.ts
Normal file
@@ -0,0 +1,41 @@
|
||||
export const formatBovinShipments = (value: unknown): string => {
|
||||
if (!Array.isArray(value) || value.length === 0) return '-'
|
||||
return value.map((item: any) => {
|
||||
const label = item?.shipmentType?.label ?? item?.shipmentType?.code ??
|
||||
'Type inconnu'
|
||||
const qty = item?.nbBovinSend ?? '-'
|
||||
return `${label} (${qty})`
|
||||
}).join(', ')
|
||||
}
|
||||
|
||||
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(', ')
|
||||
}
|
||||
|
||||
export const formatPelletBuildings = (value: unknown): string => {
|
||||
if (!Array.isArray(value) || value.length === 0) return '-'
|
||||
|
||||
return value
|
||||
.map((item: any) => {
|
||||
const pelletLabel =
|
||||
item?.pelletType?.label ?? item?.pelletType?.code ?? 'Granule inconnu'
|
||||
const buildingLabel =
|
||||
item?.building?.label ?? item?.building?.code ?? 'Bâtiment inconnu'
|
||||
|
||||
return `${pelletLabel} : ${buildingLabel}`
|
||||
})
|
||||
.join('\n')
|
||||
}
|
||||
Reference in New Issue
Block a user