mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-03-27 20:01:10 +01:00
Some fixes around environments
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { getRouteApi, useSearch } from '@tanstack/react-router';
|
||||
import { useNavigate, useSearch } from '@tanstack/react-router';
|
||||
import { useCallback } from 'react';
|
||||
import { useEnvironments } from './useEnvironments';
|
||||
|
||||
@@ -11,17 +11,15 @@ export function useActiveEnvironment() {
|
||||
|
||||
export const QUERY_ENVIRONMENT_ID = 'environment_id';
|
||||
|
||||
const routeApi = getRouteApi('/workspaces/$workspaceId/');
|
||||
|
||||
function useActiveEnvironmentId() {
|
||||
// NOTE: This query param is accessed from Rust side, so do not change
|
||||
const { environmentId: id } = useSearch({ strict: false });
|
||||
const navigate = routeApi.useNavigate();
|
||||
const { environment_id: id} = useSearch({ strict: false });
|
||||
const navigate = useNavigate({ from: '/workspaces/$workspaceId' });
|
||||
|
||||
const setId = useCallback(
|
||||
(environment_id: string | null) =>
|
||||
(environmentId: string | null) =>
|
||||
navigate({
|
||||
search: (prev) => ({ ...prev, environment_id: environment_id ?? undefined }),
|
||||
search: (prev) => ({ ...prev, environment_id: environmentId ?? undefined }),
|
||||
}),
|
||||
[navigate],
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user