import React from 'react';
import { useQuery } from '@tanstack/react-query';
import { vikunjaApi } from '../../services/vikunja';

/**
 * Invisible component — polls /api/vikunja/overdue every 10 minutes.
 * The backend creates notifications as a side-effect when polled.
 */
const VikunjaOverdueNotifier: React.FC = () => {
  useQuery({
    queryKey: ['vikunja-overdue'],
    queryFn: () => vikunjaApi.getOverdueTasks(),
    refetchInterval: 10 * 60 * 1000,
    retry: 1,
  });

  return null;
};

export default VikunjaOverdueNotifier;
