refactor(api): add adapter layer for order/chat/review/dispute writes
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import { deny } from "@/lib/policy/assert"
|
||||
import { useAuthStore } from "@/store/auth"
|
||||
import { useReviewStore } from "@/store/reviews"
|
||||
|
||||
export function listReviews() {
|
||||
@@ -11,3 +13,17 @@ export function listReviewsByOrder(orderId: string) {
|
||||
export function listReviewsByTargetUser(userId: string) {
|
||||
return useReviewStore.getState().reviews.filter((review) => review.toUserId === userId)
|
||||
}
|
||||
|
||||
export function submitReview(input: { orderId: string; rating: number; content?: string }) {
|
||||
const userId = useAuthStore.getState().user?.id
|
||||
if (!userId) {
|
||||
return deny("AUTH_REQUIRED", "请先登录")
|
||||
}
|
||||
|
||||
return useReviewStore.getState().submitReview({
|
||||
orderId: input.orderId,
|
||||
fromUserId: userId,
|
||||
rating: input.rating,
|
||||
content: input.content,
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user