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

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

  return null;
};

export default AtemschutzExpiryNotifier;
