import React from 'react'; import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query'; import { Rss, Globe, ToggleLeft, ToggleRight, ExternalLink } from 'lucide-react'; import { apiClient, Feed } from '../lib/api'; const Feeds: React.FC = () => { const queryClient = useQueryClient(); const { data: feeds, isLoading, error } = useQuery({ queryKey: ['feeds'], queryFn: () => apiClient.getFeeds(), }); const toggleMutation = useMutation({ mutationFn: (feedId: number) => apiClient.toggleFeed(feedId), onSuccess: () => { queryClient.invalidateQueries({ queryKey: ['feeds'] }); }, }); const handleToggle = (feedId: number) => { toggleMutation.mutate(feedId); }; const getTypeIcon = (type: string) => { switch (type) { case 'rss': return ; case 'website': return ; default: return ; } }; if (isLoading) { return (
{[...Array(6)].map((_, i) => (
))}
); } if (error) { return (

Failed to load feeds

); } return (

Feeds

Manage your RSS feeds and website sources

{feeds?.map((feed: Feed) => (
{getTypeIcon(feed.type)}

{feed.name}

{feed.description || 'No description provided'}

{feed.is_active ? 'Active' : 'Inactive'} {feed.type.toUpperCase()}
Added {new Date(feed.created_at).toLocaleDateString()}
))} {feeds?.length === 0 && (

No feeds

Get started by adding your first feed.

)}
); }; export default Feeds;