import { useMemo } from 'react';

import _ from 'lodash';

import ShortViewText from '@/components/ShortViewText';
import { LLRender } from '@/lang/Lang';
import { Badge } from '@/components/ui/badge';

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

const EnumsItem = (props: TableItemProps) => {

    const value = props.value;

    const values = useMemo(() => {
        return props.structure?.itemType?.values?.[value] as any;
    }, [props.structure, value]);




    if (!value || _.size(value) == 0) {
        return <EmptyItem {...props} />;
    }





    return <div>
        {_.map(value, (val, index) => {

            return <Badge variant="secondary"><ShortViewText text={LLRender(values?.[val] ?? '')} /></Badge>

        })}

    </div>


}

export default EnumsItem;