feature/improve-tag-organization-ux #8

Merged
pkartch merged 22 commits from feature/improve-tag-organization-ux into main 2026-01-17 06:13:39 +00:00
Showing only changes of commit b80e889636 - Show all commits

View File

@@ -127,9 +127,11 @@ function RecipeDetail() {
const trimmedTag = tagInput.trim(); const trimmedTag = tagInput.trim();
// Convert existing tags to string array (handle both string and object formats) // Convert existing tags to string array (handle both string and object formats)
const existingTagNames = (recipe.tags || []).map(tagItem => const existingTagNames = (recipe.tags || [])
.map(tagItem =>
typeof tagItem === 'string' ? tagItem : tagItem.tag?.name || tagItem.name typeof tagItem === 'string' ? tagItem : tagItem.tag?.name || tagItem.name
); )
.filter((tag): tag is string => tag !== undefined);
// Check if tag already exists on recipe // Check if tag already exists on recipe
if (existingTagNames.includes(trimmedTag)) { if (existingTagNames.includes(trimmedTag)) {
@@ -168,9 +170,11 @@ function RecipeDetail() {
try { try {
setSavingTags(true); setSavingTags(true);
// Convert existing tags to string array and filter out the removed tag // Convert existing tags to string array and filter out the removed tag
const existingTagNames = (recipe.tags || []).map(tagItem => const existingTagNames = (recipe.tags || [])
.map(tagItem =>
typeof tagItem === 'string' ? tagItem : tagItem.tag?.name || tagItem.name typeof tagItem === 'string' ? tagItem : tagItem.tag?.name || tagItem.name
); )
.filter((tag): tag is string => tag !== undefined);
const updatedTags = existingTagNames.filter(tag => tag !== tagToRemove); const updatedTags = existingTagNames.filter(tag => tag !== tagToRemove);
await recipesApi.update(id, { tags: updatedTags }); await recipesApi.update(id, { tags: updatedTags });
@@ -265,6 +269,7 @@ function RecipeDetail() {
recipe.tags.map(tagItem => { recipe.tags.map(tagItem => {
// Handle both string tags and object tags from API // Handle both string tags and object tags from API
const tagName = typeof tagItem === 'string' ? tagItem : tagItem.tag?.name || tagItem.name; const tagName = typeof tagItem === 'string' ? tagItem : tagItem.tag?.name || tagItem.name;
if (!tagName) return null; // Skip if tagName is undefined
return ( return (
<span key={tagName} className="tag-chip-inline"> <span key={tagName} className="tag-chip-inline">
{tagName} {tagName}