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

export const fetchPremiumStatus = async (token: string) => {
  try {
    const data: PostGetPremiumStatus = await queryClient.fetchQuery({
      queryKey: appQueryKeys.premiumStatus(token),
      queryFn: async () => {
        const response = await appApi.premiumStatus(token);
        return response.data;
      },
      gcTime: 0,
      staleTime: 0
    });

    return data;
  } catch (error) {
    console.error('Failed to fetch premium status:', error);
  }
};
