Add nomination submission and bidding start workflow
- Added `BID_START_REQUEST` and `NOMINATION_SUBMIT_REQUEST` handling in backend consumers. - Extended draft state to include `current_movie` and `bids` cache keys. - Updated frontend to: - Allow participants to nominate movies when it's their turn. - Enable admins to start bidding for the nominated movie. - Highlight the current nominated movie and the current user. - Synced state updates across clients via WebSocket events.
This commit is contained in:
@@ -6,6 +6,7 @@ import { ParticipantList } from "../common/ParticipantList.jsx";
|
||||
import { DraftMessage, DraftPhase, DraftPhaseLabel, DraftPhasesOrdered } from '../constants.js';
|
||||
import { fetchDraftDetails, isEmptyObject, handleDraftStatusMessages, handleUserIdentifyMessages } from "../common/utils.js"
|
||||
import { DraftMoviePool } from "../common/DraftMoviePool.jsx"
|
||||
import { jsxs } from "react/jsx-runtime";
|
||||
|
||||
|
||||
|
||||
@@ -65,12 +66,28 @@ export const DraftAdmin = ({ draftSessionId }) => {
|
||||
|
||||
const draftStatusMessageHandler = (event) => handleDraftStatusMessages(event, setDraftState)
|
||||
const userIdentifyMessageHandler = (event) => handleUserIdentifyMessages(event, setCurrentUser)
|
||||
const handleNominationRequest = (event)=> {
|
||||
const message = JSON.parse(event.data)
|
||||
const { type, payload } = message;
|
||||
console.log('passing through nomination request', message)
|
||||
if (type == DraftMessage.NOMINATION_SUBMIT_REQUEST) {
|
||||
socket.send(JSON.stringify(
|
||||
{
|
||||
type: DraftMessage.NOMINATION_SUBMIT_REQUEST,
|
||||
payload
|
||||
}
|
||||
))
|
||||
}
|
||||
}
|
||||
socket.addEventListener('message', draftStatusMessageHandler );
|
||||
socket.addEventListener('message', userIdentifyMessageHandler );
|
||||
socket.addEventListener('message', handleNominationRequest );
|
||||
|
||||
|
||||
return () => {
|
||||
socket.removeEventListener('message', draftStatusMessageHandler)
|
||||
socket.removeEventListener('message', userIdentifyMessageHandler );
|
||||
socket.remove('message', handleNominationRequest );
|
||||
};
|
||||
}, [socket]);
|
||||
|
||||
@@ -114,6 +131,14 @@ export const DraftAdmin = ({ draftSessionId }) => {
|
||||
)
|
||||
}
|
||||
|
||||
const handleStartBidding = () => {
|
||||
socket.send(
|
||||
JSON.stringify(
|
||||
{type: DraftMessage.BID_START_REQUEST}
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="container draft-panel admin">
|
||||
<div className="d-flex justify-content-between border-bottom mb-2 p-1">
|
||||
@@ -127,12 +152,16 @@ export const DraftAdmin = ({ draftSessionId }) => {
|
||||
</div>
|
||||
|
||||
<ParticipantList
|
||||
currentUser = {currentUser}
|
||||
draftState={draftState}
|
||||
draftDetails={draftDetails}
|
||||
isAdmin={true}
|
||||
/>
|
||||
<button onClick={handleAdvanceDraft} className="btn btn-primary">Advance Draft</button>
|
||||
<DraftMoviePool draftDetails={draftDetails}></DraftMoviePool>
|
||||
<div className="d-flex gap-1 m-1">
|
||||
<button onClick={handleAdvanceDraft} className="btn btn-primary">Advance Draft</button>
|
||||
<button onClick={handleStartBidding} className="btn btn-primary">Start Bidding</button>
|
||||
</div>
|
||||
<DraftMoviePool draftDetails={draftDetails} draftState={draftState}></DraftMoviePool>
|
||||
|
||||
<DraftPhaseDisplay draftPhase={draftState.phase} nextPhaseHandler={() => { handlePhaseChange('next') }} prevPhaseHandler={() => { handlePhaseChange('previous') }}></DraftPhaseDisplay>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user