Pair checkboxes and fix twig indent

This commit is contained in:
Gregory Schier
2023-03-20 00:03:33 -07:00
parent ae65f222bc
commit 90294fbb5d
23 changed files with 286 additions and 115 deletions

View File

@@ -16,16 +16,15 @@ export function keyValueQueryKey({
export function useKeyValue<T extends string | number | boolean>({
namespace = DEFAULT_NAMESPACE,
key,
initialValue,
defaultValue,
}: {
namespace?: string;
key: string | string[];
initialValue: T;
defaultValue: T;
}) {
const query = useQuery<T>({
initialData: initialValue,
queryKey: keyValueQueryKey({ namespace, key }),
queryFn: async () => getKeyValue({ namespace, key, fallback: initialValue }),
queryFn: async () => getKeyValue({ namespace, key, fallback: defaultValue }),
});
const mutate = useMutation<T, unknown, T>({
@@ -34,6 +33,7 @@ export function useKeyValue<T extends string | number | boolean>({
return {
value: query.data,
isLoading: query.isLoading,
set: (value: T) => mutate.mutate(value),
};
}

View File

@@ -1,10 +1,10 @@
import { useKeyValue } from './useKeyValue';
export function useResponseViewMode(requestId?: string): [string, () => void] {
export function useResponseViewMode(requestId?: string): [string | undefined, () => void] {
const v = useKeyValue<string>({
namespace: 'app',
key: ['response_view_mode', requestId ?? 'n/a'],
initialValue: 'pretty',
defaultValue: 'pretty',
});
const toggle = () => {