diff --git a/frontend/src/components/ItemRow.tsx b/frontend/src/components/ItemRow.tsx index 01b30d3..d85554a 100644 --- a/frontend/src/components/ItemRow.tsx +++ b/frontend/src/components/ItemRow.tsx @@ -1,11 +1,11 @@ import React, { useState, useRef } from "react"; -import { Item, Tag } from "../api"; -import { getTagColor } from "../utils/tagColors"; +import { Item, Tag as TagType } from "../api"; import TagAutocompleteInput from "./TagAutocompleteInput"; +import Tag from "./Tag"; interface ItemRowProps { item: Item; - allTags: Tag[]; + allTags: TagType[]; onUpdateName: (id: string, name: string) => void; onDeleteTag: (itemId: string, tagId: string) => void; onAddTag: (itemId: string, tagId: string) => void; @@ -34,7 +34,6 @@ export default function ItemRow({ setIsEditing(false); } - // --- Dim category part if "/" exists --- function renderNameWithCategory(name: string) { if (!name.includes("/")) return name; const [cat, rest] = name.split("/", 2); @@ -46,7 +45,6 @@ export default function ItemRow({ ); } - // Trip-Namen lookup const tripName = item.trip_id && trips ? trips.find((t) => t.id === item.trip_id)?.name @@ -58,7 +56,6 @@ export default function ItemRow({ onMouseEnter={() => setHover(true)} onMouseLeave={() => { setHover(false); - // Only close add tag input if not focused if ( !addingTag || (inputRef.current && document.activeElement !== inputRef.current) @@ -92,29 +89,22 @@ export default function ItemRow({ )} {item.tags.map((tag) => ( - - #{tag.name} - {tag.mandatory && !} - {hover && ( - - )} - + tag={tag} + isMarked={false} + hoveredTag={null} + onRemoveTag={() => onDeleteTag(item.id, tag.id)} + showRemove={hover} + /> ))} {tripName && ( - - {tripName} - + )} {hover && !addingTag && ( @@ -149,7 +139,6 @@ export default function ItemRow({ /> )} - {/* Löschen-Button am Ende der Zeile */} {hover && ( + )} + + ); +} \ No newline at end of file diff --git a/frontend/src/components/TagAutocompleteInput.tsx b/frontend/src/components/TagAutocompleteInput.tsx index ae83705..dbc09ae 100644 --- a/frontend/src/components/TagAutocompleteInput.tsx +++ b/frontend/src/components/TagAutocompleteInput.tsx @@ -1,9 +1,10 @@ import React, { useState, useImperativeHandle, forwardRef, useRef } from "react"; -import { Tag } from "../api"; +import { Tag as TagType } from "../api"; +import Tag from "./Tag"; interface TagAutocompleteInputProps { - allTags: Tag[]; - selectedTags: Tag[]; + allTags: TagType[]; + selectedTags: TagType[]; onAddTag: (tagId: string, viaTab?: boolean) => void; onEscape?: () => void; placeholder?: string; @@ -86,14 +87,19 @@ const TagAutocompleteInput = forwardRef )} {filteredSuggestions.length > 0 && ( -