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