import { AxiosError } from 'axios'
import { UseMutationResult } from '@tanstack/react-query'

import { IBaseResponse } from '@/@core/types/api'
import { IAdmin } from '../data'

export type ErrCallbackType = (err: { [key: string]: string }) => void

export interface ILoginParams {
  identifier: string
  password: string
}

export interface IProfileResponse
  extends IBaseResponse<{
    user: IAdmin
    permissions: string[]
  }> {}

export interface ILoginResponse
  extends IBaseResponse<{
    token: string
    expires_at: string
    user_id: string
    user?: any
  }> {}

export interface ILogoutResponse extends IBaseResponse {}

export type AuthValuesType = {
  loading: boolean
  setLoading: React.Dispatch<React.SetStateAction<boolean>>
  isPending?: boolean
  user: IAdmin | null
  setUser: React.Dispatch<React.SetStateAction<IAdmin | null>>
  logout?: any
  logoutAll?: any
  // logout?: UseMutationResult<ILogoutResponse, AxiosError<any, any>, {}, unknown> | undefined
  login?: UseMutationResult<ILoginResponse, AxiosError<ILoginResponse, any>, ILoginParams, unknown>
  loginFireBase?: UseMutationResult<ILoginResponse, AxiosError<ILoginResponse, any>, { identifier: string }, unknown>
}
