| 57 | }; |
| 58 | |
| 59 | export const getItemWeight = (unit: WeightUnit, item: PackItem | Item): WeightProps => { |
| 60 | const { weight, weight_unit } = item; |
| 61 | const quantity = 'packItem' in item ? item.packItem.quantity : 1; |
| 62 | const conversionValue = weight_unit ? converter(weight).from(unitDict[weight_unit]).to(unitDict[unit]) : 0; |
| 63 | const floatValue = parseFloat(conversionValue) * quantity; |
| 64 | |
| 65 | return { |
| 66 | value: floatValue, |
| 67 | label: floatValue.toFixed(2) |
| 68 | } |
| 69 | }; |
| 70 | |
| 71 | export const getWeightByCategory = (unit: WeightUnit, items: (PackItem | Item)[]): CategoryItemSpecs[] => { |
| 72 | const itemsByCategory = getItemsByCategory(items); |