diff --git a/src/lib/features/database/summons/schema.ts b/src/lib/features/database/summons/schema.ts index 0411a357..a800bf32 100644 --- a/src/lib/features/database/summons/schema.ts +++ b/src/lib/features/database/summons/schema.ts @@ -5,6 +5,7 @@ export const SummonEditSchema = z.object({ granblue_id: z.string().min(1), rarity: z.number().int().min(1), element: z.number().int().min(0), + promotions: z.array(z.number().int().min(1)), min_hp: z.number().int().min(0), max_hp: z.number().int().min(0), max_hp_flb: z.number().int().min(0), @@ -21,15 +22,17 @@ export type SummonEdit = z.infer export function toEditData(model: any): SummonEdit { return { name: model?.name ?? '', - granblue_id: model?.granblue_id ?? '', + granblue_id: model?.granblueId ?? model?.granblue_id ?? '', rarity: model?.rarity ?? 1, element: model?.element ?? 0, - min_hp: model?.hp?.min_hp ?? 0, - max_hp: model?.hp?.max_hp ?? 0, - max_hp_flb: model?.hp?.max_hp_flb ?? 0, - min_atk: model?.atk?.min_atk ?? 0, - max_atk: model?.atk?.max_atk ?? 0, - max_atk_flb: model?.atk?.max_atk_flb ?? 0, + promotions: model?.promotions ?? [], + // API returns camelCase after transformation + min_hp: model?.hp?.minHp ?? model?.hp?.min_hp ?? 0, + max_hp: model?.hp?.maxHp ?? model?.hp?.max_hp ?? 0, + max_hp_flb: model?.hp?.maxHpFlb ?? model?.hp?.max_hp_flb ?? 0, + min_atk: model?.atk?.minAtk ?? model?.atk?.min_atk ?? 0, + max_atk: model?.atk?.maxAtk ?? model?.atk?.max_atk ?? 0, + max_atk_flb: model?.atk?.maxAtkFlb ?? model?.atk?.max_atk_flb ?? 0, flb: model?.uncap?.flb ?? false, ulb: model?.uncap?.ulb ?? false, transcendence: model?.uncap?.transcendence ?? false @@ -42,6 +45,7 @@ export function toPayload(edit: SummonEdit) { granblue_id: edit.granblue_id, rarity: edit.rarity, element: edit.element, + promotions: edit.promotions, hp: { min_hp: edit.min_hp, max_hp: edit.max_hp, diff --git a/src/lib/features/database/summons/sections/SummonTaxonomySection.svelte b/src/lib/features/database/summons/sections/SummonTaxonomySection.svelte index 595621c3..674ed880 100644 --- a/src/lib/features/database/summons/sections/SummonTaxonomySection.svelte +++ b/src/lib/features/database/summons/sections/SummonTaxonomySection.svelte @@ -6,7 +6,10 @@ import DetailItem from '$lib/components/ui/DetailItem.svelte' import SuggestionDetailItem from '$lib/components/ui/SuggestionDetailItem.svelte' import ElementLabel from '$lib/components/labels/ElementLabel.svelte' - import { getElementOptions } from '$lib/utils/element' + import { getElementLabel, getElementOptions } from '$lib/utils/element' + import { PROMOTION_NAMES, getPromotionNames } from '$lib/types/enums' + + type ElementName = 'wind' | 'fire' | 'water' | 'earth' | 'dark' | 'light' interface Props { summon: any @@ -30,6 +33,25 @@ }: Props = $props() const elementOptions = getElementOptions() + + // Promotion options for multiselect + const promotionOptions = Object.entries(PROMOTION_NAMES).map(([value, label]) => ({ + value: Number(value), + label + })) + + // Get element name for checkbox theming + const elementName = $derived.by((): ElementName | undefined => { + const el = editMode ? editData?.element : summon?.element + const label = getElementLabel(el) + return label !== '—' && label !== 'Null' ? (label.toLowerCase() as ElementName) : undefined + }) + + // Format promotions for display + function formatPromotionsDisplay(promotions: number[]): string { + if (!promotions || promotions.length === 0) return '—' + return getPromotionNames(promotions).join(', ') + } @@ -52,10 +74,20 @@ type="text" placeholder="Series name" /> + {:else} + {/if}