Files
cameleer-server/ui/src/api/environment-store.ts

21 lines
529 B
TypeScript
Raw Normal View History

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 });
},
}));