import { useQuery } from "@tanstack/react-query";
import { ApiResponse } from "@/types/api-response";
import { usersService } from "./service";
import { UserResponseDto } from "./types";

export const UsersQueryKeys = {
  all: ["users"] as const,
  me: () => [...UsersQueryKeys.all, "me"] as const,
};

export function useGetMe() {
  const queryKey = UsersQueryKeys.me();

  const { data, ...rest } = useQuery<ApiResponse<UserResponseDto>>({
    queryKey: queryKey,
    queryFn: usersService.getMe,
  });

  return { data: data?.data, ...rest };
}
