277 lines
7.3 KiB
TypeScript
277 lines
7.3 KiB
TypeScript
import { TIMEZONES, CONFIG } from "@/graphql/config";
|
|
import { IConfig } from "@/types/config.model";
|
|
import { useQuery } from "@vue/apollo-composable";
|
|
import { computed } from "vue";
|
|
|
|
export function useTimezones() {
|
|
const {
|
|
result: timezoneResult,
|
|
error,
|
|
loading,
|
|
} = useQuery<{
|
|
config: Pick<IConfig, "timezones">;
|
|
}>(TIMEZONES, undefined, { fetchPolicy: "cache-first" });
|
|
|
|
const timezones = computed(() => timezoneResult.value?.config?.timezones);
|
|
return { timezones, error, loading };
|
|
}
|
|
|
|
export function useAnonymousParticipationConfig() {
|
|
const {
|
|
result: configResult,
|
|
error,
|
|
loading,
|
|
} = useQuery<{
|
|
config: Pick<IConfig, "anonymous">;
|
|
}>(CONFIG);
|
|
|
|
const anonymousParticipationConfig = computed(
|
|
() => configResult.value?.config?.anonymous?.participation
|
|
);
|
|
|
|
return { anonymousParticipationConfig, error, loading };
|
|
}
|
|
|
|
export function useExternalURLSConfig() {
|
|
const {
|
|
result: configResult,
|
|
error,
|
|
loading,
|
|
} = useQuery<{
|
|
config: Pick<IConfig, "externalUrls">;
|
|
}>(CONFIG);
|
|
|
|
const externalURLSConfig = computed(
|
|
() => configResult.value?.config?.externalUrls
|
|
);
|
|
|
|
return { externalURLSConfig, error, loading };
|
|
}
|
|
|
|
export function useAnonymousReportsConfig() {
|
|
const {
|
|
result: configResult,
|
|
error,
|
|
loading,
|
|
} = useQuery<{
|
|
config: Pick<IConfig, "anonymous">;
|
|
}>(CONFIG);
|
|
|
|
const anonymousReportsConfig = computed(
|
|
() => configResult.value?.config?.anonymous?.reports
|
|
);
|
|
return { anonymousReportsConfig, error, loading };
|
|
}
|
|
|
|
export function useInstanceName() {
|
|
const { result, error, loading } = useQuery<{
|
|
config: Pick<IConfig, "name">;
|
|
}>(CONFIG);
|
|
|
|
const instanceName = computed(() => result.value?.config?.name);
|
|
return { instanceName, error, loading };
|
|
}
|
|
|
|
export function useInstanceLogoUrl() {
|
|
const { result, error, loading } = useQuery<{
|
|
config: Pick<IConfig, "instanceLogo">;
|
|
}>(CONFIG);
|
|
|
|
const instanceLogoUrl = computed(
|
|
() => result.value?.config?.instanceLogo?.url
|
|
);
|
|
return { instanceLogoUrl, error, loading };
|
|
}
|
|
|
|
export function useColors() {
|
|
const { result, error, loading } = useQuery<{
|
|
config: Pick<IConfig, "primaryColor" | "secondaryColor">;
|
|
}>(CONFIG);
|
|
|
|
const primaryColor = computed(() => result.value?.config?.primaryColor);
|
|
const secondaryColor = computed(() => result.value?.config?.secondaryColor);
|
|
return { primaryColor, secondaryColor, error, loading };
|
|
}
|
|
|
|
export function useDefaultPicture() {
|
|
const { result, error, loading } = useQuery<{
|
|
config: Pick<IConfig, "defaultPicture">;
|
|
}>(CONFIG);
|
|
|
|
const defaultPicture = computed(() => result.value?.config?.defaultPicture);
|
|
return { defaultPicture, error, loading };
|
|
}
|
|
|
|
export function useAnonymousActorId() {
|
|
const { result, error, loading } = useQuery<{
|
|
config: Pick<IConfig, "anonymous">;
|
|
}>(CONFIG);
|
|
|
|
const anonymousActorId = computed(
|
|
() => result.value?.config?.anonymous?.actorId
|
|
);
|
|
return { anonymousActorId, error, loading };
|
|
}
|
|
|
|
export function useUploadLimits() {
|
|
const { result, error, loading } = useQuery<{
|
|
config: Pick<IConfig, "uploadLimits">;
|
|
}>(CONFIG);
|
|
|
|
const uploadLimits = computed(() => result.value?.config?.uploadLimits);
|
|
return { uploadLimits, error, loading };
|
|
}
|
|
|
|
export function useEventCategories() {
|
|
const { result, error, loading } = useQuery<{
|
|
config: Pick<IConfig, "eventCategories">;
|
|
}>(CONFIG);
|
|
|
|
const eventCategories = computed(() => result.value?.config.eventCategories);
|
|
return { eventCategories, error, loading };
|
|
}
|
|
|
|
export function useRestrictions() {
|
|
const { result, error, loading } = useQuery<{
|
|
config: Pick<IConfig, "restrictions">;
|
|
}>(CONFIG);
|
|
|
|
const restrictions = computed(() => result.value?.config.restrictions);
|
|
return { restrictions, error, loading };
|
|
}
|
|
|
|
export function useExportFormats() {
|
|
const { result, error, loading } = useQuery<{
|
|
config: Pick<IConfig, "exportFormats">;
|
|
}>(CONFIG);
|
|
const exportFormats = computed(() => result.value?.config?.exportFormats);
|
|
return { exportFormats, error, loading };
|
|
}
|
|
|
|
export function useGeocodingAutocomplete() {
|
|
const { result, error, loading } = useQuery<{
|
|
config: Pick<IConfig, "geocoding">;
|
|
}>(CONFIG);
|
|
const geocodingAutocomplete = computed(
|
|
() => result.value?.config?.geocoding?.autocomplete
|
|
);
|
|
return { geocodingAutocomplete, error, loading };
|
|
}
|
|
|
|
export function useMapTiles() {
|
|
const { result, error, loading } = useQuery<{
|
|
config: Pick<IConfig, "maps">;
|
|
}>(CONFIG);
|
|
|
|
const tiles = computed(() => result.value?.config.maps.tiles);
|
|
return { tiles, error, loading };
|
|
}
|
|
|
|
export function useRoutingType() {
|
|
const { result, error, loading } = useQuery<{
|
|
config: Pick<IConfig, "maps">;
|
|
}>(CONFIG);
|
|
|
|
const routingType = computed(() => result.value?.config.maps.routing.type);
|
|
return { routingType, error, loading };
|
|
}
|
|
|
|
export function useFeatures() {
|
|
const { result, error, loading } = useQuery<{
|
|
config: Pick<IConfig, "features">;
|
|
}>(CONFIG);
|
|
|
|
const features = computed(() => result.value?.config.features);
|
|
return { features, error, loading };
|
|
}
|
|
|
|
export function useResourceProviders() {
|
|
const { result, error, loading } = useQuery<{
|
|
config: Pick<IConfig, "resourceProviders">;
|
|
}>(CONFIG);
|
|
|
|
const resourceProviders = computed(
|
|
() => result.value?.config.resourceProviders
|
|
);
|
|
return { resourceProviders, error, loading };
|
|
}
|
|
|
|
export function useServerProvidedLocation() {
|
|
const { result, error, loading } = useQuery<{
|
|
config: Pick<IConfig, "location">;
|
|
}>(CONFIG);
|
|
|
|
const location = computed(() => result.value?.config.location);
|
|
return { location, error, loading };
|
|
}
|
|
|
|
export function useIsDemoMode() {
|
|
const { result, error, loading } = useQuery<{
|
|
config: Pick<IConfig, "demoMode">;
|
|
}>(CONFIG);
|
|
|
|
const isDemoMode = computed(() => result.value?.config.demoMode);
|
|
return { isDemoMode, error, loading };
|
|
}
|
|
|
|
export function useIsLongEvents() {
|
|
const { result, error, loading } = useQuery<{
|
|
config: Pick<IConfig, "longEvents">;
|
|
}>(CONFIG);
|
|
|
|
const isLongEvents = computed(() => result.value?.config.longEvents);
|
|
return { isLongEvents, error, loading };
|
|
}
|
|
|
|
export function useAnalytics() {
|
|
const { result, error, loading } = useQuery<{
|
|
config: Pick<IConfig, "analytics">;
|
|
}>(CONFIG);
|
|
|
|
const analytics = computed(() => result.value?.config.analytics);
|
|
return { analytics, error, loading };
|
|
}
|
|
|
|
export function useSearchConfig() {
|
|
const { result, error, loading, onResult } = useQuery<{
|
|
config: Pick<IConfig, "search">;
|
|
}>(CONFIG);
|
|
|
|
const searchConfig = computed(() => result.value?.config.search);
|
|
return { searchConfig, error, loading, onResult };
|
|
}
|
|
|
|
export function useRegistrationConfig() {
|
|
const { result, error, loading, onResult } = useQuery<{
|
|
config: Pick<
|
|
IConfig,
|
|
| "registrationsOpen"
|
|
| "registrationsModeration"
|
|
| "registrationsAllowlist"
|
|
| "auth"
|
|
>;
|
|
}>(CONFIG);
|
|
|
|
const registrationsOpen = computed(
|
|
() => result.value?.config?.registrationsOpen
|
|
);
|
|
const registrationsModeration = computed(
|
|
() => result.value?.config?.registrationsModeration
|
|
);
|
|
const registrationsAllowlist = computed(
|
|
() => result.value?.config?.registrationsAllowlist
|
|
);
|
|
const databaseLogin = computed(
|
|
() => result.value?.config?.auth?.databaseLogin
|
|
);
|
|
return {
|
|
registrationsOpen,
|
|
registrationsModeration,
|
|
registrationsAllowlist,
|
|
databaseLogin,
|
|
error,
|
|
loading,
|
|
onResult,
|
|
};
|
|
}
|