feat: persist crafting zone selection in sessionStorage #49

Merged
naomi merged 1 commits from fix/crafting-zone into main 2026-03-09 22:25:18 -07:00
Showing only changes of commit f7053dcf2f - Show all commits
@@ -26,7 +26,9 @@ const bonusLabel: Record<string, string> = {
*/
const CraftingPanel = (): JSX.Element => {
const { state, craftRecipe, formatNumber } = useGame();
const [ activeZoneId, setActiveZoneId ] = useState("verdant_vale");
const [ activeZoneId, setActiveZoneId ] = useState(() => {
return sessionStorage.getItem("elysium_craft_zone") ?? "verdant_vale";
});
const [ pendingRecipeId, setPendingRecipeId ] = useState<string | null>(null);
if (state === null) {
@@ -68,6 +70,11 @@ const CraftingPanel = (): JSX.Element => {
});
}
function handleZoneSelect(zoneId: string): void {
setActiveZoneId(zoneId);
sessionStorage.setItem("elysium_craft_zone", zoneId);
}
async function handleCraft(recipeId: string): Promise<void> {
setPendingRecipeId(recipeId);
try {
@@ -85,7 +92,7 @@ const CraftingPanel = (): JSX.Element => {
<ZoneSelector
activeZoneId={activeZoneId}
onSelectZone={setActiveZoneId}
onSelectZone={handleZoneSelect}
zones={zones}
/>