export function useAuthService() {
  const { apiFetch } = useApi()

  return {
    login(data: { email: string; password: string }) {
      return apiFetch<{ access_token: string; me: any }>('/auth/login', {
        method: 'POST',
        body: data,
      })
    },

    register(data: FormData) {
      return apiFetch('/register', {
        method: 'POST',
        body: data,
      })
    },

    logout() {
      return apiFetch('/auth/logout', { method: 'POST' })
    },

    me() {
      return apiFetch<{ data: any }>('/auth/me', { method: 'POST' })
    },

    refresh(refreshToken: string) {
      return apiFetch<{ access_token: string }>('/auth/refresh', {
        method: 'POST',
        body: { refresh_token: refreshToken },
      })
    },

    forgotPassword(form: { email: string }) {
      return apiFetch('/forget-password/create', {
        method: 'POST',
        body: form,
      })
    },

    resetPassword(data: { token: string; password: string; password_confirmation: string }) {
      return apiFetch('/forget-password/reset', {
        method: 'POST',
        body: data,
      })
    },
  }
}
