mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-03-17 23:14:03 +01:00
Variables under Environment, and render all props
This commit is contained in:
18
src-web/hooks/useVariables.ts
Normal file
18
src-web/hooks/useVariables.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import { useQuery } from '@tanstack/react-query';
|
||||
import { invoke } from '@tauri-apps/api';
|
||||
import type { Variable } from '../lib/models';
|
||||
|
||||
export function variablesQueryKey({ environmentId }: { environmentId: string }) {
|
||||
return ['variables', { environmentId }];
|
||||
}
|
||||
|
||||
export function useVariables({ environmentId }: { environmentId: string }) {
|
||||
return (
|
||||
useQuery({
|
||||
queryKey: variablesQueryKey({ environmentId }),
|
||||
queryFn: async () => {
|
||||
return (await invoke('list_variables', { environmentId })) as Variable[];
|
||||
},
|
||||
}).data ?? []
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user