feat: connect dashboard shop pages to mutable state

This commit is contained in:
zetaloop
2026-02-21 15:49:42 +08:00
parent 94b96ac577
commit 6469811382
6 changed files with 210 additions and 20 deletions
+25
View File
@@ -0,0 +1,25 @@
import { create } from "zustand"
import { mockPlayers } from "@/lib/mock"
import type { Player } from "@/lib/types"
interface PlayerState {
players: Player[]
assignToShop: (playerId: string, shopId: string, shopName: string) => void
removeFromShop: (playerId: string) => void
}
export const usePlayerStore = create<PlayerState>((set) => ({
players: mockPlayers,
assignToShop: (playerId, shopId, shopName) =>
set((state) => ({
players: state.players.map((player) =>
player.id === playerId ? { ...player, shopId, shopName } : player,
),
})),
removeFromShop: (playerId) =>
set((state) => ({
players: state.players.map((player) =>
player.id === playerId ? { ...player, shopId: undefined, shopName: undefined } : player,
),
})),
}))