feat(socket): implement match report submission and schedule update events
- Added WebSocket events for match report submission and schedule updates, enhancing real-time communication between clients and the server. - Updated matchController to emit schedule updates when match players are modified. - Enhanced nuscoreApiRoutes to emit match report submissions with relevant data for other clients. - Implemented socket service methods for handling incoming match report submissions and schedule updates in the frontend. - Updated MatchReportApiDialog and ScheduleView components to handle new WebSocket events, ensuring data synchronization across clients.
This commit is contained in:
@@ -467,12 +467,56 @@ class MatchService {
|
||||
playersPlanned: plannedList !== null ? plannedList : (match.playersPlanned || []),
|
||||
playersPlayed: playedList !== null ? playedList : (match.playersPlayed || [])
|
||||
});
|
||||
|
||||
|
||||
// Aktualisiertes Match nochmals laden und für WebSocket-Broadcast anreichern (gleiche Struktur wie getMatchesForLeague)
|
||||
const updated = await Match.findByPk(matchId);
|
||||
const enriched = {
|
||||
id: updated.id,
|
||||
date: updated.date,
|
||||
time: updated.time,
|
||||
homeTeamId: updated.homeTeamId,
|
||||
guestTeamId: updated.guestTeamId,
|
||||
locationId: updated.locationId,
|
||||
leagueId: updated.leagueId,
|
||||
code: updated.code,
|
||||
homePin: updated.homePin,
|
||||
guestPin: updated.guestPin,
|
||||
homeMatchPoints: updated.homeMatchPoints || 0,
|
||||
guestMatchPoints: updated.guestMatchPoints || 0,
|
||||
isCompleted: updated.isCompleted || false,
|
||||
pdfUrl: updated.pdfUrl,
|
||||
playersReady: updated.playersReady || [],
|
||||
playersPlanned: updated.playersPlanned || [],
|
||||
playersPlayed: updated.playersPlayed || [],
|
||||
homeTeam: { name: 'Unbekannt' },
|
||||
guestTeam: { name: 'Unbekannt' },
|
||||
location: { name: 'Unbekannt', address: '', city: '', zip: '' },
|
||||
leagueDetails: { name: 'Unbekannt' }
|
||||
};
|
||||
if (updated.homeTeamId) {
|
||||
const homeTeam = await Team.findByPk(updated.homeTeamId, { attributes: ['name'] });
|
||||
if (homeTeam) enriched.homeTeam = homeTeam;
|
||||
}
|
||||
if (updated.guestTeamId) {
|
||||
const guestTeam = await Team.findByPk(updated.guestTeamId, { attributes: ['name'] });
|
||||
if (guestTeam) enriched.guestTeam = guestTeam;
|
||||
}
|
||||
if (updated.locationId) {
|
||||
const location = await Location.findByPk(updated.locationId, { attributes: ['name', 'address', 'city', 'zip'] });
|
||||
if (location) enriched.location = location;
|
||||
}
|
||||
if (updated.leagueId) {
|
||||
const league = await League.findByPk(updated.leagueId, { attributes: ['name'] });
|
||||
if (league) enriched.leagueDetails = league;
|
||||
}
|
||||
|
||||
return {
|
||||
id: match.id,
|
||||
playersReady: match.playersReady,
|
||||
playersPlanned: match.playersPlanned,
|
||||
playersPlayed: match.playersPlayed
|
||||
id: updated.id,
|
||||
clubId: updated.clubId,
|
||||
playersReady: updated.playersReady,
|
||||
playersPlanned: updated.playersPlanned,
|
||||
playersPlayed: updated.playersPlayed,
|
||||
match: enriched
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -225,3 +225,13 @@ export const emitTournamentChanged = (clubId, tournamentId) => {
|
||||
emitToClub(clubId, 'tournament:changed', { tournamentId });
|
||||
};
|
||||
|
||||
// Event wenn Spielerauswahl (Bereit/Geplant/Gespielt) für ein Match geändert wurde (match = vollständiges angereichertes Match-Objekt)
|
||||
export const emitScheduleMatchUpdated = (clubId, matchId, match = null) => {
|
||||
emitToClub(clubId, 'schedule:match:updated', { clubId, matchId, match });
|
||||
};
|
||||
|
||||
// Event wenn Spielbericht (nuscore) abgesendet wurde – matchData = vollständiges Objekt für andere Clients
|
||||
export const emitMatchReportSubmitted = (clubId, matchCode, matchData = null) => {
|
||||
emitToClub(clubId, 'schedule:match-report:submitted', { clubId, matchCode, matchData });
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user