Remove useNavigate everywhere, and make request a query param. And convert dialog to Jotai

This commit is contained in:
Gregory Schier
2025-01-06 16:54:07 -08:00
parent 806a8eb801
commit bc50891edb
54 changed files with 592 additions and 545 deletions

View File

@@ -1,9 +1,10 @@
import { useNavigate, useSearch } from '@tanstack/react-router';
import { useSearch } from '@tanstack/react-router';
import type { Environment } from '@yaakapp-internal/models';
import { useAtomValue } from 'jotai';
import { atom } from 'jotai/index';
import { useCallback, useEffect } from 'react';
import { jotaiStore } from '../lib/jotai';
import { router } from '../lib/router';
import { environmentsAtom } from './useEnvironments';
export const QUERY_ENVIRONMENT_ID = 'environment_id';
@@ -16,13 +17,13 @@ export const activeEnvironmentAtom = atom<Environment | null>((get) => {
});
export function useActiveEnvironment() {
const navigate = useNavigate({ from: '/workspaces/$workspaceId' });
const setId = useCallback(
(id: string | null) =>
navigate({
router.navigate({
from: '/workspaces/$workspaceId',
search: (prev) => ({ ...prev, environment_id: id }),
}),
[navigate],
[],
);
const environment = useAtomValue(activeEnvironmentAtom);
return [environment, setId] as const;