diff --git a/store/player-status.ts b/store/player-status.ts new file mode 100644 index 0000000..cd0d500 --- /dev/null +++ b/store/player-status.ts @@ -0,0 +1,23 @@ +import { create } from "zustand" +import type { Player } from "@/lib/types" + +type PlayerStatus = Player["status"] + +interface PlayerStatusState { + statuses: Record + setStatus: (playerId: string, status: PlayerStatus) => void + getStatus: (playerId: string) => PlayerStatus | undefined +} + +export const usePlayerStatusStore = create((set, get) => ({ + statuses: { + u2: "available", + u4: "busy", + u5: "available", + }, + setStatus: (playerId, status) => + set((state) => ({ + statuses: { ...state.statuses, [playerId]: status }, + })), + getStatus: (playerId) => get().statuses[playerId], +}))