diff --git a/messages/en.json b/messages/en.json index 81bf0296..95cbbe26 100644 --- a/messages/en.json +++ b/messages/en.json @@ -17,6 +17,7 @@ "job_selection_title": "Select Job", "job_selection_search_placeholder": "Search jobs...", + "job_choose": "Choose a job", "skill_selection_title": "Select Skill", "skill_selection_search_placeholder": "Search skills...", diff --git a/messages/ja.json b/messages/ja.json index f6ca8280..cd07aa35 100644 --- a/messages/ja.json +++ b/messages/ja.json @@ -17,6 +17,7 @@ "job_selection_title": "ジョブ選択", "job_selection_search_placeholder": "ジョブを検索...", + "job_choose": "ジョブを選択", "skill_selection_title": "スキル選択", "skill_selection_search_placeholder": "スキルを検索...", diff --git a/src/lib/api/adapters/party.adapter.ts b/src/lib/api/adapters/party.adapter.ts index 974f66d9..53f26d8a 100644 --- a/src/lib/api/adapters/party.adapter.ts +++ b/src/lib/api/adapters/party.adapter.ts @@ -346,7 +346,9 @@ export class PartyAdapter extends BaseAdapter { return this.request(`/parties/${partyId}/job_skills`, { method: 'DELETE', body: { - slot: skillSlot + party: { + skill_position: skillSlot + } } }) } diff --git a/src/lib/components/job/JobSection.svelte b/src/lib/components/job/JobSection.svelte index dd9afd5c..cb84473d 100644 --- a/src/lib/components/job/JobSection.svelte +++ b/src/lib/components/job/JobSection.svelte @@ -12,6 +12,8 @@ } from '$lib/utils/jobUtils' import { getAccessoryImage, getBasePath } from '$lib/utils/images' import Icon from '$lib/components/Icon.svelte' + import Button from '$lib/components/ui/Button.svelte' + import * as m from '$lib/paraglide/messages' interface Props { job?: Job | undefined @@ -62,13 +64,8 @@ {#if job} {job.name.en}
- {:else if canEdit} -
- -
+ {:else} +
{/if} {#if canEdit && job} @@ -167,7 +164,11 @@ {/if} {:else}
-

{canEdit ? 'Select a job to view skills and details' : 'No job selected'}

+ {#if canEdit} + + {:else} +

No job selected

+ {/if}
{/if} @@ -240,34 +241,9 @@ } .empty-portrait { - display: flex; - flex-direction: column; - align-items: center; - justify-content: center; - color: var(--text-secondary); - font-size: typography.$font-regular; z-index: 2; } - .select-job-button { - display: flex; - align-items: center; - gap: spacing.$unit-half; - padding: spacing.$unit spacing.$unit-2x; - background: var(--button-primary-bg); - color: var(--button-primary-text); - border: none; - border-radius: layout.$card-corner; - font-size: typography.$font-regular; - font-weight: 500; - cursor: pointer; - transition: background 0.2s ease; - - &:hover { - background: var(--button-primary-bg-hover); - } - } - .change-job-button { position: absolute; top: spacing.$unit; diff --git a/src/lib/components/job/JobSkillSlot.svelte b/src/lib/components/job/JobSkillSlot.svelte index 2a0d5e07..603c8bc9 100644 --- a/src/lib/components/job/JobSkillSlot.svelte +++ b/src/lib/components/job/JobSkillSlot.svelte @@ -63,12 +63,12 @@ + /> {/if} {:else} diff --git a/src/lib/components/party/Party.svelte b/src/lib/components/party/Party.svelte index 8395b8c0..09bba0cf 100644 --- a/src/lib/components/party/Party.svelte +++ b/src/lib/components/party/Party.svelte @@ -33,6 +33,13 @@ useUnfavoriteParty } from '$lib/api/mutations/party.mutations' + // TanStack Query mutations - Job + import { + useUpdatePartyJob, + useUpdatePartyJobSkills, + useRemovePartyJobSkill + } from '$lib/api/mutations/job.mutations' + // Utilities import { getLocalId } from '$lib/utils/localId' import { getEditKey, storeEditKey, computeEditability } from '$lib/utils/editKeys' @@ -152,6 +159,11 @@ const favoritePartyMutation = useFavoriteParty() const unfavoritePartyMutation = useUnfavoriteParty() + // TanStack Query mutations - Job + const updateJobMutation = useUpdatePartyJob() + const updateJobSkillsMutation = useUpdatePartyJobSkills() + const removeJobSkillMutation = useRemovePartyJobSkill() + // Create drag-drop context const dragContext = createDragDropContext({ onLocalUpdate: async (operation) => { @@ -498,9 +510,11 @@ error = null try { - // Update job via API (use shortcode for party identification) - await partyAdapter.updateJob(party.shortcode, job.id) - // Party will be updated via cache invalidation + // Use mutation for proper cache invalidation + await updateJobMutation.mutateAsync({ + shortcode: party.shortcode, + jobId: job.id + }) } catch (e) { error = e instanceof Error ? e.message : 'Failed to update job' console.error('Failed to update job:', e) @@ -528,18 +542,14 @@ const updatedSkills = { ...party.jobSkills } updatedSkills[String(slot) as keyof typeof updatedSkills] = skill - console.log('[Party] Current jobSkills:', party.jobSkills) - console.log('[Party] Updated jobSkills object:', updatedSkills) - console.log('[Party] Slot being updated:', slot) - console.log('[Party] New skill:', skill) - // Convert skills object to array format expected by API const skillsArray = transformSkillsToArray(updatedSkills) - console.log('[Party] Skills array to send:', skillsArray) - - await partyAdapter.updateJobSkills(party.shortcode, skillsArray) - // Party will be updated via cache invalidation + // Use mutation for proper cache invalidation + await updateJobSkillsMutation.mutateAsync({ + shortcode: party.shortcode, + skills: skillsArray + }) } catch (e: any) { error = extractErrorMessage(e, 'Failed to update skill') console.error('Failed to update skill:', e) @@ -552,21 +562,11 @@ error = null try { - // Remove skill from slot - const updatedSkills = { ...party.jobSkills } - delete updatedSkills[String(slot) as keyof typeof updatedSkills] - - console.log('[Party] Removing skill from slot:', slot) - console.log('[Party] Current jobSkills:', party.jobSkills) - console.log('[Party] Updated jobSkills after removal:', updatedSkills) - - // Convert skills object to array format expected by API - const skillsArray = transformSkillsToArray(updatedSkills) - - console.log('[Party] Skills array to send after removal:', skillsArray) - - await partyAdapter.updateJobSkills(party.shortcode, skillsArray) - // Party will be updated via cache invalidation + // Use remove mutation for proper cache invalidation + await removeJobSkillMutation.mutateAsync({ + shortcode: party.shortcode, + slot + }) } catch (e: any) { error = extractErrorMessage(e, 'Failed to remove skill') console.error('Failed to remove skill:', e) @@ -585,15 +585,11 @@ error = null try { - // Remove skill from slot - const updatedSkills = { ...party.jobSkills } - delete updatedSkills[String(slot) as keyof typeof updatedSkills] - - // Convert skills object to array format expected by API - const skillsArray = transformSkillsToArray(updatedSkills) - - await partyAdapter.updateJobSkills(party.shortcode, skillsArray) - // Party will be updated via cache invalidation + // Use remove mutation for proper cache invalidation + await removeJobSkillMutation.mutateAsync({ + shortcode: party.shortcode, + slot + }) } catch (e) { error = e instanceof Error ? e.message : 'Failed to remove skill' console.error('Failed to remove skill:', e)