useSchemasForAi.ts20 lines · main
1import { LOCAL_STORAGE_KEYS } from 'common'
2import { Dispatch, SetStateAction } from 'react'
3
4import { useLocalStorageQuery } from '@/hooks/misc/useLocalStorage'
5
6/**
7 * Returns which schemas are ok to be sent to AI.
8 */
9export function useSchemasForAi(
10 ref: string
11): readonly [string[], Dispatch<SetStateAction<string[]>>] {
12 const [enabledSchemas, setEnabledSchemas] = useLocalStorageQuery(
13 LOCAL_STORAGE_KEYS.SQL_EDITOR_AI_SCHEMA(ref),
14 ['public']
15 )
16
17 if (!ref) return [[], () => {}]
18
19 return [enabledSchemas, setEnabledSchemas]
20}