feat: player status store for online/busy/available state management

This commit is contained in:
zetaloop
2026-02-20 18:51:01 +08:00
parent 922d656056
commit 60eafc571d
+23
View File
@@ -0,0 +1,23 @@
import { create } from "zustand"
import type { Player } from "@/lib/types"
type PlayerStatus = Player["status"]
interface PlayerStatusState {
statuses: Record<string, PlayerStatus>
setStatus: (playerId: string, status: PlayerStatus) => void
getStatus: (playerId: string) => PlayerStatus | undefined
}
export const usePlayerStatusStore = create<PlayerStatusState>((set, get) => ({
statuses: {
u2: "available",
u4: "busy",
u5: "available",
},
setStatus: (playerId, status) =>
set((state) => ({
statuses: { ...state.statuses, [playerId]: status },
})),
getStatus: (playerId) => get().statuses[playerId],
}))