import { useMutation, useQuery } from "@tanstack/react-query";
import { usersService } from "./service";
import type { UpdateProfileDto, ChangePasswordDto } from "./service";

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

export const useGetMe = (enabled: boolean = true) => {
  return useQuery({
    queryKey: UsersQueryKeys.me(),
    queryFn: () => usersService.getMe(),
    enabled,
  });
};

export const useUpdateProfile = () => {
  return useMutation({
    mutationFn: (dto: UpdateProfileDto) => usersService.updateMe(dto),
  });
};

export const useChangePassword = () => {
  return useMutation({
    mutationFn: (dto: ChangePasswordDto) => usersService.changePassword(dto),
  });
};
