refactor(store): adapt Zustand stores to backend-aligned types

- orders: remove name fields from creation, keep dispatchMode logic
- chat: remove readonly/senderName/senderAvatar references
- reviews: remove fromUserAvatar/toUserId, simplify participant check
- disputes: remove initiatorId/initiatorName from creation
- posts: remove authorRole/quotedPostId, keep linkedOrderId as number
- comments: remove postId from creation
- wallet: use string amounts
This commit is contained in:
zetaloop
2026-04-23 21:15:11 +08:00
parent 4037816998
commit 12284290cc
7 changed files with 28 additions and 125 deletions
+3 -7
View File
@@ -1,16 +1,14 @@
import { generateId } from "@/lib/id"
import type { Post, User, UserRole } from "@/lib/types"
import type { Post, User } from "@/lib/types"
import { create } from "zustand"
interface CreatePostInput {
author: User
authorRole: UserRole
title: string
content: string
images: string[]
tags: string[]
linkedOrderId?: string
quotedPostId?: string
}
interface PostState {
@@ -26,17 +24,15 @@ export const usePostStore = create<PostState>((set) => ({
const post: Post = {
id: generateId("post"),
author: input.author,
authorRole: input.authorRole,
title: input.title.trim(),
content: input.content.trim(),
images: input.images,
tags: input.tags,
linkedOrderId: input.linkedOrderId,
quotedPostId: input.quotedPostId,
linkedOrderId: input.linkedOrderId ? Number(input.linkedOrderId) : undefined,
pinned: false,
likeCount: 0,
commentCount: 0,
liked: false,
pinned: false,
createdAt: new Date().toISOString(),
}