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>
21 lines
529 B
TypeScript
21 lines
529 B
TypeScript
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 });
|
|
},
|
|
}));
|