import { useMemo } from 'react';

import _ from 'lodash';

import ShortViewLL from '@/components/ShortViewLL';
import { Badge } from '@/components/ui/badge';
import { cn } from '@/lib/utils';

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

const EnumItem = (props: TableItemProps) => {

    const value = props.value;

    const values = useMemo(() => {
        return props.structure?.values;
    }, [props.structure, value]);
    const tokens = props.boardTokens;




    if (!value || !values?.[value]) {
        return <EmptyItem {...props} />;
    }






    return <div><Badge
        variant={"secondary"}
        className={tokens ? 'py-0' : undefined}
    >

        <ShortViewLL
            className={cn(tokens?.valueClass)}
            maxLength={tokens?.shortTextMaxLength ?? 15}
            value={values?.[value] ?? ''}
        />
    </Badge></div>


}

export default EnumItem;
