From 0cf79828096b14178a8e3765302759f879d16728 Mon Sep 17 00:00:00 2001 From: Justin Edmund Date: Mon, 15 Dec 2025 14:21:35 -0800 Subject: [PATCH] fix job adapter response handling, update tier names --- src/lib/api/adapters/job.adapter.ts | 38 +++++++++++++++++++++++++++-- src/lib/utils/jobUtils.ts | 6 +++-- 2 files changed, 40 insertions(+), 4 deletions(-) diff --git a/src/lib/api/adapters/job.adapter.ts b/src/lib/api/adapters/job.adapter.ts index f2aa4187..2d3879e7 100644 --- a/src/lib/api/adapters/job.adapter.ts +++ b/src/lib/api/adapters/job.adapter.ts @@ -25,6 +25,24 @@ export interface SearchJobSkillsParams { filters?: { group?: number } } +/** + * Payload for updating a job entity + */ +export interface JobUpdatePayload { + name_en?: string + name_jp?: string + granblue_id?: string + proficiency1?: number + proficiency2?: number + row?: string + order?: number + master_level?: boolean + ultimate_mastery?: boolean + accessory?: boolean + accessory_type?: number + base_job_id?: string | null +} + /** * Job skill search response */ @@ -65,11 +83,11 @@ export class JobAdapter extends BaseAdapter { * Gets a single job by ID */ async getById(id: string): Promise { - const response = await this.request<{ job: Job }>(`/jobs/${id}`, { + const response = await this.request(`/jobs/${id}`, { method: 'GET', cacheTTL: 300000 // Cache for 5 minutes }) - return response.job + return response } /** @@ -99,6 +117,22 @@ export class JobAdapter extends BaseAdapter { return response.accessories } + /** + * Updates a job entity (database admin function) + * @param granblueId The job's granblue_id + * @param data The fields to update + */ + async updateJob(granblueId: string, data: JobUpdatePayload): Promise { + const response = await this.request(`/jobs/${granblueId}`, { + method: 'PUT', + body: data + }) + // Clear jobs cache to reflect the change + this.clearCache('/jobs') + this.clearCache(`/jobs/${granblueId}`) + return response + } + /** * Searches for job skills based on query and filters * Used for the skill selection interface with pagination diff --git a/src/lib/utils/jobUtils.ts b/src/lib/utils/jobUtils.ts index a1673544..b7287823 100644 --- a/src/lib/utils/jobUtils.ts +++ b/src/lib/utils/jobUtils.ts @@ -93,8 +93,9 @@ export function getJobTierName(row: string | number): string { '3': 'Class III', '4': 'Class IV', '5': 'Class V', - ex: 'Extra', - ex2: 'Extra II' + ex: 'EX', + ex1: 'EX', + ex2: 'EXII' } const rowStr = row.toString().toLowerCase() @@ -113,6 +114,7 @@ export function getJobTierOrder(row: string | number): number { '4': 4, '5': 5, ex: 6, + ex1: 6, ex2: 7 }