Fix adapter field names and runed import
- Update Party interface to use transformed field names (weapons/characters/summons) - Fix runed import to use useDebounce instead of debounced - Clean up debug logging
This commit is contained in:
parent
1a6a112efd
commit
100a04eda6
3 changed files with 22 additions and 22 deletions
|
|
@ -46,9 +46,9 @@ export interface Party {
|
|||
name: Record<string, string>
|
||||
}
|
||||
}
|
||||
gridWeapons: GridWeapon[]
|
||||
gridSummons: GridSummon[]
|
||||
gridCharacters: GridCharacter[]
|
||||
weapons: GridWeapon[]
|
||||
summons: GridSummon[]
|
||||
characters: GridCharacter[]
|
||||
guidebook?: {
|
||||
id: string
|
||||
title: string
|
||||
|
|
@ -195,31 +195,30 @@ export interface GridUpdateResponse {
|
|||
*/
|
||||
export class PartyAdapter extends BaseAdapter {
|
||||
constructor(options?: AdapterOptions) {
|
||||
super({
|
||||
...options,
|
||||
baseURL: options?.baseURL || '/api/v1'
|
||||
})
|
||||
super(options)
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new party
|
||||
*/
|
||||
async create(params: CreatePartyParams): Promise<Party> {
|
||||
return this.request<Party>('/parties', {
|
||||
const response = await this.request<{ party: Party }>('/parties', {
|
||||
method: 'POST',
|
||||
body: {
|
||||
party: params
|
||||
}
|
||||
})
|
||||
return response.party
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a party by shortcode
|
||||
*/
|
||||
async getByShortcode(shortcode: string): Promise<Party> {
|
||||
return this.request<Party>(`/parties/${shortcode}`, {
|
||||
const response = await this.request<{ party: Party }>(`/parties/${shortcode}`, {
|
||||
cacheTTL: 60000 // Cache for 1 minute
|
||||
})
|
||||
return response.party
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -227,12 +226,13 @@ export class PartyAdapter extends BaseAdapter {
|
|||
*/
|
||||
async update(params: UpdatePartyParams): Promise<Party> {
|
||||
const { shortcode, ...updateParams } = params
|
||||
return this.request<Party>(`/parties/${shortcode}`, {
|
||||
const response = await this.request<{ party: Party }>(`/parties/${shortcode}`, {
|
||||
method: 'PATCH',
|
||||
body: {
|
||||
party: updateParams
|
||||
}
|
||||
})
|
||||
return response.party
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -248,9 +248,10 @@ export class PartyAdapter extends BaseAdapter {
|
|||
* Creates a remix (copy) of an existing party
|
||||
*/
|
||||
async remix(shortcode: string): Promise<Party> {
|
||||
return this.request<Party>(`/parties/${shortcode}/remix`, {
|
||||
const response = await this.request<{ party: Party }>(`/parties/${shortcode}/remix`, {
|
||||
method: 'POST'
|
||||
})
|
||||
return response.party
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
* @module adapters/resources/search
|
||||
*/
|
||||
|
||||
import { debounced } from 'runed'
|
||||
import { useDebounce } from 'runed'
|
||||
import { SearchAdapter, searchAdapter, type SearchParams, type SearchResponse } from '../search.adapter'
|
||||
import type { AdapterError } from '../types'
|
||||
|
||||
|
|
@ -152,8 +152,14 @@ export class SearchResource {
|
|||
}
|
||||
}
|
||||
|
||||
// Return debounced version
|
||||
return debounced(searchFn, this.debounceMs)
|
||||
// Create a debounced wrapper using useDebounce
|
||||
const debouncedSearch = useDebounce(
|
||||
(params: SearchParams) => searchFn(params),
|
||||
() => this.debounceMs
|
||||
)
|
||||
|
||||
// Return a function that calls the debounced search
|
||||
return (params: SearchParams) => debouncedSearch(params)
|
||||
}
|
||||
|
||||
// Create debounced search methods
|
||||
|
|
|
|||
|
|
@ -2,8 +2,6 @@ import type { PageServerLoad } from './$types'
|
|||
import { PartyService } from '$lib/services/party.service'
|
||||
|
||||
export const load: PageServerLoad = async ({ params, fetch, locals }) => {
|
||||
console.log('[p/[id]/+page.server.ts] Loading with id:', params.id)
|
||||
|
||||
// Get auth data directly from locals instead of parent()
|
||||
const authUserId = locals.session?.account?.userId
|
||||
|
||||
|
|
@ -17,17 +15,12 @@ export const load: PageServerLoad = async ({ params, fetch, locals }) => {
|
|||
try {
|
||||
// Fetch the party
|
||||
party = await partyService.getByShortcode(params.id)
|
||||
console.log('[p/[id]] Successfully fetched party on server:', party.id, party.name)
|
||||
partyFound = true
|
||||
|
||||
// Determine if user can edit
|
||||
console.log('[p/[id]] Auth user ID:', authUserId)
|
||||
console.log('[p/[id]] Party user ID:', party.user?.id)
|
||||
console.log('[p/[id]] Party user:', party.user)
|
||||
canEdit = authUserId ? party.user?.id === authUserId : false
|
||||
console.log('[p/[id]] Can edit?', canEdit)
|
||||
} catch (err) {
|
||||
console.log('[p/[id]] Error fetching party (expected for test ids):', err)
|
||||
// Error is expected for test/invalid IDs
|
||||
}
|
||||
|
||||
// Return party data with explicit serialization
|
||||
|
|
|
|||
Loading…
Reference in a new issue