feat: add API endpoints for fetching staff profiles and staff list
This commit is contained in:
@@ -11,7 +11,7 @@ const staffResponseSchema = z.object({
|
||||
}),
|
||||
})
|
||||
|
||||
export const getStaff = async (parameters: THttpServer) => {
|
||||
export const getProfile = async (parameters: THttpServer) => {
|
||||
try {
|
||||
const { data } = await HttpServer(parameters).get(`/api/staff/profile`)
|
||||
return staffResponseSchema.parse(data)
|
||||
@@ -0,0 +1,25 @@
|
||||
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)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user