feat: team indeling endpoint + proposed_teams field

This commit is contained in:
root
2026-05-25 08:29:01 +00:00
parent 099908c303
commit 558544e461
2 changed files with 31 additions and 2 deletions
+8 -2
View File
@@ -286,11 +286,11 @@ function updateMatch(id, match) {
// Build SET dynamically to only update provided fields
const fields = [];
const values = [];
for (const key of ['status', 'responses', 'proposed_at', 'date', 'start', 'end', 'location', 'day', 'score', 'booker_id', 'booker_name']) {
for (const key of ['status', 'responses', 'proposed_at', 'date', 'start', 'end', 'location', 'day', 'score', 'booker_id', 'booker_name', 'proposed_teams']) {
if (match[key] !== undefined) {
fields.push(`${key}=?`);
let val = merged[key];
if (key === 'responses' || (key === 'score' && typeof val === 'object' && val !== null)) {
if (key === 'responses' || key === 'score' || key === 'proposed_teams') {
val = JSON.stringify(val);
}
values.push(key === 'booker_id' || key === 'booker_name' ? String(val) : val);
@@ -446,6 +446,11 @@ function rowToMatch(r) {
try { score = JSON.parse(r.score); } catch (e) { /* ignore */ }
}
let proposed_teams = null;
if (r.proposed_teams) {
try { proposed_teams = JSON.parse(r.proposed_teams); } catch (e) { /* ignore */ }
}
return {
id: r.id,
status: r.status,
@@ -457,6 +462,7 @@ function rowToMatch(r) {
location: r.location,
day: r.day,
score: score,
proposed_teams: proposed_teams,
booker_id: r.booker_id || null,
booker_name: r.booker_name || null,
players: players