import { useMutation, useQuery } from "@tanstack/react-query";
import * as api from "../service/FinancialService";
import {
  CreateLegalUserType,
  CreateRealUserType,
} from "../types/FinancialTypes";

export const useCreateLegalUser = () => {
  return useMutation({
    mutationFn: (variables: CreateLegalUserType) =>
      api.createLegalUser(variables),
  });
};

export const useGetProvines = () => {
  return useQuery({
    queryKey: ["provines"],
    queryFn: () => api.getProvines(),
  });
};

export const useCreateRealUser = () => {
  return useMutation({
    mutationFn: (variables: CreateRealUserType) =>
      api.createRealUser(variables),
  });
};

export const useGetCities = (provincesId: string) => {
  return useQuery({
    queryKey: ["cities", provincesId],
    queryFn: () => api.getCities(provincesId),
    enabled: !!provincesId,
  });
};

export const useGetFinancialInfo = () => {
  return useQuery({
    queryKey: ["financial-info"],
    queryFn: () => api.getFinancialInfo(),
  });
};

export const useGetLegalInfo = () => {
  return useQuery({
    queryKey: ["legal-info"],
    queryFn: () => api.getLegalInfo(),
  });
};

export const useGetRealInfo = () => {
  return useQuery({
    queryKey: ["real-info"],
    queryFn: () => api.getRealInfo(),
  });
};
