import { request, unwrapApiBody, type ApiResponse } from '../utils/http/factory' export type GlobalConfig = { allowRegister: boolean } type GlobalConfigResult = { config: GlobalConfig } const DEFAULT_GLOBAL_CONFIG: GlobalConfig = { allowRegister: true, } export function useGlobalConfig() { const { data, pending, error, refresh } = useAsyncData( 'global:config', async () => { const payload = await request>('/api/config/global') return unwrapApiBody(payload).config }, { default: () => ({ ...DEFAULT_GLOBAL_CONFIG }), }, ) const config = computed(() => data.value ?? DEFAULT_GLOBAL_CONFIG) return { config, allowRegister: computed(() => config.value.allowRegister), pending, error, refresh, } }