import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
import { useDb } from '../db/dbContext.js';
import { getUserContext, updateUserContext, } from '../models/userContext.js';
export const useUserContext = () => {
    const db = useDb();
    return useQuery({
        queryKey: ['userContext'],
        queryFn: () => getUserContext(db),
    });
};
export const useUpdateUserContext = () => {
    const queryClient = useQueryClient();
    const db = useDb();
    return useMutation({
        mutationFn: (context) => updateUserContext(db, context),
        onSuccess: () => {
            queryClient.invalidateQueries({ queryKey: ['userContext'] });
        },
    });
};
