From 7bcb73f13907abc69140c126ff779c6a0abe17f8 Mon Sep 17 00:00:00 2001 From: zetaloop Date: Sun, 22 Feb 2026 08:02:48 +0800 Subject: [PATCH] refactor(data): add mock API adapters, id utility, and toast feedback --- app/(order)/order/new/page.tsx | 16 +++++------- app/providers.tsx | 2 ++ components/order-actions.tsx | 4 +-- lib/api/chat.ts | 13 ++++++++++ lib/api/comments.ts | 9 +++++++ lib/api/disputes.ts | 9 +++++++ lib/api/favorites.ts | 18 +++++++++++++ lib/api/games.ts | 9 +++++++ lib/api/index.ts | 14 +++++++++++ lib/api/notifications.ts | 5 ++++ lib/api/orders.ts | 13 ++++++++++ lib/api/players.ts | 13 ++++++++++ lib/api/posts.ts | 13 ++++++++++ lib/api/reviews.ts | 13 ++++++++++ lib/api/services.ts | 13 ++++++++++ lib/api/shops.ts | 13 ++++++++++ lib/api/transactions.ts | 5 ++++ lib/api/users.ts | 13 ++++++++++ lib/id.ts | 6 +++++ lib/toast.ts | 9 +++++++ package.json | 1 + pnpm-lock.yaml | 46 +++++++++++----------------------- store/chat.ts | 3 ++- store/orders.ts | 3 ++- store/services.ts | 3 ++- 25 files changed, 219 insertions(+), 47 deletions(-) create mode 100644 lib/api/chat.ts create mode 100644 lib/api/comments.ts create mode 100644 lib/api/disputes.ts create mode 100644 lib/api/favorites.ts create mode 100644 lib/api/games.ts create mode 100644 lib/api/index.ts create mode 100644 lib/api/notifications.ts create mode 100644 lib/api/orders.ts create mode 100644 lib/api/players.ts create mode 100644 lib/api/posts.ts create mode 100644 lib/api/reviews.ts create mode 100644 lib/api/services.ts create mode 100644 lib/api/shops.ts create mode 100644 lib/api/transactions.ts create mode 100644 lib/api/users.ts create mode 100644 lib/id.ts create mode 100644 lib/toast.ts diff --git a/app/(order)/order/new/page.tsx b/app/(order)/order/new/page.tsx index 17586cc..a079637 100644 --- a/app/(order)/order/new/page.tsx +++ b/app/(order)/order/new/page.tsx @@ -12,16 +12,12 @@ import { Label } from "@/components/ui/label" import { Separator } from "@/components/ui/separator" import { Textarea } from "@/components/ui/textarea" import { mockPlayers, mockServices, walletBalance } from "@/lib/mock" +import { notifySuccess } from "@/lib/toast" import { useRequireAuth } from "@/lib/use-require-auth" import { useAuthStore } from "@/store/auth" import { useChatStore } from "@/store/chat" import { useOrderStore } from "@/store/orders" -function showFeedback(message: string) { - if (typeof window === "undefined") return - window.alert(message) -} - export default function NewOrderPage() { const router = useRouter() const searchParams = useSearchParams() @@ -189,12 +185,12 @@ export default function NewOrderPage() { onClick={() => requireAuth(async () => { await new Promise((resolve) => setTimeout(resolve, 500)) - const currentUser = useAuthStore.getState().user - if (!currentUser) return + const authUser = useAuthStore.getState().user + if (!authUser) return const order = createOrder({ - consumerId: currentUser.id, - consumerName: currentUser.nickname, + consumerId: authUser.id, + consumerName: authUser.nickname, playerId: player.id, playerName: player.user.nickname, shopId: player.shopId, @@ -207,7 +203,7 @@ export default function NewOrderPage() { ensureOrderSession(order) setSubmitted(true) - showFeedback("下单成功") + notifySuccess("下单成功") setTimeout(() => { router.push(`/order/${order.id}`) }, 800) diff --git a/app/providers.tsx b/app/providers.tsx index 6a29d33..df28850 100644 --- a/app/providers.tsx +++ b/app/providers.tsx @@ -2,6 +2,7 @@ import { QueryClient, QueryClientProvider } from "@tanstack/react-query" import { useState } from "react" +import { Toaster } from "sonner" import { GlobalLoginDialog } from "@/components/global-login-dialog" import { TooltipProvider } from "@/components/ui/tooltip" @@ -22,6 +23,7 @@ export function Providers({ children }: { children: React.ReactNode }) { {children} + diff --git a/components/order-actions.tsx b/components/order-actions.tsx index 7278ecc..31e1084 100644 --- a/components/order-actions.tsx +++ b/components/order-actions.tsx @@ -4,6 +4,7 @@ import { AlertTriangle, CheckCircle2, MessageSquare, RefreshCw, Star, XCircle } import Link from "next/link" import { useEffect, useState } from "react" import { Button } from "@/components/ui/button" +import { notifySuccess } from "@/lib/toast" import type { OrderStatus } from "@/lib/types" import { useChatStore } from "@/store/chat" import { useOrderStore } from "@/store/orders" @@ -16,8 +17,7 @@ interface OrderActionsProps { } function showFeedback(message: string) { - if (typeof window === "undefined") return - window.alert(message) + notifySuccess(message) } export default function OrderActions({ diff --git a/lib/api/chat.ts b/lib/api/chat.ts new file mode 100644 index 0000000..b66831a --- /dev/null +++ b/lib/api/chat.ts @@ -0,0 +1,13 @@ +import { useChatStore } from "@/store/chat" + +export function listChatSessions() { + return useChatStore.getState().sessions +} + +export function getChatSessionById(sessionId: string) { + return useChatStore.getState().sessions.find((session) => session.id === sessionId) +} + +export function listChatMessages(sessionId: string) { + return useChatStore.getState().messages.filter((message) => message.sessionId === sessionId) +} diff --git a/lib/api/comments.ts b/lib/api/comments.ts new file mode 100644 index 0000000..e077791 --- /dev/null +++ b/lib/api/comments.ts @@ -0,0 +1,9 @@ +import { mockComments } from "@/lib/mock" + +export function listComments() { + return mockComments +} + +export function listCommentsByPost(postId: string) { + return mockComments.filter((comment) => comment.postId === postId) +} diff --git a/lib/api/disputes.ts b/lib/api/disputes.ts new file mode 100644 index 0000000..5aee7ba --- /dev/null +++ b/lib/api/disputes.ts @@ -0,0 +1,9 @@ +import { mockDisputes } from "@/lib/mock" + +export function listDisputes() { + return mockDisputes +} + +export function getDisputeByOrderId(orderId: string) { + return mockDisputes.find((dispute) => dispute.orderId === orderId) +} diff --git a/lib/api/favorites.ts b/lib/api/favorites.ts new file mode 100644 index 0000000..055d404 --- /dev/null +++ b/lib/api/favorites.ts @@ -0,0 +1,18 @@ +import { mockFavorites } from "@/lib/mock" + +export function listFavorites() { + return mockFavorites +} + +export function listFavoritesByUser(userId: string) { + return mockFavorites.filter((favorite) => favorite.userId === userId) +} + +export function isFavorited(userId: string, targetType: "player" | "shop", targetId: string) { + return mockFavorites.some( + (favorite) => + favorite.userId === userId && + favorite.targetType === targetType && + favorite.targetId === targetId, + ) +} diff --git a/lib/api/games.ts b/lib/api/games.ts new file mode 100644 index 0000000..0eb5edb --- /dev/null +++ b/lib/api/games.ts @@ -0,0 +1,9 @@ +import { mockGames } from "@/lib/mock" + +export function listGames() { + return mockGames +} + +export function getGameById(gameId: string) { + return mockGames.find((game) => game.id === gameId) +} diff --git a/lib/api/index.ts b/lib/api/index.ts new file mode 100644 index 0000000..8f9716e --- /dev/null +++ b/lib/api/index.ts @@ -0,0 +1,14 @@ +export { getChatSessionById, listChatMessages, listChatSessions } from "./chat" +export { listComments, listCommentsByPost } from "./comments" +export { getDisputeByOrderId, listDisputes } from "./disputes" +export { isFavorited, listFavorites, listFavoritesByUser } from "./favorites" +export { getGameById, listGames } from "./games" +export { listNotifications } from "./notifications" +export { getOrderById, listOrders, listOrdersByConsumer } from "./orders" +export { getPlayerById, listPlayers, listPlayersByShop } from "./players" +export { getPostById, listPosts, listPostsByAuthor } from "./posts" +export { listReviews, listReviewsByOrder, listReviewsByTargetUser } from "./reviews" +export { getServiceById, listServices, listServicesByPlayer } from "./services" +export { getShopById, getShopByOwnerId, listShops } from "./shops" +export { listTransactions } from "./transactions" +export { getCurrentUserForLogin, getUserById, listUsers } from "./users" diff --git a/lib/api/notifications.ts b/lib/api/notifications.ts new file mode 100644 index 0000000..591a55b --- /dev/null +++ b/lib/api/notifications.ts @@ -0,0 +1,5 @@ +import { useNotificationStore } from "@/store/notifications" + +export function listNotifications() { + return useNotificationStore.getState().notifications +} diff --git a/lib/api/orders.ts b/lib/api/orders.ts new file mode 100644 index 0000000..ba84edf --- /dev/null +++ b/lib/api/orders.ts @@ -0,0 +1,13 @@ +import { useOrderStore } from "@/store/orders" + +export function listOrders() { + return useOrderStore.getState().orders +} + +export function getOrderById(orderId: string) { + return useOrderStore.getState().orders.find((order) => order.id === orderId) +} + +export function listOrdersByConsumer(consumerId: string) { + return useOrderStore.getState().orders.filter((order) => order.consumerId === consumerId) +} diff --git a/lib/api/players.ts b/lib/api/players.ts new file mode 100644 index 0000000..deac8b2 --- /dev/null +++ b/lib/api/players.ts @@ -0,0 +1,13 @@ +import { usePlayerStore } from "@/store/players" + +export function listPlayers() { + return usePlayerStore.getState().players +} + +export function getPlayerById(playerId: string) { + return usePlayerStore.getState().players.find((player) => player.id === playerId) +} + +export function listPlayersByShop(shopId: string) { + return usePlayerStore.getState().players.filter((player) => player.shopId === shopId) +} diff --git a/lib/api/posts.ts b/lib/api/posts.ts new file mode 100644 index 0000000..3a8154a --- /dev/null +++ b/lib/api/posts.ts @@ -0,0 +1,13 @@ +import { mockPosts } from "@/lib/mock" + +export function listPosts() { + return mockPosts +} + +export function getPostById(postId: string) { + return mockPosts.find((post) => post.id === postId) +} + +export function listPostsByAuthor(userId: string) { + return mockPosts.filter((post) => post.author.id === userId) +} diff --git a/lib/api/reviews.ts b/lib/api/reviews.ts new file mode 100644 index 0000000..c4da795 --- /dev/null +++ b/lib/api/reviews.ts @@ -0,0 +1,13 @@ +import { mockReviews } from "@/lib/mock" + +export function listReviews() { + return mockReviews +} + +export function listReviewsByOrder(orderId: string) { + return mockReviews.filter((review) => review.orderId === orderId) +} + +export function listReviewsByTargetUser(userId: string) { + return mockReviews.filter((review) => review.toUserId === userId) +} diff --git a/lib/api/services.ts b/lib/api/services.ts new file mode 100644 index 0000000..b12c6e5 --- /dev/null +++ b/lib/api/services.ts @@ -0,0 +1,13 @@ +import { useServiceStore } from "@/store/services" + +export function listServices() { + return useServiceStore.getState().services +} + +export function getServiceById(serviceId: string) { + return useServiceStore.getState().services.find((service) => service.id === serviceId) +} + +export function listServicesByPlayer(playerId: string) { + return useServiceStore.getState().services.filter((service) => service.playerId === playerId) +} diff --git a/lib/api/shops.ts b/lib/api/shops.ts new file mode 100644 index 0000000..573c724 --- /dev/null +++ b/lib/api/shops.ts @@ -0,0 +1,13 @@ +import { useShopStore } from "@/store/shops" + +export function listShops() { + return useShopStore.getState().shops +} + +export function getShopById(shopId: string) { + return useShopStore.getState().shops.find((shop) => shop.id === shopId) +} + +export function getShopByOwnerId(ownerId: string) { + return useShopStore.getState().shops.find((shop) => shop.owner.id === ownerId) +} diff --git a/lib/api/transactions.ts b/lib/api/transactions.ts new file mode 100644 index 0000000..195ead5 --- /dev/null +++ b/lib/api/transactions.ts @@ -0,0 +1,5 @@ +import { mockTransactions } from "@/lib/mock" + +export function listTransactions() { + return mockTransactions +} diff --git a/lib/api/users.ts b/lib/api/users.ts new file mode 100644 index 0000000..938269a --- /dev/null +++ b/lib/api/users.ts @@ -0,0 +1,13 @@ +import { currentUser, mockUsers } from "@/lib/mock" + +export function listUsers() { + return mockUsers +} + +export function getUserById(userId: string) { + return mockUsers.find((user) => user.id === userId) +} + +export function getCurrentUserForLogin() { + return currentUser +} diff --git a/lib/id.ts b/lib/id.ts new file mode 100644 index 0000000..a2f6c11 --- /dev/null +++ b/lib/id.ts @@ -0,0 +1,6 @@ +let counter = 0 + +export function generateId(prefix: string) { + counter += 1 + return `${prefix}-${Date.now()}-${counter}` +} diff --git a/lib/toast.ts b/lib/toast.ts new file mode 100644 index 0000000..d5c3090 --- /dev/null +++ b/lib/toast.ts @@ -0,0 +1,9 @@ +import { toast } from "sonner" + +export function notifySuccess(message: string) { + toast.success(message) +} + +export function notifyInfo(message: string) { + toast(message) +} diff --git a/package.json b/package.json index 1825d78..a171100 100644 --- a/package.json +++ b/package.json @@ -25,6 +25,7 @@ "react": "19.2.3", "react-dom": "19.2.3", "react-hook-form": "^7.71.1", + "sonner": "^2.0.7", "tailwind-merge": "^3.5.0", "zod": "^4.3.6", "zustand": "^5.0.11" diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 35f7d68..c0fe986 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -44,6 +44,9 @@ importers: react-hook-form: specifier: ^7.71.1 version: 7.71.1(react@19.2.3) + sonner: + specifier: ^2.0.7 + version: 2.0.7(react-dom@19.2.3(react@19.2.3))(react@19.2.3) tailwind-merge: specifier: ^3.5.0 version: 3.5.0 @@ -243,28 +246,24 @@ packages: engines: {node: '>=14.21.3'} cpu: [arm64] os: [linux] - libc: [musl] '@biomejs/cli-linux-arm64@2.4.3': resolution: {integrity: sha512-0m+O0x9FgK99FAwDK+fiDtjs2wnqq7bvfj17KJVeCkTwT/liI+Q9njJG7lwXK0iSJVXeFNRIxukpVI3SifMYAA==} engines: {node: '>=14.21.3'} cpu: [arm64] os: [linux] - libc: [glibc] '@biomejs/cli-linux-x64-musl@2.4.3': resolution: {integrity: sha512-qEc0OCpj/uytruQ4wLM0yWNJLZy0Up8H1Er5MW3SrstqM6J2d4XqdNA86xzCy8MQCHpoVZ3lFye3GBlIL4/ljw==} engines: {node: '>=14.21.3'} cpu: [x64] os: [linux] - libc: [musl] '@biomejs/cli-linux-x64@2.4.3': resolution: {integrity: sha512-NVqh0saIU0u5OfOp/0jFdlKRE59+XyMvWmtx0f6Nm/2OpdxBl04coRIftBbY9d1gfu+23JVv4CItAqPYrjYh5w==} engines: {node: '>=14.21.3'} cpu: [x64] os: [linux] - libc: [glibc] '@biomejs/cli-win32-arm64@2.4.3': resolution: {integrity: sha512-gRO96vrIARilv/Cp2ZnmNNL5LSZg3RO75GPp13hsLO3N4YVpE7saaMDp2bcyV48y2N2Pbit1brkGVGta0yd6VQ==} @@ -347,105 +346,89 @@ packages: resolution: {integrity: sha512-excjX8DfsIcJ10x1Kzr4RcWe1edC9PquDRRPx3YVCvQv+U5p7Yin2s32ftzikXojb1PIFc/9Mt28/y+iRklkrw==} cpu: [arm64] os: [linux] - libc: [glibc] '@img/sharp-libvips-linux-arm@1.2.4': resolution: {integrity: sha512-bFI7xcKFELdiNCVov8e44Ia4u2byA+l3XtsAj+Q8tfCwO6BQ8iDojYdvoPMqsKDkuoOo+X6HZA0s0q11ANMQ8A==} cpu: [arm] os: [linux] - libc: [glibc] '@img/sharp-libvips-linux-ppc64@1.2.4': resolution: {integrity: sha512-FMuvGijLDYG6lW+b/UvyilUWu5Ayu+3r2d1S8notiGCIyYU/76eig1UfMmkZ7vwgOrzKzlQbFSuQfgm7GYUPpA==} cpu: [ppc64] os: [linux] - libc: [glibc] '@img/sharp-libvips-linux-riscv64@1.2.4': resolution: {integrity: sha512-oVDbcR4zUC0ce82teubSm+x6ETixtKZBh/qbREIOcI3cULzDyb18Sr/Wcyx7NRQeQzOiHTNbZFF1UwPS2scyGA==} cpu: [riscv64] os: [linux] - libc: [glibc] '@img/sharp-libvips-linux-s390x@1.2.4': resolution: {integrity: sha512-qmp9VrzgPgMoGZyPvrQHqk02uyjA0/QrTO26Tqk6l4ZV0MPWIW6LTkqOIov+J1yEu7MbFQaDpwdwJKhbJvuRxQ==} cpu: [s390x] os: [linux] - libc: [glibc] '@img/sharp-libvips-linux-x64@1.2.4': resolution: {integrity: sha512-tJxiiLsmHc9Ax1bz3oaOYBURTXGIRDODBqhveVHonrHJ9/+k89qbLl0bcJns+e4t4rvaNBxaEZsFtSfAdquPrw==} cpu: [x64] os: [linux] - libc: [glibc] '@img/sharp-libvips-linuxmusl-arm64@1.2.4': resolution: {integrity: sha512-FVQHuwx1IIuNow9QAbYUzJ+En8KcVm9Lk5+uGUQJHaZmMECZmOlix9HnH7n1TRkXMS0pGxIJokIVB9SuqZGGXw==} cpu: [arm64] os: [linux] - libc: [musl] '@img/sharp-libvips-linuxmusl-x64@1.2.4': resolution: {integrity: sha512-+LpyBk7L44ZIXwz/VYfglaX/okxezESc6UxDSoyo2Ks6Jxc4Y7sGjpgU9s4PMgqgjj1gZCylTieNamqA1MF7Dg==} cpu: [x64] os: [linux] - libc: [musl] '@img/sharp-linux-arm64@0.34.5': resolution: {integrity: sha512-bKQzaJRY/bkPOXyKx5EVup7qkaojECG6NLYswgktOZjaXecSAeCWiZwwiFf3/Y+O1HrauiE3FVsGxFg8c24rZg==} engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0} cpu: [arm64] os: [linux] - libc: [glibc] '@img/sharp-linux-arm@0.34.5': resolution: {integrity: sha512-9dLqsvwtg1uuXBGZKsxem9595+ujv0sJ6Vi8wcTANSFpwV/GONat5eCkzQo/1O6zRIkh0m/8+5BjrRr7jDUSZw==} engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0} cpu: [arm] os: [linux] - libc: [glibc] '@img/sharp-linux-ppc64@0.34.5': resolution: {integrity: sha512-7zznwNaqW6YtsfrGGDA6BRkISKAAE1Jo0QdpNYXNMHu2+0dTrPflTLNkpc8l7MUP5M16ZJcUvysVWWrMefZquA==} engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0} cpu: [ppc64] os: [linux] - libc: [glibc] '@img/sharp-linux-riscv64@0.34.5': resolution: {integrity: sha512-51gJuLPTKa7piYPaVs8GmByo7/U7/7TZOq+cnXJIHZKavIRHAP77e3N2HEl3dgiqdD/w0yUfiJnII77PuDDFdw==} engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0} cpu: [riscv64] os: [linux] - libc: [glibc] '@img/sharp-linux-s390x@0.34.5': resolution: {integrity: sha512-nQtCk0PdKfho3eC5MrbQoigJ2gd1CgddUMkabUj+rBevs8tZ2cULOx46E7oyX+04WGfABgIwmMC0VqieTiR4jg==} engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0} cpu: [s390x] os: [linux] - libc: [glibc] '@img/sharp-linux-x64@0.34.5': resolution: {integrity: sha512-MEzd8HPKxVxVenwAa+JRPwEC7QFjoPWuS5NZnBt6B3pu7EG2Ge0id1oLHZpPJdn3OQK+BQDiw9zStiHBTJQQQQ==} engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0} cpu: [x64] os: [linux] - libc: [glibc] '@img/sharp-linuxmusl-arm64@0.34.5': resolution: {integrity: sha512-fprJR6GtRsMt6Kyfq44IsChVZeGN97gTD331weR1ex1c1rypDEABN6Tm2xa1wE6lYb5DdEnk03NZPqA7Id21yg==} engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0} cpu: [arm64] os: [linux] - libc: [musl] '@img/sharp-linuxmusl-x64@0.34.5': resolution: {integrity: sha512-Jg8wNT1MUzIvhBFxViqrEhWDGzqymo3sV7z7ZsaWbZNDLXRJZoRGrjulp60YYtV4wfY8VIKcWidjojlLcWrd8Q==} engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0} cpu: [x64] os: [linux] - libc: [musl] '@img/sharp-wasm32@0.34.5': resolution: {integrity: sha512-OdWTEiVkY2PHwqkbBI8frFxQQFekHaSSkUIJkwzclWZe64O1X4UlUjqqqLaPbUpMOQk6FBu/HtlGXNblIs0huw==} @@ -555,28 +538,24 @@ packages: engines: {node: '>= 10'} cpu: [arm64] os: [linux] - libc: [glibc] '@next/swc-linux-arm64-musl@16.1.6': resolution: {integrity: sha512-S4J2v+8tT3NIO9u2q+S0G5KdvNDjXfAv06OhfOzNDaBn5rw84DGXWndOEB7d5/x852A20sW1M56vhC/tRVbccQ==} engines: {node: '>= 10'} cpu: [arm64] os: [linux] - libc: [musl] '@next/swc-linux-x64-gnu@16.1.6': resolution: {integrity: sha512-2eEBDkFlMMNQnkTyPBhQOAyn2qMxyG2eE7GPH2WIDGEpEILcBPI/jdSv4t6xupSP+ot/jkfrCShLAa7+ZUPcJQ==} engines: {node: '>= 10'} cpu: [x64] os: [linux] - libc: [glibc] '@next/swc-linux-x64-musl@16.1.6': resolution: {integrity: sha512-oicJwRlyOoZXVlxmIMaTq7f8pN9QNbdes0q2FXfRsPhfCi8n8JmOZJm5oo1pwDaFbnnD421rVU409M3evFbIqg==} engines: {node: '>= 10'} cpu: [x64] os: [linux] - libc: [musl] '@next/swc-win32-arm64-msvc@16.1.6': resolution: {integrity: sha512-gQmm8izDTPgs+DCWH22kcDmuUp7NyiJgEl18bcr8irXA5N2m2O+JQIr6f3ct42GOs9c0h8QF3L5SzIxcYAAXXw==} @@ -1367,28 +1346,24 @@ packages: engines: {node: '>= 20'} cpu: [arm64] os: [linux] - libc: [glibc] '@tailwindcss/oxide-linux-arm64-musl@4.2.0': resolution: {integrity: sha512-XKcSStleEVnbH6W/9DHzZv1YhjE4eSS6zOu2eRtYAIh7aV4o3vIBs+t/B15xlqoxt6ef/0uiqJVB6hkHjWD/0A==} engines: {node: '>= 20'} cpu: [arm64] os: [linux] - libc: [musl] '@tailwindcss/oxide-linux-x64-gnu@4.2.0': resolution: {integrity: sha512-/hlXCBqn9K6fi7eAM0RsobHwJYa5V/xzWspVTzxnX+Ft9v6n+30Pz8+RxCn7sQL/vRHHLS30iQPrHQunu6/vJA==} engines: {node: '>= 20'} cpu: [x64] os: [linux] - libc: [glibc] '@tailwindcss/oxide-linux-x64-musl@4.2.0': resolution: {integrity: sha512-lKUaygq4G7sWkhQbfdRRBkaq4LY39IriqBQ+Gk6l5nKq6Ay2M2ZZb1tlIyRNgZKS8cbErTwuYSor0IIULC0SHw==} engines: {node: '>= 20'} cpu: [x64] os: [linux] - libc: [musl] '@tailwindcss/oxide-wasm32-wasi@4.2.0': resolution: {integrity: sha512-xuDjhAsFdUuFP5W9Ze4k/o4AskUtI8bcAGU4puTYprr89QaYFmhYOPfP+d1pH+k9ets6RoE23BXZM1X1jJqoyw==} @@ -2120,28 +2095,24 @@ packages: engines: {node: '>= 12.0.0'} cpu: [arm64] os: [linux] - libc: [glibc] lightningcss-linux-arm64-musl@1.31.1: resolution: {integrity: sha512-mVZ7Pg2zIbe3XlNbZJdjs86YViQFoJSpc41CbVmKBPiGmC4YrfeOyz65ms2qpAobVd7WQsbW4PdsSJEMymyIMg==} engines: {node: '>= 12.0.0'} cpu: [arm64] os: [linux] - libc: [musl] lightningcss-linux-x64-gnu@1.31.1: resolution: {integrity: sha512-xGlFWRMl+0KvUhgySdIaReQdB4FNudfUTARn7q0hh/V67PVGCs3ADFjw+6++kG1RNd0zdGRlEKa+T13/tQjPMA==} engines: {node: '>= 12.0.0'} cpu: [x64] os: [linux] - libc: [glibc] lightningcss-linux-x64-musl@1.31.1: resolution: {integrity: sha512-eowF8PrKHw9LpoZii5tdZwnBcYDxRw2rRCyvAXLi34iyeYfqCQNA9rmUM0ce62NlPhCvof1+9ivRaTY6pSKDaA==} engines: {node: '>= 12.0.0'} cpu: [x64] os: [linux] - libc: [musl] lightningcss-win32-arm64-msvc@1.31.1: resolution: {integrity: sha512-aJReEbSEQzx1uBlQizAOBSjcmr9dCdL3XuC/6HLXAxmtErsj2ICo5yYggg1qOODQMtnjNQv2UHb9NpOuFtYe4w==} @@ -2586,6 +2557,12 @@ packages: sisteransi@1.0.5: resolution: {integrity: sha512-bLGGlR1QxBcynn2d5YmDX4MGjlZvy2MRBDRNHLJ8VI6l6+9FUiyTFNJ0IveOSP0bcXgVDPRcfGqA0pjaqUpfVg==} + sonner@2.0.7: + resolution: {integrity: sha512-W6ZN4p58k8aDKA4XPcx2hpIQXBRAgyiWVkYhT7CvK6D3iAu7xjvVyhQHg2/iaKJZ1XVJ4r7XuwGL+WGEK37i9w==} + peerDependencies: + react: ^18.0.0 || ^19.0.0 || ^19.0.0-rc + react-dom: ^18.0.0 || ^19.0.0 || ^19.0.0-rc + source-map-js@1.2.1: resolution: {integrity: sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA==} engines: {node: '>=0.10.0'} @@ -5377,6 +5354,11 @@ snapshots: sisteransi@1.0.5: {} + sonner@2.0.7(react-dom@19.2.3(react@19.2.3))(react@19.2.3): + dependencies: + react: 19.2.3 + react-dom: 19.2.3(react@19.2.3) + source-map-js@1.2.1: {} source-map@0.6.1: {} diff --git a/store/chat.ts b/store/chat.ts index 9dd210b..f98c6fb 100644 --- a/store/chat.ts +++ b/store/chat.ts @@ -1,4 +1,5 @@ import { create } from "zustand" +import { generateId } from "@/lib/id" import { mockChatMessages, mockChatSessions, mockUsers } from "@/lib/mock" import type { ChatMessage, ChatSession, Order } from "@/lib/types" @@ -76,7 +77,7 @@ export const useChatStore = create((set, get) => ({ const now = new Date().toISOString() const message: ChatMessage = { - id: `msg-${Date.now()}`, + id: generateId("msg"), sessionId, senderId: sender.id, senderName: sender.name, diff --git a/store/orders.ts b/store/orders.ts index 5c58b17..0de22f8 100644 --- a/store/orders.ts +++ b/store/orders.ts @@ -1,4 +1,5 @@ import { create } from "zustand" +import { generateId } from "@/lib/id" import { mockOrders } from "@/lib/mock" import type { Order, OrderStatus, PlayerService } from "@/lib/types" @@ -25,7 +26,7 @@ export const useOrderStore = create((set) => ({ orders: mockOrders, createOrder: (input) => { const order: Order = { - id: `ord${Date.now()}`, + id: generateId("ord"), consumerId: input.consumerId, consumerName: input.consumerName, playerId: input.playerId, diff --git a/store/services.ts b/store/services.ts index c949693..f0be479 100644 --- a/store/services.ts +++ b/store/services.ts @@ -1,4 +1,5 @@ import { create } from "zustand" +import { generateId } from "@/lib/id" import { mockServices } from "@/lib/mock" import type { PlayerService } from "@/lib/types" @@ -17,7 +18,7 @@ export const useServiceStore = create((set) => ({ ...state.services, { ...service, - id: `s${Date.now()}`, + id: generateId("svc"), }, ], })),