refactor(types): align core types with backend contract
This commit is contained in:
@@ -42,14 +42,14 @@ export default function VerifyPage() {
|
|||||||
)
|
)
|
||||||
|
|
||||||
const buildMaterials = () => {
|
const buildMaterials = () => {
|
||||||
const materials: Record<string, string> = {
|
const materials = {
|
||||||
realName,
|
realName,
|
||||||
idNumber,
|
idNumber,
|
||||||
gameProfile,
|
gameProfile,
|
||||||
idCardFront: "mock://idCardFront",
|
idCardFront: "mock://idCardFront",
|
||||||
idCardBack: "mock://idCardBack",
|
idCardBack: "mock://idCardBack",
|
||||||
gameScreenshot: "mock://gameScreenshot",
|
gameScreenshot: "mock://gameScreenshot",
|
||||||
}
|
} satisfies Record<string, string>
|
||||||
|
|
||||||
return materials
|
return materials
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,12 +35,12 @@ import { useState } from "react"
|
|||||||
|
|
||||||
import { canAccessDashboard } from "@/components/role-guard"
|
import { canAccessDashboard } from "@/components/role-guard"
|
||||||
|
|
||||||
const roleLabels: Record<UserRole, string> = {
|
const roleLabels = {
|
||||||
consumer: "客户",
|
consumer: "客户",
|
||||||
player: "打手",
|
player: "打手",
|
||||||
owner: "店主",
|
owner: "店主",
|
||||||
admin: "管理员",
|
admin: "管理员",
|
||||||
}
|
} satisfies Record<UserRole, string>
|
||||||
|
|
||||||
export function Header() {
|
export function Header() {
|
||||||
const [mobileOpen, setMobileOpen] = useState(false)
|
const [mobileOpen, setMobileOpen] = useState(false)
|
||||||
|
|||||||
+37
-35
@@ -1,11 +1,13 @@
|
|||||||
// All `id` fields come from backend snowflake int64.
|
// All `id` fields come from backend snowflake int64.
|
||||||
// Frontend stores them as strings to avoid JS number precision issues.
|
// Frontend stores them as strings to avoid JS number precision issues.
|
||||||
|
|
||||||
|
export type SnowflakeId = string
|
||||||
|
|
||||||
export type UserRole = "consumer" | "player" | "owner" | "admin"
|
export type UserRole = "consumer" | "player" | "owner" | "admin"
|
||||||
export type VerificationStatus = "pending" | "approved" | "rejected"
|
export type VerificationStatus = "pending" | "approved" | "rejected"
|
||||||
|
|
||||||
export interface User {
|
export interface User {
|
||||||
id: string
|
id: SnowflakeId
|
||||||
username: string
|
username: string
|
||||||
email?: string
|
email?: string
|
||||||
nickname: string
|
nickname: string
|
||||||
@@ -19,16 +21,16 @@ export interface User {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface Game {
|
export interface Game {
|
||||||
id: string
|
id: SnowflakeId
|
||||||
name: string
|
name: string
|
||||||
icon: string
|
icon: string
|
||||||
category: "MOBA" | "FPS" | "动作" | "RPG"
|
category: "MOBA" | "FPS" | "动作" | "RPG"
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface PlayerService {
|
export interface PlayerService {
|
||||||
id: string
|
id: SnowflakeId
|
||||||
playerId: string
|
playerId: SnowflakeId
|
||||||
gameId: string
|
gameId: SnowflakeId
|
||||||
gameName: string
|
gameName: string
|
||||||
title: string
|
title: string
|
||||||
description: string
|
description: string
|
||||||
@@ -39,7 +41,7 @@ export interface PlayerService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface Player {
|
export interface Player {
|
||||||
id: string
|
id: SnowflakeId
|
||||||
user: User
|
user: User
|
||||||
rating: number
|
rating: number
|
||||||
totalOrders: number
|
totalOrders: number
|
||||||
@@ -47,13 +49,13 @@ export interface Player {
|
|||||||
status: "available" | "busy" | "offline"
|
status: "available" | "busy" | "offline"
|
||||||
games: string[]
|
games: string[]
|
||||||
services: PlayerService[]
|
services: PlayerService[]
|
||||||
shopId?: string
|
shopId?: SnowflakeId
|
||||||
shopName?: string
|
shopName?: string
|
||||||
tags: string[]
|
tags: string[]
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Shop {
|
export interface Shop {
|
||||||
id: string
|
id: SnowflakeId
|
||||||
owner: User
|
owner: User
|
||||||
name: string
|
name: string
|
||||||
banner?: string
|
banner?: string
|
||||||
@@ -91,12 +93,12 @@ export type OrderStatus =
|
|||||||
| "cancelled"
|
| "cancelled"
|
||||||
|
|
||||||
export interface Order {
|
export interface Order {
|
||||||
id: string
|
id: SnowflakeId
|
||||||
consumerId: string
|
consumerId: SnowflakeId
|
||||||
consumerName: string
|
consumerName: string
|
||||||
playerId: string
|
playerId: SnowflakeId
|
||||||
playerName: string
|
playerName: string
|
||||||
shopId?: string
|
shopId?: SnowflakeId
|
||||||
shopName?: string
|
shopName?: string
|
||||||
service: PlayerService
|
service: PlayerService
|
||||||
status: OrderStatus
|
status: OrderStatus
|
||||||
@@ -109,12 +111,12 @@ export interface Order {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface Review {
|
export interface Review {
|
||||||
id: string
|
id: SnowflakeId
|
||||||
orderId: string
|
orderId: SnowflakeId
|
||||||
fromUserId: string
|
fromUserId: SnowflakeId
|
||||||
fromUserName: string
|
fromUserName: string
|
||||||
fromUserAvatar: string
|
fromUserAvatar: string
|
||||||
toUserId: string
|
toUserId: SnowflakeId
|
||||||
rating: number
|
rating: number
|
||||||
content?: string
|
content?: string
|
||||||
sealed: boolean
|
sealed: boolean
|
||||||
@@ -122,9 +124,9 @@ export interface Review {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface Dispute {
|
export interface Dispute {
|
||||||
id: string
|
id: SnowflakeId
|
||||||
orderId: string
|
orderId: SnowflakeId
|
||||||
initiatorId: string
|
initiatorId: SnowflakeId
|
||||||
initiatorName: string
|
initiatorName: string
|
||||||
reason: string
|
reason: string
|
||||||
evidence: string[]
|
evidence: string[]
|
||||||
@@ -134,8 +136,8 @@ export interface Dispute {
|
|||||||
}
|
}
|
||||||
|
|
||||||
interface BaseChatSession {
|
interface BaseChatSession {
|
||||||
id: string
|
id: SnowflakeId
|
||||||
participants: { id: string; name: string; avatar: string }[]
|
participants: { id: SnowflakeId; name: string; avatar: string }[]
|
||||||
lastMessage?: string
|
lastMessage?: string
|
||||||
lastMessageAt?: string
|
lastMessageAt?: string
|
||||||
unreadCount: number
|
unreadCount: number
|
||||||
@@ -144,7 +146,7 @@ interface BaseChatSession {
|
|||||||
|
|
||||||
export interface OrderChatSession extends BaseChatSession {
|
export interface OrderChatSession extends BaseChatSession {
|
||||||
type: "order"
|
type: "order"
|
||||||
orderId: string
|
orderId: SnowflakeId
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ConsultationChatSession extends BaseChatSession {
|
export interface ConsultationChatSession extends BaseChatSession {
|
||||||
@@ -155,9 +157,9 @@ export interface ConsultationChatSession extends BaseChatSession {
|
|||||||
export type ChatSession = OrderChatSession | ConsultationChatSession
|
export type ChatSession = OrderChatSession | ConsultationChatSession
|
||||||
|
|
||||||
export interface ChatMessage {
|
export interface ChatMessage {
|
||||||
id: string
|
id: SnowflakeId
|
||||||
sessionId: string
|
sessionId: SnowflakeId
|
||||||
senderId: string
|
senderId: SnowflakeId
|
||||||
senderName: string
|
senderName: string
|
||||||
senderAvatar: string
|
senderAvatar: string
|
||||||
type: "text" | "image" | "system"
|
type: "text" | "image" | "system"
|
||||||
@@ -166,15 +168,15 @@ export interface ChatMessage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface Post {
|
export interface Post {
|
||||||
id: string
|
id: SnowflakeId
|
||||||
author: User
|
author: User
|
||||||
authorRole: UserRole
|
authorRole: UserRole
|
||||||
title: string
|
title: string
|
||||||
content: string
|
content: string
|
||||||
images: string[]
|
images: string[]
|
||||||
tags: string[]
|
tags: string[]
|
||||||
linkedOrderId?: string
|
linkedOrderId?: SnowflakeId
|
||||||
quotedPostId?: string
|
quotedPostId?: SnowflakeId
|
||||||
likeCount: number
|
likeCount: number
|
||||||
commentCount: number
|
commentCount: number
|
||||||
liked: boolean
|
liked: boolean
|
||||||
@@ -183,8 +185,8 @@ export interface Post {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface Comment {
|
export interface Comment {
|
||||||
id: string
|
id: SnowflakeId
|
||||||
postId: string
|
postId: SnowflakeId
|
||||||
author: User
|
author: User
|
||||||
content: string
|
content: string
|
||||||
likeCount: number
|
likeCount: number
|
||||||
@@ -193,7 +195,7 @@ export interface Comment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface Notification {
|
export interface Notification {
|
||||||
id: string
|
id: SnowflakeId
|
||||||
type: "order" | "community" | "system"
|
type: "order" | "community" | "system"
|
||||||
title: string
|
title: string
|
||||||
content: string
|
content: string
|
||||||
@@ -203,7 +205,7 @@ export interface Notification {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface WalletTransaction {
|
export interface WalletTransaction {
|
||||||
id: string
|
id: SnowflakeId
|
||||||
type: "topup" | "payment" | "income" | "withdrawal" | "refund"
|
type: "topup" | "payment" | "income" | "withdrawal" | "refund"
|
||||||
amount: number
|
amount: number
|
||||||
description: string
|
description: string
|
||||||
@@ -211,9 +213,9 @@ export interface WalletTransaction {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface Favorite {
|
export interface Favorite {
|
||||||
id: string
|
id: SnowflakeId
|
||||||
userId: string
|
userId: SnowflakeId
|
||||||
targetType: "player" | "shop"
|
targetType: "player" | "shop"
|
||||||
targetId: string
|
targetId: SnowflakeId
|
||||||
createdAt: string
|
createdAt: string
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user