import React from 'react';
import DocumentTags from './DocumentTags';
import type { Identifier } from '../../types/identifiers';
import type { DocumentTag } from '../../types/documents';

interface EntryTagsProps {
    tags: DocumentTag[];
    tagLookupById?: Map<Identifier, DocumentTag> | null;
    onTagClick?: (tagId: Identifier) => void;
    docId: Identifier;
    onDocumentTagDetach?: (docId: Identifier, tagId: Identifier) => void;
    onTagDragStart?: (event: React.DragEvent<HTMLElement>, tagId: Identifier) => void;
    onTagDragEnd?: (event: React.DragEvent<HTMLElement>) => void;
}

const EntryTags: React.FC<EntryTagsProps> = (props) => {
    if (!props.tags || props.tags.length === 0) {
        return null;
    }

    return (
        <DocumentTags
            tags={props.tags}
            tagLookupById={props.tagLookupById}
            onTagClick={props.onTagClick}
            docId={props.docId}
            onDocumentTagDetach={props.onDocumentTagDetach}
            onTagDragStart={props.onTagDragStart}
            onTagDragEnd={props.onTagDragEnd}
        />
    );
};

export default EntryTags;
