From f390ce80d6635adeea1305916adcebbf2ec29c0f Mon Sep 17 00:00:00 2001 From: Felix Zett Date: Mon, 1 Sep 2025 20:25:28 +0200 Subject: [PATCH] feat: enhance TripChecklist to categorize items if they contain a '/' --- frontend/src/pages/TripChecklist.tsx | 73 ++++++++++++++++++++++++++-- 1 file changed, 70 insertions(+), 3 deletions(-) diff --git a/frontend/src/pages/TripChecklist.tsx b/frontend/src/pages/TripChecklist.tsx index fe05d8f..9e22b95 100644 --- a/frontend/src/pages/TripChecklist.tsx +++ b/frontend/src/pages/TripChecklist.tsx @@ -91,6 +91,22 @@ export default function TripChecklist({ trips }: { trips: any[] }) { // Gruppiere Items nach Kategorie (item.tag) const itemsWithoutTag = items.filter((item) => !item.tag); + + // Split items into "slash" category items and normal items + const slashCategoryMap: Record = {}; + const normalItemsWithoutTag: any[] = []; + + itemsWithoutTag.forEach((item) => { + const name = item.name_calculated || ""; + if (name.includes("/")) { + const [cat, sub] = name.split("/", 2); + if (!slashCategoryMap[cat]) slashCategoryMap[cat] = []; + slashCategoryMap[cat].push({ ...item, _sub: sub }); + } else { + normalItemsWithoutTag.push(item); + } + }); + // Map: tagId -> { tag, items: [...] } const itemsByTag: Record = {}; items @@ -203,8 +219,8 @@ export default function TripChecklist({ trips }: { trips: any[] }) { {/* ...Rest der Checklist... */}
    - {/* Einträge ohne Kategorie */} - {itemsWithoutTag.map((item) => ( + {/* Einträge ohne Kategorie und ohne Slash */} + {normalItemsWithoutTag.map((item) => (
  • ))} - {/* Einträge mit Kategorie */} + {/* Einträge mit Kategorie (item.tag) */} {sortedTagGroups.map(({ tag, items }) => (
  • @@ -295,6 +311,57 @@ export default function TripChecklist({ trips }: { trips: any[] }) { ))} ))} + + {/* Slash categories at the end */} + {Object.entries(slashCategoryMap).map(([cat, items]) => ( + +
  • +

    + {cat.charAt(0).toUpperCase() + cat.slice(1)} +

    +
  • + {items.map((item) => ( +
  • { + await toggleTripItem(item.id); + const updated = await getTripItems(id!); + setItems(updated); + }} + > + + + {item._sub} + + {item.item && item.item.tags && item.item.tags.length > 0 && ( + + {[...item.item.tags] + .slice() + .sort((a, b) => a.name.localeCompare(b.name)) + .map((tag: any) => ( + + #{tag.name} + + ))} + + )} +
  • + ))} + + ))}
);