import _ from 'lodash';

import { cn } from '@/lib/utils';

import TableItem, { TableItemProps } from '../TableItem';

const StructureItem = (props: TableItemProps) => {

    const value = props.value;
    const tokens = props.boardTokens;

    return <div className={cn('flex flex-row', tokens ? 'gap-1' : 'gap-2')}>


        {_.map(props.structure?.items, (item) => {

            if (!item.inAdmin || !item.inTable) return null;

            const valueItem = _.get(value, item?.key ?? "none", null);




            return <TableItem
                key={item.key}
                value={valueItem}
                structure={item ?? null}
                boardTokens={tokens}
            />

        })}




    </div>


}

export default StructureItem;
