JSONPath filter plugins working

This commit is contained in:
Gregory Schier
2024-01-15 15:06:49 -08:00
parent d23de93917
commit 13307a76af
9 changed files with 434 additions and 277 deletions

View File

@@ -0,0 +1,23 @@
import { useQuery } from '@tanstack/react-query';
import { invoke } from '@tauri-apps/api';
export function useFilterResponse({
responseId,
filter,
}: {
responseId: string | null;
filter: string;
}) {
return (
useQuery<string | null>({
queryKey: [responseId, filter],
queryFn: async () => {
if (filter === '') {
return null;
}
return (await invoke('filter_response', { responseId, filter })) as string | null;
},
}).data ?? null
);
}

View File

@@ -0,0 +1,7 @@
import { useCallback, useState } from 'react';
export function useToggle(initialValue = false) {
const [value, setValue] = useState<boolean>(initialValue);
const toggle = useCallback(() => setValue((v) => !v), []);
return [value, toggle] as const;
}