26 lines
695 B
TypeScript
26 lines
695 B
TypeScript
import { z } from 'zod'
|
|
|
|
import { HttpServer, type THttpServer } from '~/libs/http-server'
|
|
|
|
const staffResponseSchema = z.object({
|
|
id: z.string(),
|
|
email: z.string(),
|
|
name: z.string(),
|
|
profile_picture: z.string(),
|
|
})
|
|
const staffsResponseSchema = z.object({
|
|
data: z.array(staffResponseSchema),
|
|
})
|
|
|
|
export type TStaffResponse = z.infer<typeof staffResponseSchema>
|
|
|
|
export const getStaffs = async (parameters: THttpServer) => {
|
|
try {
|
|
const { data } = await HttpServer(parameters).get(`/api/staff/get-all`)
|
|
return staffsResponseSchema.parse(data)
|
|
} catch (error) {
|
|
// eslint-disable-next-line unicorn/no-useless-promise-resolve-reject
|
|
return Promise.reject(error)
|
|
}
|
|
}
|