blob: d1d7bf3875514859d9d5ad032b534c120d40a80b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
import { useQuery } from "urql";
import { GetFeedsDocument } from "../graphql/generated/graphql";
import { FeedItem } from "./FeedItem";
interface Props {
onFeedUnsubscribed?: () => void;
}
export function FeedList({ onFeedUnsubscribed }: Props) {
const [{ data, fetching, error }] = useQuery({
query: GetFeedsDocument,
});
if (fetching) {
return <div className="p-4">Loading feeds...</div>;
}
if (error) {
return <div className="p-4 text-red-600">Error: {error.message}</div>;
}
if (!data?.feeds || data.feeds.length === 0) {
return <div className="p-4 text-gray-500">No feeds added yet.</div>;
}
return (
<div className="space-y-4 p-4">
{data.feeds.map((feed) => (
<FeedItem
key={feed.id}
feed={feed}
onFeedUnsubscribed={onFeedUnsubscribed}
/>
))}
</div>
);
}
|