import type { WatchListView } from '@dorfteich/shared'; import { useQuery, useQueryClient } from '@tanstack/react-query'; import { EyeOff } from 'lucide-react'; import { useTranslation } from 'react-i18next'; import { Link } from 'react-router-dom'; import { apiDelete, apiGet } from '../lib/api'; /** * The account's watch list (issue #93): everything the user follows, with * links to the targets and an unwatch action per entry. */ export function WatchesSection(): React.JSX.Element { const { t } = useTranslation('watches'); const queryClient = useQueryClient(); const list = useQuery({ queryKey: ['watches'], queryFn: () => apiGet('/users/me/watches'), }); const unwatch = async (targetType: string, targetId: string): Promise => { await apiDelete(`/watches/${targetType}/${targetId}`); await queryClient.invalidateQueries({ queryKey: ['watches'] }); await queryClient.invalidateQueries({ queryKey: ['watch', targetType, targetId] }); }; return (

{t('settings.title')}

{list.data && list.data.watches.length === 0 &&

{t('settings.empty')}

} {list.data && list.data.watches.length > 0 && (
    {list.data.watches.map((watch) => (
  • {watch.name} {t(`settings.types.${watch.targetType}`)}
  • ))}
)}
); }