feat: refactor user handling in news components and add premium attribute logic

This commit is contained in:
Ardeman
2025-03-03 08:59:06 +08:00
parent a594227026
commit 1b4ff4c3e7
5 changed files with 24 additions and 4 deletions
+4 -2
View File
@@ -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)