import React from 'react' ; import { Component , ComponentProps } from './Component/index' ; import { Group , GroupProps } from './Group/index' ; export interface IteratorProps { originalData : any ; filteredData : any ; isRoot ? : boolean ; } export const Iterator = ( { originalData , filteredData , isRoot = true } ) => { return ( < > { filteredData . map ( ( item ) => { if ( typeof item . children !== 'undefined' ) { const items = [ ] ; item . children . forEach ( ( id ) => { items . push ( originalData . filter ( ( fitem ) => id === fitem . id ) [ 0 ] ) ; } ) ; if ( item . type === 'GROUP' ) { const { id , value , isNegated } = item as GroupProps ; return ( < Group key = { id } value = { value } isNegated = { isNegated } id = { id } isRoot = { isRoot } > < Iterator originalData = { originalData } filteredData = { items } isRoot = { false } / > < /Group>); } return null ; } const { field , value , id , operator } = item as ComponentProps ; return ( < Component key = { id } field = { field } value = { value } operator = { operator } id = { id } data - test - id = "IteratorComponent" / > ) ; } ) } < />); } ;