add raidId and metrics to party adapter

This commit is contained in:
Justin Edmund 2025-12-21 02:56:44 -08:00
parent 0a45b13e71
commit 22d3ac625f
5 changed files with 39 additions and 6 deletions

View file

@ -117,13 +117,14 @@ describe('PartyAdapter', () => {
}) })
const result = await adapter.update({ const result = await adapter.update({
id: 'uuid-123',
shortcode: 'ABC123', shortcode: 'ABC123',
name: 'Updated Party' name: 'Updated Party'
}) })
expect(result).toEqual(updatedParty) expect(result).toEqual(updatedParty)
expect(global.fetch).toHaveBeenCalledWith( expect(global.fetch).toHaveBeenCalledWith(
'https://api.example.com/parties/ABC123', 'https://api.example.com/parties/uuid-123',
expect.objectContaining({ expect.objectContaining({
method: 'PATCH', method: 'PATCH',
body: JSON.stringify({ body: JSON.stringify({

View file

@ -21,7 +21,7 @@ export interface CreatePartyParams {
description?: string | undefined description?: string | undefined
visibility?: 'public' | 'private' | 'unlisted' | undefined visibility?: 'public' | 'private' | 'unlisted' | undefined
jobId?: string | undefined jobId?: string | undefined
raidId?: string | undefined raidId?: string | null | undefined
guidebookId?: string | undefined guidebookId?: string | undefined
extras?: Record<string, any> | undefined extras?: Record<string, any> | undefined
} }
@ -30,7 +30,24 @@ export interface CreatePartyParams {
* Parameters for updating a party * Parameters for updating a party
*/ */
export interface UpdatePartyParams extends CreatePartyParams { export interface UpdatePartyParams extends CreatePartyParams {
/** Party UUID (required for API update) */
id: string
/** Party shortcode (for cache invalidation) */
shortcode: string shortcode: string
// Battle settings
fullAuto?: boolean
autoGuard?: boolean
autoSummon?: boolean
chargeAttack?: boolean
// Performance metrics (null to clear)
clearTime?: number | null
buttonCount?: number | null
chainCount?: number | null
summonCount?: number | null
// Video (null to clear)
videoUrl?: string | null
// Raid (null to clear)
raidId?: string | null
} }
/** /**
@ -119,10 +136,11 @@ export class PartyAdapter extends BaseAdapter {
/** /**
* Updates a party * Updates a party
* Note: API expects UUID for update, not shortcode
*/ */
async update(params: UpdatePartyParams): Promise<Party> { async update(params: UpdatePartyParams): Promise<Party> {
const { shortcode, ...updateParams } = params const { id, shortcode, ...updateParams } = params
const response = await this.request<{ party: Party }>(`/parties/${shortcode}`, { const response = await this.request<{ party: Party }>(`/parties/${id}`, {
method: 'PATCH', method: 'PATCH',
body: { body: {
party: updateParams party: updateParams

View file

@ -120,6 +120,8 @@ const MinimalScalarsSchema = z
buttonCount: z.number().nullish().optional(), buttonCount: z.number().nullish().optional(),
chainCount: z.number().nullish().optional(), chainCount: z.number().nullish().optional(),
turnCount: z.number().nullish().optional(), turnCount: z.number().nullish().optional(),
summonCount: z.number().nullish().optional(),
videoUrl: z.string().nullish().optional(),
visibility: z.enum(['public', 'private', 'unlisted']).nullish().optional() visibility: z.enum(['public', 'private', 'unlisted']).nullish().optional()
}) })
.partial() .partial()
@ -373,6 +375,10 @@ export const PartySchemaRaw = z.object({
button_count: z.number().nullish(), button_count: z.number().nullish(),
turn_count: z.number().nullish(), turn_count: z.number().nullish(),
chain_count: z.number().nullish(), chain_count: z.number().nullish(),
summon_count: z.number().nullish(),
// Video URL
video_url: z.string().nullish(),
// Relations // Relations
raid_id: z.string().nullish(), raid_id: z.string().nullish(),

View file

@ -9,12 +9,14 @@
noHover?: boolean noHover?: boolean
/** Remove padding for inline edit contexts */ /** Remove padding for inline edit contexts */
noPadding?: boolean noPadding?: boolean
/** Remove min-width from value (for compact controls like switches) */
compact?: boolean
} }
let { label, value, children, noHover = false, noPadding = false }: Props = $props() let { label, value, children, noHover = false, noPadding = false, compact = false }: Props = $props()
</script> </script>
<div class="detail-row" class:no-hover={noHover} class:no-padding={noPadding}> <div class="detail-row" class:no-hover={noHover} class:no-padding={noPadding} class:compact>
<span class="label">{label}</span> <span class="label">{label}</span>
<span class="value"> <span class="value">
{#if children} {#if children}
@ -62,5 +64,9 @@
text-align: right; text-align: right;
min-width: 180px; min-width: 180px;
} }
&.compact .value {
min-width: unset;
}
} }
</style> </style>

View file

@ -107,6 +107,8 @@ export interface Party {
buttonCount?: number buttonCount?: number
turnCount?: number turnCount?: number
chainCount?: number chainCount?: number
summonCount?: number
videoUrl?: string
visibility?: import('$lib/types/visibility').PartyVisibility visibility?: import('$lib/types/visibility').PartyVisibility
element?: number element?: number
favorited?: boolean favorited?: boolean