mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-01-15 13:43:39 +01:00
19 lines
596 B
TypeScript
19 lines
596 B
TypeScript
import { useQuery } from '@tanstack/react-query';
|
|
import { invoke } from '@tauri-apps/api';
|
|
import type { EnvironmentVariable } 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('cmd_list_variables', { environmentId })) as EnvironmentVariable[];
|
|
},
|
|
}).data ?? []
|
|
);
|
|
}
|