add party share types and adapter methods
This commit is contained in:
parent
5edb225d2d
commit
272c1dfa4e
4 changed files with 55 additions and 1 deletions
|
|
@ -1,6 +1,7 @@
|
|||
import { BaseAdapter } from './base.adapter'
|
||||
import { DEFAULT_ADAPTER_CONFIG } from './config'
|
||||
import type { RequestOptions } from './types'
|
||||
import type { RequestOptions, PaginatedResponse } from './types'
|
||||
import type { Party } from '$lib/types/api/party'
|
||||
import type {
|
||||
Crew,
|
||||
CrewMembership,
|
||||
|
|
@ -31,6 +32,23 @@ export class CrewAdapter extends BaseAdapter {
|
|||
return response.crew
|
||||
}
|
||||
|
||||
/**
|
||||
* Get parties shared with the user's crew
|
||||
*/
|
||||
async getSharedParties(
|
||||
page = 1,
|
||||
perPage = 20,
|
||||
options?: RequestOptions
|
||||
): Promise<{ parties: Party[]; meta: { page: number; totalPages: number; count: number; perPage: number } }> {
|
||||
return this.request<{ parties: Party[]; meta: { page: number; totalPages: number; count: number; perPage: number } }>(
|
||||
'/crew/shared_parties',
|
||||
{
|
||||
...options,
|
||||
params: { page, per_page: perPage }
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new crew (user becomes captain)
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ import { BaseAdapter } from './base.adapter'
|
|||
import type { AdapterOptions, PaginatedResponse } from './types'
|
||||
import { DEFAULT_ADAPTER_CONFIG } from './config'
|
||||
import type { Party, GridWeapon, GridCharacter, GridSummon } from '$lib/types/api/party'
|
||||
import type { PartyShare } from '$lib/types/api/partyShare'
|
||||
|
||||
/**
|
||||
* Parameters for creating a new party
|
||||
|
|
@ -409,6 +410,28 @@ export class PartyAdapter extends BaseAdapter {
|
|||
this.clearCache(`/parties/${shortcode}`)
|
||||
}
|
||||
|
||||
/**
|
||||
* Share a party with the current user's crew
|
||||
* @param partyId - The party's UUID
|
||||
*/
|
||||
async shareWithCrew(partyId: string): Promise<PartyShare> {
|
||||
const response = await this.request<{ share: PartyShare }>(`/parties/${partyId}/shares`, {
|
||||
method: 'POST'
|
||||
})
|
||||
return response.share
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a party share
|
||||
* @param partyId - The party's UUID
|
||||
* @param shareId - The share's UUID to remove
|
||||
*/
|
||||
async removeShare(partyId: string, shareId: string): Promise<void> {
|
||||
await this.request(`/parties/${partyId}/shares/${shareId}`, {
|
||||
method: 'DELETE'
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears the cache for party-related data
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ import type {
|
|||
} from './entities'
|
||||
import type { GridArtifact, CollectionArtifact } from './artifact'
|
||||
import type { AugmentSkill, Befoulment } from './weaponStatModifier'
|
||||
import type { PartyShare } from './partyShare'
|
||||
|
||||
// Grid item types - these are the junction tables between Party and entities
|
||||
|
||||
|
|
@ -139,6 +140,8 @@ export interface Party {
|
|||
user?: User
|
||||
sourceParty?: Party
|
||||
remixes?: Party[]
|
||||
/** Shares for this party (only present for owner) */
|
||||
shares?: PartyShare[]
|
||||
|
||||
// Local client state
|
||||
localId?: string
|
||||
|
|
|
|||
10
src/lib/types/api/partyShare.ts
Normal file
10
src/lib/types/api/partyShare.ts
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
// PartyShare type for party sharing with crews/groups
|
||||
// Based on PartyShareBlueprint from Rails API
|
||||
|
||||
export interface PartyShare {
|
||||
id: string
|
||||
shareableType: string
|
||||
shareableId: string
|
||||
shareableName?: string
|
||||
createdAt: string
|
||||
}
|
||||
Loading…
Reference in a new issue