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