feat: refactor user handling in news components and add premium attribute logic
This commit is contained in:
@@ -2,7 +2,7 @@ import { z } from 'zod'
|
||||
|
||||
import { HttpServer, type THttpServer } from '~/libs/http-server'
|
||||
|
||||
const playerSchema = z.object({
|
||||
const userSchema = z.object({
|
||||
data: z.object({
|
||||
id: z.string(),
|
||||
email: z.string(),
|
||||
@@ -12,10 +12,12 @@ const playerSchema = z.object({
|
||||
}),
|
||||
})
|
||||
|
||||
export type TUser = z.infer<typeof userSchema>
|
||||
|
||||
export const getUser = async (parameters: THttpServer) => {
|
||||
try {
|
||||
const { data } = await HttpServer(parameters).get(`/api/user/profile`)
|
||||
return playerSchema.parse(data)
|
||||
return userSchema.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