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:
@@ -1,5 +1,6 @@
|
||||
import express from 'express';
|
||||
import fetch from 'node-fetch';
|
||||
import { emitMatchReportSubmitted } from '../services/socketService.js';
|
||||
|
||||
const router = express.Router();
|
||||
|
||||
@@ -256,6 +257,12 @@ router.put('/submit/:uuid', async (req, res) => {
|
||||
'Cache-Control': 'no-cache, no-store, must-revalidate'
|
||||
});
|
||||
|
||||
const clubId = reportData.clubId;
|
||||
const matchCode = reportData.gameCode || reportData.code;
|
||||
if (clubId && (matchCode || uuid)) {
|
||||
emitMatchReportSubmitted(clubId, matchCode || uuid, reportData);
|
||||
}
|
||||
|
||||
res.json({
|
||||
success: true,
|
||||
data: responseData,
|
||||
@@ -271,6 +278,17 @@ router.put('/submit/:uuid', async (req, res) => {
|
||||
}
|
||||
});
|
||||
|
||||
// Nur Broadcast: aktueller Spielberichtsentwurf (z. B. Satzergebnisse) an andere Clients senden, ohne bei nuscore zu speichern
|
||||
router.post('/broadcast-draft', (req, res) => {
|
||||
const { clubId, gameCode, matchData } = req.body || {};
|
||||
if (!clubId || !(gameCode ?? matchData?.gameCode ?? matchData?.code)) {
|
||||
return res.status(400).json({ error: 'clubId und gameCode erforderlich' });
|
||||
}
|
||||
const code = String(gameCode ?? matchData?.gameCode ?? matchData?.code ?? '');
|
||||
emitMatchReportSubmitted(clubId, code, matchData || null);
|
||||
res.json({ ok: true });
|
||||
});
|
||||
|
||||
// Validate Meeting Report API-Endpunkt (für Zwischenspeicherung)
|
||||
router.put('/validate/:uuid', async (req, res) => {
|
||||
const { uuid } = req.params;
|
||||
|
||||
Reference in New Issue
Block a user