fix: persist CraftingTab sub-tab selection across tab navigation
Build and Publish Mana Loop Docker Image / build-and-publish (push) Successful in 1m28s
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:
@@ -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">
|
||||
|
||||
Reference in New Issue
Block a user