Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | 1x 5x 5x 5x 5x 7x 5x 5x 2x 2x 2x 2x 2x 2x 2x 7x 2x 2x 2x 7x 5x 5x | import { SelectedAccountingObject } from '@/entities/accounting-object'
import { Nullable } from '@tmk/ui-kit'
import { PackagePipes } from '@/entities/pipe'
export const getSelectedPipesObjects = (
objects: SelectedAccountingObject[],
packagePipes?: Nullable<PackagePipes>
): SelectedAccountingObject[] => {
return objects.reduce((acc: SelectedAccountingObject[], obj: SelectedAccountingObject) => {
if (obj.type?.toLocaleLowerCase() === 'package' && !obj?.intermediate) {
const selectedPipes = packagePipes?.[obj.packageId as string]
if (selectedPipes) {
selectedPipes.forEach(pipe => {
const isAlreadyExists = acc?.find(selectedObject => selectedObject.id === pipe.id)
if (!isAlreadyExists) {
acc.push(pipe)
}
})
}
} else if (obj.type?.toLocaleLowerCase() === 'pipe') {
const isAlreadyExists = acc?.find(selectedObject => selectedObject.id === obj.id)
if (!isAlreadyExists) {
acc.push(obj)
}
}
return acc
}, [])
}
|