diff --git a/src/lib/api/adapters/party.adapter.ts b/src/lib/api/adapters/party.adapter.ts index 598c3e58..864f4d03 100644 --- a/src/lib/api/adapters/party.adapter.ts +++ b/src/lib/api/adapters/party.adapter.ts @@ -213,7 +213,9 @@ export class PartyAdapter extends BaseAdapter { return this.request(`/parties/${shortcode}/jobs`, { method: 'PUT', body: { - job_id: jobId + party: { + job_id: jobId + } } }) } @@ -228,17 +230,17 @@ export class PartyAdapter extends BaseAdapter { console.log('[updateJobSkills] Input skills array:', skills) // Convert skills array to Rails expected format - const party: Record = {} + // Rails has skill0_id (main, locked), skill1_id, skill2_id, skill3_id + // Only include skills that have actual IDs - don't send null values + // as Rails will try to validate them + const party: Record = {} - // Initialize all slots with null - for (let i = 1; i <= 4; i++) { - party[`skill${i}_id`] = null - } - - // Set the provided skills - skills.forEach(skill => { - // Rails expects skill1_id, skill2_id, skill3_id, skill4_id - party[`skill${skill.slot + 1}_id`] = skill.id + // Set the provided skills - slot number maps directly to skill{N}_id + skills.forEach((skill) => { + // Only set editable slots (1, 2, 3) and only if skill has an ID + if (skill.slot >= 1 && skill.slot <= 3 && skill.id) { + party[`skill${skill.slot}_id`] = skill.id + } }) const requestBody = { @@ -256,6 +258,16 @@ export class PartyAdapter extends BaseAdapter { }) } + /** + * Updates the accessory for a party + */ + async updateAccessory(partyId: string, accessoryId: string): Promise { + return this.request(`/parties/${partyId}/accessory`, { + method: 'PUT', + body: { accessory_id: accessoryId } + }) + } + /** * Removes a job skill from a party */ diff --git a/src/lib/components/party/Party.svelte b/src/lib/components/party/Party.svelte index 3383833c..37cc5b12 100644 --- a/src/lib/components/party/Party.svelte +++ b/src/lib/components/party/Party.svelte @@ -369,8 +369,8 @@ error = null try { - // Update job via API - const updated = await partyAdapter.updateJob(party.id, job.id) + // Update job via API (use shortcode for party identification) + const updated = await partyAdapter.updateJob(party.shortcode, job.id) party = updated } catch (e) { error = e instanceof Error ? e.message : 'Failed to update job' @@ -415,7 +415,7 @@ console.log('[Party] Skills array to send:', skillsArray) const updated = await partyAdapter.updateJobSkills( - party.id, + party.shortcode, skillsArray ) party = updated @@ -476,7 +476,7 @@ console.log('[Party] Skills array to send after removal:', skillsArray) const updated = await partyAdapter.updateJobSkills( - party.id, + party.shortcode, skillsArray ) party = updated @@ -537,7 +537,7 @@ })) const updated = await partyAdapter.updateJobSkills( - party.id, + party.shortcode, skillsArray ) party = updated