From 23a48e1d498680be769e931f46ddb1fd44f38d1a Mon Sep 17 00:00:00 2001 From: Adam Mathes Date: Fri, 13 Feb 2026 07:46:58 -0800 Subject: Implement Tag View and fix tests --- frontend/src/components/FeedList.tsx | 66 ++++++++++++++++++++++++------------ 1 file changed, 44 insertions(+), 22 deletions(-) (limited to 'frontend/src/components/FeedList.tsx') diff --git a/frontend/src/components/FeedList.tsx b/frontend/src/components/FeedList.tsx index f913293..f17fdc7 100644 --- a/frontend/src/components/FeedList.tsx +++ b/frontend/src/components/FeedList.tsx @@ -1,23 +1,28 @@ import { useEffect, useState } from 'react'; import { Link } from 'react-router-dom'; -import type { Feed } from '../types'; +import type { Feed, Category } from '../types'; import './FeedList.css'; export default function FeedList() { const [feeds, setFeeds] = useState([]); + const [tags, setTags] = useState([]); const [loading, setLoading] = useState(true); const [error, setError] = useState(''); useEffect(() => { - fetch('/api/feed/') - .then((res) => { - if (!res.ok) { - throw new Error('Failed to fetch feeds'); - } + Promise.all([ + fetch('/api/feed/').then(res => { + if (!res.ok) throw new Error('Failed to fetch feeds'); + return res.json(); + }), + fetch('/api/tag').then(res => { + if (!res.ok) throw new Error('Failed to fetch tags'); return res.json(); }) - .then((data) => { - setFeeds(data); + ]) + .then(([feedsData, tagsData]) => { + setFeeds(feedsData); + setTags(tagsData); setLoading(false); }) .catch((err) => { @@ -31,20 +36,37 @@ export default function FeedList() { return (
-

Feeds

- {feeds.length === 0 ? ( -

No feeds found.

- ) : ( -
    - {feeds.map((feed) => ( -
  • - - {feed.title || feed.url} - - {feed.category && {feed.category}} -
  • - ))} -
+
+

Feeds

+ {feeds.length === 0 ? ( +

No feeds found.

+ ) : ( +
    + {feeds.map((feed) => ( +
  • + + {feed.title || feed.url} + + {feed.category && {feed.category}} +
  • + ))} +
+ )} +
+ + {tags && tags.length > 0 && ( +
+

Tags

+
    + {tags.map((tag) => ( +
  • + + {tag.title} + +
  • + ))} +
+
)}
); -- cgit v1.2.3