tianji/src/client/hooks/useConfig.ts
2024-02-17 11:45:11 +08:00

21 lines
447 B
TypeScript

import { AppRouterOutput, trpc } from '../api/trpc';
const defaultGlobalConfig: AppRouterOutput['global']['config'] = {
allowRegister: false,
alphaMode: false,
};
/**
* Fetch settings from server
*/
export function useGlobalConfig(): AppRouterOutput['global']['config'] {
const { data = defaultGlobalConfig } = trpc.global.config.useQuery(
undefined,
{
staleTime: 1000 * 60 * 60 * 1, // 1 hour
}
);
return data;
}