From 60eafc571d87b1c19dbbf74c824d0fdfc4c8842f Mon Sep 17 00:00:00 2001 From: zetaloop Date: Fri, 20 Feb 2026 18:51:01 +0800 Subject: [PATCH] feat: player status store for online/busy/available state management --- store/player-status.ts | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 store/player-status.ts 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], +}))