Add timed bidding support with countdown displays and debug view
- Added `bidding_duration` field to `DraftSessionSettings` model and migration. - Updated `DraftStateManager` to manage bidding start/end times using session settings. - Extended WebSocket payloads to include bidding timer data. - Added `DraftCountdownClock` React component and integrated into admin and participant UIs. - Created new `DraftDebug` view, template, and front-end component for real-time state debugging. - Updated utility functions to handle new timer fields in draft state. - Changed script tags in templates to load with `defer` for non-blocking execution.
This commit is contained in:
45
frontend/src/apps/draft/DraftDebug.jsx
Normal file
45
frontend/src/apps/draft/DraftDebug.jsx
Normal file
@@ -0,0 +1,45 @@
|
||||
import React, { useEffect, useState } from "react";;
|
||||
import { useWebSocket } from "./WebSocketContext.jsx";
|
||||
import { DraftMessage, DraftPhase, DraftPhaseLabel, DraftPhasesOrdered } from './constants.js';
|
||||
import { fetchDraftDetails, isEmptyObject, handleDraftStatusMessages, handleUserIdentifyMessages } from "./common/utils.js"
|
||||
|
||||
export const DraftDebug = ({ draftSessionId }) => {
|
||||
const [draftState, setDraftState] = useState({})
|
||||
const socket = useWebSocket();
|
||||
if (!socket) return;
|
||||
|
||||
useEffect(() => {
|
||||
if (!socket) return;
|
||||
const openHandler = (event) => {
|
||||
console.log('Websocket Opened')
|
||||
}
|
||||
const closeHandler = (event) => {
|
||||
console.log('Websocket Closed')
|
||||
}
|
||||
socket.addEventListener('open', openHandler);
|
||||
socket.addEventListener('close', closeHandler);
|
||||
return () => {
|
||||
socket.removeEventListener('open', openHandler);
|
||||
socket.removeEventListener('close', closeHandler);
|
||||
}
|
||||
}, [socket])
|
||||
|
||||
useEffect(() => {
|
||||
if (!socket) return;
|
||||
|
||||
const draftStatusMessageHandler = (event) => handleDraftStatusMessages(event, setDraftState)
|
||||
|
||||
socket.addEventListener('message', draftStatusMessageHandler);
|
||||
|
||||
|
||||
return () => {
|
||||
socket.removeEventListener('message', draftStatusMessageHandler)
|
||||
};
|
||||
}, [socket]);
|
||||
const data = { 'message': 'test' }
|
||||
return (<pre style={{margin: "1em"}}>
|
||||
{JSON.stringify(draftState, null, 2)}
|
||||
</pre>
|
||||
)
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user