import { appQueryKeys } from '../app-query-keys';
import { type PostGetLastUpdate, appApi } from '../app-api';
import { queryClient } from 'src/utils/queryClient';

export const fetchLastDareDbUpdate = async (date: string) => {
  try {
    const data: PostGetLastUpdate = await queryClient.fetchQuery({
      queryKey: appQueryKeys.getLastDareUpdate(),
      queryFn: () => appApi.getLastDareUpdate(date).then((res) => res.data),
      gcTime: 0,
      staleTime: 0
    });

    return data;
  } catch (error) {
    console.error('Failed to fetch last dare update:', error);
  }
};
