fix: persist CraftingTab sub-tab selection across tab navigation
Build and Publish Mana Loop Docker Image / build-and-publish (push) Successful in 1m28s

- Add activeCraftingSubTab state + setActiveCraftingSubTab action to
  craftingStore (persisted to localStorage via zustand persist middleware)
- Add CraftingAttunement type to craftingStore.types and re-export from
  stores/index.ts barrel
- Update CraftingTab.tsx to read/write active sub-tab from store instead
  of local useState, so selection survives component remount
- Add default 'fabricator' value in craft-initial-state.ts
This commit is contained in:
2026-06-09 19:08:49 +02:00
parent 28d39a61ba
commit 8bca8f85d5
7 changed files with 15 additions and 7 deletions
+4 -4
View File
@@ -1,14 +1,13 @@
'use client';
import { useState } from 'react';
import clsx from 'clsx';
import { Hammer, Sparkles } from 'lucide-react';
import { DebugName } from '@/components/game/debug/debug-context';
import { useCraftingStore } from '@/lib/game/stores/craftingStore';
import type { CraftingAttunement } from '@/lib/game/stores/craftingStore.types';
import { FabricatorSubTab } from './CraftingTab/FabricatorSubTab';
import { EnchanterSubTab } from './CraftingTab/EnchanterSubTab';
type CraftingAttunement = 'fabricator' | 'enchanter';
interface CraftingSubTab {
key: CraftingAttunement;
label: string;
@@ -21,7 +20,8 @@ const CRAFTING_SUB_TABS: CraftingSubTab[] = [
];
export function CraftingTab() {
const [activeSubTab, setActiveSubTab] = useState<CraftingAttunement>('fabricator');
const activeSubTab = useCraftingStore((s) => s.activeCraftingSubTab);
const setActiveSubTab = useCraftingStore((s) => s.setActiveCraftingSubTab);
return (
<DebugName name="CraftingTab">