Extract base environment (#149)

This commit is contained in:
Gregory Schier
2024-12-21 05:44:55 -08:00
committed by GitHub
parent ecabe9b6ef
commit dd8ccfe21f
28 changed files with 425 additions and 387 deletions

View File

@@ -1,14 +1,11 @@
import { getRouteApi, useSearch } from '@tanstack/react-router';
import { useCallback, useMemo } from 'react';
import { useCallback } from 'react';
import { useEnvironments } from './useEnvironments';
export function useActiveEnvironment() {
const [id, setId] = useActiveEnvironmentId();
const environments = useEnvironments();
const environment = useMemo(
() => environments.find((w) => w.id === id) ?? null,
[environments, id],
);
const { subEnvironments } = useEnvironments();
const environment = subEnvironments.find((w) => w.id === id) ?? null;
return [environment, setId] as const;
}