Environments in URL and better rendering

This commit is contained in:
Gregory Schier
2023-10-25 11:13:00 -07:00
parent 3b660ddbd0
commit 33c406ce49
44 changed files with 226 additions and 160 deletions

View File

@@ -3,17 +3,13 @@ import type { Environment } from '../lib/models';
import { useActiveEnvironmentId } from './useActiveEnvironmentId';
import { useEnvironments } from './useEnvironments';
export function useActiveEnvironment(): [Environment | null, (environment: Environment) => void] {
const [id, setId] = useActiveEnvironmentId();
export function useActiveEnvironment(): Environment | null {
const id = useActiveEnvironmentId();
const environments = useEnvironments();
const environment = useMemo(
() => environments.find((w) => w.id === id) ?? null,
[environments, id],
);
const setActiveEnvironment = useCallback((e: Environment) => {
setId(e.id)
}, [setId]);
return [environment, setActiveEnvironment];
return environment;
}