mirror of
https://github.com/Crosstalk-Solutions/project-nomad.git
synced 2026-03-28 11:39:26 +01:00
23 lines
621 B
TypeScript
23 lines
621 B
TypeScript
import { useQuery, UseQueryOptions } from '@tanstack/react-query'
|
|
import api from '~/lib/api'
|
|
import { KVStoreKey } from '../../types/kv_store';
|
|
|
|
export type UseSystemSettingProps = Omit<
|
|
UseQueryOptions<{ key: string; value: any } | undefined>,
|
|
'queryKey' | 'queryFn'
|
|
> & {
|
|
key: KVStoreKey
|
|
}
|
|
|
|
export const useSystemSetting = (props: UseSystemSettingProps) => {
|
|
const { key, ...queryOptions } = props
|
|
|
|
const queryData = useQuery<{ key: string; value: any } | undefined>({
|
|
...queryOptions,
|
|
queryKey: ['system-setting', key],
|
|
queryFn: async () => await api.getSetting(key),
|
|
})
|
|
|
|
return queryData
|
|
}
|