feat: match_type (ranked/friendly) + /api/matches/:id/type endpoint
This commit is contained in:
@@ -383,7 +383,20 @@ app.get("/api/matches/:id/teams", (req, res) => {
|
||||
const m = db.getMatch(String(req.params.id));
|
||||
if (!m) return res.status(404).json({ error: "match not found" });
|
||||
const teams = m.proposed_teams || null;
|
||||
res.json({ teams, match: { id: m.id, date: m.date, start: m.start, status: m.status } });
|
||||
res.json({ teams, match: { id: m.id, date: m.date, start: m.start, status: m.status, match_type: m.match_type || 'friendly' } });
|
||||
});
|
||||
|
||||
// ─── MATCH TYPE (ranked/friendly) ───
|
||||
app.post("/api/matches/:id/type", (req, res) => {
|
||||
let m = db.getMatch(String(req.params.id));
|
||||
if (!m) return res.status(404).json({ error: "match not found" });
|
||||
const { match_type } = req.body;
|
||||
if (match_type !== 'ranked' && match_type !== 'friendly')
|
||||
return res.status(400).json({ error: "match_type must be 'ranked' or 'friendly'" });
|
||||
db.updateMatch(String(req.params.id), { match_type });
|
||||
m = db.getMatch(String(req.params.id));
|
||||
const playerIds = (m.players || []).map(p => p.id);
|
||||
res.json({ ...m, players: playerIds, players_array: m.players });
|
||||
});
|
||||
|
||||
// ─── SCORES ───
|
||||
|
||||
Reference in New Issue
Block a user