fix: persist environment selection in Zustand store instead of URL params
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:
20
ui/src/api/environment-store.ts
Normal file
20
ui/src/api/environment-store.ts
Normal 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 });
|
||||
},
|
||||
}));
|
||||
Reference in New Issue
Block a user