fix job skills adapter to expect array, add emp_skills method

This commit is contained in:
Justin Edmund 2025-12-15 14:30:47 -08:00
parent cbe698c86f
commit 767eda424e
2 changed files with 29 additions and 4 deletions

View file

@ -95,11 +95,10 @@ export class JobAdapter extends BaseAdapter {
* Returns skills categorized by type (main, sub, emp, base)
*/
async getSkills(jobId: string): Promise<JobSkill[]> {
const response = await this.request<{ skills: JobSkill[] }>(`/jobs/${jobId}/skills`, {
return this.request<JobSkill[]>(`/jobs/${jobId}/skills`, {
method: 'GET',
cacheTTL: 300000 // Cache for 5 minutes
})
return response.skills
}
/**
@ -179,11 +178,21 @@ export class JobAdapter extends BaseAdapter {
* Useful for browsing all skills
*/
async getAllSkills(): Promise<JobSkill[]> {
const response = await this.request<{ skills: JobSkill[] }>('/jobs/skills', {
return this.request<JobSkill[]>('/jobs/skills', {
method: 'GET',
cacheTTL: 300000 // Cache for 5 minutes
})
}
/**
* Gets EMP skills from other jobs (for party skill selection)
* Returns skills that can be used with the specified job
*/
async getEmpSkills(jobId: string): Promise<JobSkill[]> {
return this.request<JobSkill[]>(`/jobs/${jobId}/emp_skills`, {
method: 'GET',
cacheTTL: 300000 // Cache for 5 minutes
})
return response.skills
}
/**

View file

@ -86,6 +86,21 @@ export const jobQueries = {
gcTime: 1000 * 60 * 60 // 1 hour
}),
/**
* EMP skills from other jobs (for party skill selection)
*
* @param jobId - Current job ID to find compatible EMP skills for
* @returns Query options for fetching EMP skills from other jobs
*/
empSkills: (jobId: string) =>
queryOptions({
queryKey: ['jobs', jobId, 'emp_skills'] as const,
queryFn: () => jobAdapter.getEmpSkills(jobId),
enabled: !!jobId,
staleTime: 1000 * 60 * 30, // 30 minutes
gcTime: 1000 * 60 * 60 // 1 hour
}),
/**
* Job skills search infinite query options
*
@ -175,6 +190,7 @@ export const jobKeys = {
lists: () => [...jobKeys.all] as const,
detail: (id: string) => [...jobKeys.all, id] as const,
skills: (jobId: string) => [...jobKeys.all, jobId, 'skills'] as const,
empSkills: (jobId: string) => [...jobKeys.all, jobId, 'emp_skills'] as const,
skillsSearch: (jobId: string, params?: Omit<SearchJobSkillsParams, 'jobId' | 'page'>) =>
[...jobKeys.skills(jobId), 'search', params] as const,
accessories: (jobId: string) => [...jobKeys.all, jobId, 'accessories'] as const,