From 994b88306c409579d927f76b513cc9ee6c66cc6e Mon Sep 17 00:00:00 2001 From: Studio-18 Date: Sat, 22 Nov 2025 09:40:24 -0800 Subject: [PATCH 1/5] Clarify create match payload --- src/api/matches.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/api/matches.ts b/src/api/matches.ts index 0d657fef..6952d71f 100644 --- a/src/api/matches.ts +++ b/src/api/matches.ts @@ -216,6 +216,7 @@ export const createMatch = async ({ }: CreateMatchParams) => { const status = "upcoming"; const matchType = privacy === "private" ? "private" : "open"; + const defaultVisibility = matchType === "open" ? "open" : "private"; const payload: Record = { status, @@ -223,6 +224,10 @@ export const createMatch = async ({ location_text: locationText, location: locationText, listing_visibility: "listed", + hidden: false, + is_hidden: false, + visibility: defaultVisibility, + match_visibility: defaultVisibility, }; const startIso = toIsoString(startDateTime); From 2becdbd4fff1c115b5616a55e3d77d7be766c343 Mon Sep 17 00:00:00 2001 From: Studio-18 Date: Sat, 22 Nov 2025 12:37:41 -0800 Subject: [PATCH 2/5] Improve match creation payload defaults --- src/api/matches.ts | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/api/matches.ts b/src/api/matches.ts index 6952d71f..c91f1487 100644 --- a/src/api/matches.ts +++ b/src/api/matches.ts @@ -217,13 +217,14 @@ export const createMatch = async ({ const status = "upcoming"; const matchType = privacy === "private" ? "private" : "open"; const defaultVisibility = matchType === "open" ? "open" : "private"; + const listingVisibility = matchType === "open" ? "listed" : "private"; const payload: Record = { status, match_type: matchType, location_text: locationText, location: locationText, - listing_visibility: "listed", + listing_visibility: listingVisibility, hidden: false, is_hidden: false, visibility: defaultVisibility, @@ -245,8 +246,19 @@ export const createMatch = async ({ } if (matchType === "open" && skillLevel !== undefined && skillLevel !== null && `${skillLevel}`.trim() !== "") { - payload.skill_level_min = skillLevel; - payload.skillLevel = skillLevel; + const parsedSkill = `${skillLevel}`.trim(); + const [minRaw, maxRaw] = parsedSkill.split(/\s*[-–]\s*/); + const minLevel = Number.parseFloat(minRaw ?? ""); + const maxLevel = Number.parseFloat(maxRaw ?? ""); + + if (!Number.isNaN(minLevel)) { + payload.skill_level_min = minLevel; + } + if (!Number.isNaN(maxLevel)) { + payload.skill_level_max = maxLevel; + } + + payload.skillLevel = parsedSkill; } if (matchFormat) { From 9fa39bab193967489a242cd86072c75e827286ce Mon Sep 17 00:00:00 2001 From: Studio-18 Date: Sat, 22 Nov 2025 12:37:49 -0800 Subject: [PATCH 3/5] Align match creation payload with API requirements --- src/api/matches.ts | 40 ++++++++++++++++------------------------ 1 file changed, 16 insertions(+), 24 deletions(-) diff --git a/src/api/matches.ts b/src/api/matches.ts index c91f1487..e6d1a777 100644 --- a/src/api/matches.ts +++ b/src/api/matches.ts @@ -216,19 +216,11 @@ export const createMatch = async ({ }: CreateMatchParams) => { const status = "upcoming"; const matchType = privacy === "private" ? "private" : "open"; - const defaultVisibility = matchType === "open" ? "open" : "private"; - const listingVisibility = matchType === "open" ? "listed" : "private"; const payload: Record = { status, match_type: matchType, location_text: locationText, - location: locationText, - listing_visibility: listingVisibility, - hidden: false, - is_hidden: false, - visibility: defaultVisibility, - match_visibility: defaultVisibility, }; const startIso = toIsoString(startDateTime); @@ -242,40 +234,40 @@ export const createMatch = async ({ if (typeof rosterSize === "number") { payload.player_limit = rosterSize; - payload.playerCount = rosterSize; } - if (matchType === "open" && skillLevel !== undefined && skillLevel !== null && `${skillLevel}`.trim() !== "") { + if ( + matchType === "open" && + skillLevel !== undefined && + skillLevel !== null && + `${skillLevel}`.trim() !== "" + ) { const parsedSkill = `${skillLevel}`.trim(); - const [minRaw, maxRaw] = parsedSkill.split(/\s*[-–]\s*/); + const [minRaw] = parsedSkill.split(/\s*[-–]\s*/); const minLevel = Number.parseFloat(minRaw ?? ""); - const maxLevel = Number.parseFloat(maxRaw ?? ""); if (!Number.isNaN(minLevel)) { payload.skill_level_min = minLevel; } - if (!Number.isNaN(maxLevel)) { - payload.skill_level_max = maxLevel; - } - - payload.skillLevel = parsedSkill; } if (matchFormat) { payload.match_format = matchFormat; - payload.format = matchFormat; } if (notes) { payload.notes = notes; } - if (matchType === "open" && linkOnly) { - payload.hidden = true; - payload.is_hidden = true; - payload.listing_visibility = "link_only"; - payload.visibility = "hidden"; - payload.match_visibility = "hidden"; + if (matchType === "open") { + payload.hidden = false; + payload.is_hidden = false; + payload.listing_visibility = linkOnly ? "link_only" : "listed"; + + if (linkOnly) { + payload.visibility = "hidden"; + payload.match_visibility = "hidden"; + } } const executeCreate = async (override?: Record) => From d273855f5847956ae649a46e6e5fd7830505f754 Mon Sep 17 00:00:00 2001 From: Studio-18 Date: Sat, 22 Nov 2025 13:38:12 -0800 Subject: [PATCH 4/5] Adjust open match visibility flags --- src/api/matches.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/api/matches.ts b/src/api/matches.ts index e6d1a777..c6f22698 100644 --- a/src/api/matches.ts +++ b/src/api/matches.ts @@ -221,6 +221,7 @@ export const createMatch = async ({ status, match_type: matchType, location_text: locationText, + location: locationText, }; const startIso = toIsoString(startDateTime); @@ -232,9 +233,7 @@ export const createMatch = async ({ if (typeof latitude === "number") payload.latitude = latitude; if (typeof longitude === "number") payload.longitude = longitude; - if (typeof rosterSize === "number") { - payload.player_limit = rosterSize; - } + if (typeof rosterSize === "number") payload.player_limit = rosterSize; if ( matchType === "open" && @@ -260,11 +259,12 @@ export const createMatch = async ({ } if (matchType === "open") { - payload.hidden = false; - payload.is_hidden = false; - payload.listing_visibility = linkOnly ? "link_only" : "listed"; + const isLinkOnly = Boolean(linkOnly); + payload.hidden = isLinkOnly; + payload.is_hidden = isLinkOnly; + payload.listing_visibility = isLinkOnly ? "link_only" : "listed"; - if (linkOnly) { + if (isLinkOnly) { payload.visibility = "hidden"; payload.match_visibility = "hidden"; } From 8afe7f0cdf16fc6e7bce72193f7e3f81a349e88b Mon Sep 17 00:00:00 2001 From: Studio-18 Date: Sat, 22 Nov 2025 13:58:52 -0800 Subject: [PATCH 5/5] Log create match request payload --- src/api/matches.ts | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/api/matches.ts b/src/api/matches.ts index c6f22698..a347a4f9 100644 --- a/src/api/matches.ts +++ b/src/api/matches.ts @@ -270,16 +270,24 @@ export const createMatch = async ({ } } - const executeCreate = async (override?: Record) => - request("/matches", { + const executeCreate = async (override?: Record) => { + const body = { + ...payload, + ...override, + }; + + console.log("[createMatch] POST /matches", { + body, + tokenProvided: Boolean(token), + }); + + return request("/matches", { method: "POST", token: token ?? undefined, signal, - body: { - ...payload, - ...override, - }, + body, }); + }; try { const response = await executeCreate();