import { UsersSubscriptionQueryOption } from '@/apis/users-subscription/queryOptions';
import { usersSubscriptionSchema } from '@/validators/users-subscription';
import { defer } from '@tanstack/react-router';
import { createFileRoute } from '@tanstack/react-router';

export const Route = createFileRoute('/_authenticated/users-subscription/')({
  validateSearch: usersSubscriptionSchema,
  loaderDeps: ({ search: { email, status, page } }) => ({
    email,
    status,
    page,
  }),
  loader: async ({ context: { queryClient }, deps }) => {
    return { usersSubscriptionData: defer(queryClient.ensureQueryData(UsersSubscriptionQueryOption(deps))) };
  },
});
