import { z } from 'zod'

import { HttpServer, type THttpServer } from '~/libs/http-server'

const staffSchema = z.object({
  data: z.object({
    id: z.string(),
    email: z.string(),
    username: z.string(),
  }),
})

export const getStaff = async (parameters: THttpServer) => {
  try {
    const { data } = await HttpServer(parameters).get(`/api/staff/profile`)
    return staffSchema.parse(data)
  } catch (error) {
    // eslint-disable-next-line unicorn/no-useless-promise-resolve-reject
    return Promise.reject(error)
  }
}
