diff --git a/src/lib/components/collection/CollectionArtifactDetailPane.svelte b/src/lib/components/collection/CollectionArtifactDetailPane.svelte index bde4eac5..d400e5e7 100644 --- a/src/lib/components/collection/CollectionArtifactDetailPane.svelte +++ b/src/lib/components/collection/CollectionArtifactDetailPane.svelte @@ -8,12 +8,13 @@ * provides Edit button in header to push edit pane onto stack. */ import { onMount } from 'svelte' - import type { CollectionArtifact } from '$lib/types/api/artifact' + import type { CollectionArtifact, ArtifactSkillInstance } from '$lib/types/api/artifact' import { isQuirkArtifact } from '$lib/types/api/artifact' + import { createQuery } from '@tanstack/svelte-query' + import { artifactQueries } from '$lib/api/queries/artifact.queries' import { useDeleteCollectionArtifact } from '$lib/api/mutations/artifact.mutations' import { usePaneStack, type PaneConfig, type ElementType } from '$lib/stores/paneStack.svelte' import { sidebar } from '$lib/stores/sidebar.svelte' - import { getArtifactImage } from '$lib/utils/images' import DetailsSection from '$lib/components/sidebar/details/DetailsSection.svelte' import DetailRow from '$lib/components/sidebar/details/DetailRow.svelte' import ElementLabel from '$lib/components/labels/ElementLabel.svelte' @@ -28,19 +29,19 @@ onClose?: () => void } - let { artifact, isOwner = false, onClose }: Props = $props() + let { artifact: initialArtifact, isOwner = false, onClose }: Props = $props() + + // Local state that can be updated when returning from edit pane + let artifact = $state(initialArtifact) + + // Update artifact when edit pane returns with new data + function handleArtifactUpdated(updatedArtifact: CollectionArtifact) { + artifact = updatedArtifact + } const paneStack = usePaneStack() const deleteMutation = useDeleteCollectionArtifact() - // Image and name - const imageUrl = $derived(getArtifactImage(artifact.artifact?.granblueId)) - const displayName = $derived.by(() => { - const name = artifact.artifact?.name - if (!name) return '—' - if (typeof name === 'string') return name - return name.en || name.ja || '—' - }) // Artifact properties const isQuirk = $derived(isQuirkArtifact(artifact.artifact)) @@ -52,6 +53,15 @@ const skills = $derived(artifact.skills ?? []) const hasSkills = $derived(!isQuirk && skills.some((s) => s !== null)) + // Query skill definitions to get names + const skillsQuery = createQuery(() => artifactQueries.skills()) + + // Get skill name by modifier + function getSkillName(skill: ArtifactSkillInstance): string { + const skillDef = skillsQuery.data?.find((s) => s.modifier === skill.modifier) + return skillDef?.name?.en ?? 'Unknown Skill' + } + // Convert numeric element to ElementType string const elementNames: Record = { 1: 'wind', @@ -70,7 +80,8 @@ title: 'Edit Artifact', component: CollectionArtifactEditPane, props: { - artifact + artifact, + onSaved: handleArtifactUpdated } } paneStack.push(config) @@ -108,20 +119,12 @@
- -
-
- {displayName} -
-

{displayName}

- {#if artifact.nickname} -

"{artifact.nickname}"

- {/if} -
- -
+ {#if artifact.nickname} + + {/if} + @@ -139,13 +142,13 @@ {#if hasSkills} -
- {#each skills as skill, index} - {#if skill} - - {/if} - {/each} -
+ {#each skills as skill} + {#if skill} + + + + {/if} + {/each}
{/if} @@ -155,13 +158,10 @@
-