Update services for editing support

This commit is contained in:
Justin Edmund 2025-09-15 04:10:22 -07:00
parent ff6074675b
commit 251c56b86d
3 changed files with 19 additions and 7 deletions

View file

@ -1,4 +1,4 @@
import type { Party, GridWeapon, GridCharacter } from '$lib/api/schemas/party' import type { Party, GridWeapon, GridCharacter } from '$lib/types/api/party'
import type { FetchLike } from '$lib/api/core' import type { FetchLike } from '$lib/api/core'
import * as partiesApi from '$lib/api/resources/parties' import * as partiesApi from '$lib/api/resources/parties'

View file

@ -1,4 +1,4 @@
import type { Party, GridWeapon, GridSummon, GridCharacter } from '$lib/api/schemas/party' import type { Party, GridWeapon, GridSummon, GridCharacter } from '$lib/types/api/party'
import * as partiesApi from '$lib/api/resources/parties' import * as partiesApi from '$lib/api/resources/parties'
import type { FetchLike } from '$lib/api/core' import type { FetchLike } from '$lib/api/core'

View file

@ -1,4 +1,4 @@
import type { Party } from '$lib/api/schemas/party' import type { Party } from '$lib/types/api/party'
import * as partiesApi from '$lib/api/resources/parties' import * as partiesApi from '$lib/api/resources/parties'
import type { FetchLike } from '$lib/api/core' import type { FetchLike } from '$lib/api/core'
@ -11,6 +11,7 @@ export interface EditabilityResult {
export interface PartyUpdatePayload { export interface PartyUpdatePayload {
name?: string | null name?: string | null
description?: string | null description?: string | null
element?: number
raidId?: string raidId?: string
chargeAttack?: boolean chargeAttack?: boolean
fullAuto?: boolean fullAuto?: boolean
@ -41,10 +42,20 @@ export class PartyService {
/** /**
* Create a new party * Create a new party
*/ */
async create(payload: PartyUpdatePayload, editKey?: string): Promise<Party> { async create(payload: PartyUpdatePayload, editKey?: string): Promise<{
party: Party
editKey?: string
}> {
const headers = this.buildHeaders(editKey) const headers = this.buildHeaders(editKey)
const apiPayload = this.mapToApiPayload(payload) const apiPayload = this.mapToApiPayload(payload)
return partiesApi.create(this.fetch, apiPayload, headers) const result = await partiesApi.create(this.fetch, apiPayload, headers)
// Store edit key if returned
if (result.editKey && typeof window !== 'undefined') {
localStorage.setItem(`edit_key_${result.party.shortcode}`, result.editKey)
}
return result
} }
/** /**
@ -196,6 +207,7 @@ export class PartyService {
if (payload.name !== undefined) mapped.name = payload.name if (payload.name !== undefined) mapped.name = payload.name
if (payload.description !== undefined) mapped.description = payload.description if (payload.description !== undefined) mapped.description = payload.description
if (payload.element !== undefined) mapped.element = payload.element
if (payload.raidId !== undefined) mapped.raid = { id: payload.raidId } if (payload.raidId !== undefined) mapped.raid = { id: payload.raidId }
if (payload.chargeAttack !== undefined) mapped.chargeAttack = payload.chargeAttack if (payload.chargeAttack !== undefined) mapped.chargeAttack = payload.chargeAttack
if (payload.fullAuto !== undefined) mapped.fullAuto = payload.fullAuto if (payload.fullAuto !== undefined) mapped.fullAuto = payload.fullAuto