fix: persist environment selection in Zustand store instead of URL params
All checks were successful
CI / cleanup-branch (push) Has been skipped
CI / build (push) Successful in 1m5s
CI / docker (push) Successful in 57s
CI / deploy-feature (push) Has been skipped
CI / deploy (push) Successful in 36s

Environment selector was losing its value on navigation because URL search
params were silently dropped by navigate() calls. Moved to a Zustand store
with localStorage persistence so the selection survives navigation, page
refresh, and new tabs. Switching environment now resets all filters, clears
URL params, invalidates queries, and remounts pages via Outlet key. Also
syncs openapi.json schema with running backend.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
hsiegeln
2026-04-04 17:12:16 +02:00
parent 37eb56332a
commit 69055f7d74
4 changed files with 157 additions and 42 deletions

View File

@@ -0,0 +1,20 @@
import { create } from 'zustand';
const STORAGE_KEY = 'cameleer-environment';
interface EnvironmentState {
environment: string | undefined;
setEnvironment: (env: string | undefined) => void;
}
export const useEnvironmentStore = create<EnvironmentState>((set) => ({
environment: localStorage.getItem(STORAGE_KEY) || undefined,
setEnvironment: (env) => {
if (env) {
localStorage.setItem(STORAGE_KEY, env);
} else {
localStorage.removeItem(STORAGE_KEY);
}
set({ environment: env });
},
}));