1
0
mirror of https://github.com/toast-ts/Daggerbot-TS.git synced 2024-11-18 17:00:58 -05:00
Daggerbot-TS/src/helpers/PalletLibrary.ts

13 lines
603 B
TypeScript
Raw Normal View History

2023-10-02 13:05:51 -04:00
import {FSData} from 'src/typings/interfaces';
export default (serverEndpoint:FSData)=>{
const getAmount =(type:string)=>serverEndpoint.vehicles.filter(v=>v.type === 'pallet').map(v=>v.fills).flat().map(t=>t.type).filter(t=>t===type).length;
let palletTypeName = serverEndpoint.vehicles.filter(v=>v.type === 'pallet').map(v=>v.fills).flat().map(t=>t.type).filter((t,i,a)=>a.indexOf(t)===i).map(t=>({
[t]:{
name: t.toLowerCase().slice(0,1).toUpperCase()+t.toLowerCase().slice(1),
size: getAmount(t.toUpperCase())
},
})).reduce((a,b)=>({...a,...b}));
return palletTypeName;
}