2022-07-12 10:55:28 +02:00
|
|
|
import {
|
|
|
|
ABOUT,
|
|
|
|
ANALYTICS,
|
|
|
|
ANONYMOUS_ACTOR_ID,
|
|
|
|
ANONYMOUS_PARTICIPATION_CONFIG,
|
|
|
|
ANONYMOUS_REPORTS_CONFIG,
|
|
|
|
DEMO_MODE,
|
|
|
|
EVENT_CATEGORIES,
|
|
|
|
EVENT_PARTICIPANTS,
|
|
|
|
FEATURES,
|
|
|
|
GEOCODING_AUTOCOMPLETE,
|
|
|
|
LOCATION,
|
|
|
|
MAPS_TILES,
|
2022-10-28 12:58:52 +02:00
|
|
|
REGISTRATIONS,
|
2022-07-12 10:55:28 +02:00
|
|
|
RESOURCE_PROVIDERS,
|
|
|
|
RESTRICTIONS,
|
2022-09-20 16:53:26 +02:00
|
|
|
ROUTING_TYPE,
|
2022-08-26 16:08:58 +02:00
|
|
|
SEARCH_CONFIG,
|
2022-07-12 10:55:28 +02:00
|
|
|
TIMEZONES,
|
|
|
|
UPLOAD_LIMITS,
|
|
|
|
} from "@/graphql/config";
|
2022-09-20 16:53:26 +02:00
|
|
|
import { IConfig } from "@/types/config.model";
|
2022-07-12 10:55:28 +02:00
|
|
|
import { useQuery } from "@vue/apollo-composable";
|
2022-09-20 16:53:26 +02:00
|
|
|
import { computed } from "vue";
|
2022-07-12 10:55:28 +02:00
|
|
|
|
|
|
|
export function useTimezones() {
|
|
|
|
const {
|
|
|
|
result: timezoneResult,
|
|
|
|
error,
|
|
|
|
loading,
|
|
|
|
} = useQuery<{
|
|
|
|
config: Pick<IConfig, "timezones">;
|
2022-10-05 17:42:12 +02:00
|
|
|
}>(TIMEZONES, undefined, { fetchPolicy: "cache-first" });
|
2022-07-12 10:55:28 +02:00
|
|
|
|
|
|
|
const timezones = computed(() => timezoneResult.value?.config?.timezones);
|
|
|
|
return { timezones, error, loading };
|
|
|
|
}
|
|
|
|
|
|
|
|
export function useAnonymousParticipationConfig() {
|
2022-09-20 16:53:26 +02:00
|
|
|
const {
|
|
|
|
result: configResult,
|
|
|
|
error,
|
|
|
|
loading,
|
|
|
|
} = useQuery<{
|
|
|
|
config: Pick<IConfig, "anonymous">;
|
2022-10-05 17:42:12 +02:00
|
|
|
}>(ANONYMOUS_PARTICIPATION_CONFIG, undefined, { fetchPolicy: "cache-only" });
|
2022-07-12 10:55:28 +02:00
|
|
|
|
2022-09-20 16:53:26 +02:00
|
|
|
const anonymousParticipationConfig = computed(
|
|
|
|
() => configResult.value?.config?.anonymous?.participation
|
|
|
|
);
|
2022-07-12 10:55:28 +02:00
|
|
|
|
2022-09-20 16:53:26 +02:00
|
|
|
return { anonymousParticipationConfig, error, loading };
|
2022-07-12 10:55:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
export function useAnonymousReportsConfig() {
|
|
|
|
const {
|
|
|
|
result: configResult,
|
|
|
|
error,
|
|
|
|
loading,
|
|
|
|
} = useQuery<{
|
|
|
|
config: Pick<IConfig, "anonymous">;
|
2022-10-05 17:42:12 +02:00
|
|
|
}>(ANONYMOUS_REPORTS_CONFIG, undefined, { fetchPolicy: "cache-only" });
|
2022-07-12 10:55:28 +02:00
|
|
|
|
|
|
|
const anonymousReportsConfig = computed(
|
2022-10-25 19:01:26 +02:00
|
|
|
() => configResult.value?.config?.anonymous?.reports
|
2022-07-12 10:55:28 +02:00
|
|
|
);
|
|
|
|
return { anonymousReportsConfig, error, loading };
|
|
|
|
}
|
|
|
|
|
|
|
|
export function useInstanceName() {
|
|
|
|
const { result, error, loading } = useQuery<{
|
|
|
|
config: Pick<IConfig, "name">;
|
2022-10-05 17:42:12 +02:00
|
|
|
}>(ABOUT, undefined, { fetchPolicy: "cache-only" });
|
2022-07-12 10:55:28 +02:00
|
|
|
|
|
|
|
const instanceName = computed(() => result.value?.config?.name);
|
|
|
|
return { instanceName, error, loading };
|
|
|
|
}
|
|
|
|
|
|
|
|
export function useAnonymousActorId() {
|
|
|
|
const { result, error, loading } = useQuery<{
|
|
|
|
config: Pick<IConfig, "anonymous">;
|
2022-10-05 17:42:12 +02:00
|
|
|
}>(ANONYMOUS_ACTOR_ID, undefined, { fetchPolicy: "cache-only" });
|
2022-07-12 10:55:28 +02:00
|
|
|
|
|
|
|
const anonymousActorId = computed(
|
|
|
|
() => result.value?.config?.anonymous?.actorId
|
|
|
|
);
|
|
|
|
return { anonymousActorId, error, loading };
|
|
|
|
}
|
|
|
|
|
|
|
|
export function useUploadLimits() {
|
|
|
|
const { result, error, loading } = useQuery<{
|
|
|
|
config: Pick<IConfig, "uploadLimits">;
|
2022-10-05 17:42:12 +02:00
|
|
|
}>(UPLOAD_LIMITS, undefined, { fetchPolicy: "cache-only" });
|
2022-07-12 10:55:28 +02:00
|
|
|
|
|
|
|
const uploadLimits = computed(() => result.value?.config?.uploadLimits);
|
|
|
|
return { uploadLimits, error, loading };
|
|
|
|
}
|
|
|
|
|
|
|
|
export function useEventCategories() {
|
|
|
|
const { result, error, loading } = useQuery<{
|
|
|
|
config: Pick<IConfig, "eventCategories">;
|
2022-10-05 17:42:12 +02:00
|
|
|
}>(EVENT_CATEGORIES, undefined, { fetchPolicy: "cache-only" });
|
2022-07-12 10:55:28 +02:00
|
|
|
|
|
|
|
const eventCategories = computed(() => result.value?.config.eventCategories);
|
|
|
|
return { eventCategories, error, loading };
|
|
|
|
}
|
|
|
|
|
|
|
|
export function useRestrictions() {
|
|
|
|
const { result, error, loading } = useQuery<{
|
|
|
|
config: Pick<IConfig, "restrictions">;
|
2022-10-05 17:42:12 +02:00
|
|
|
}>(RESTRICTIONS, undefined, { fetchPolicy: "cache-only" });
|
2022-07-12 10:55:28 +02:00
|
|
|
|
|
|
|
const restrictions = computed(() => result.value?.config.restrictions);
|
|
|
|
return { restrictions, error, loading };
|
|
|
|
}
|
|
|
|
|
|
|
|
export function useExportFormats() {
|
|
|
|
const { result, error, loading } = useQuery<{
|
|
|
|
config: Pick<IConfig, "exportFormats">;
|
2022-10-05 17:42:12 +02:00
|
|
|
}>(EVENT_PARTICIPANTS, undefined, { fetchPolicy: "cache-only" });
|
2022-07-12 10:55:28 +02:00
|
|
|
const exportFormats = computed(() => result.value?.config?.exportFormats);
|
|
|
|
return { exportFormats, error, loading };
|
|
|
|
}
|
|
|
|
|
|
|
|
export function useGeocodingAutocomplete() {
|
|
|
|
const { result, error, loading } = useQuery<{
|
|
|
|
config: Pick<IConfig, "geocoding">;
|
2022-10-05 17:42:12 +02:00
|
|
|
}>(GEOCODING_AUTOCOMPLETE, undefined, { fetchPolicy: "cache-only" });
|
2022-07-12 10:55:28 +02:00
|
|
|
const geocodingAutocomplete = computed(
|
|
|
|
() => result.value?.config?.geocoding?.autocomplete
|
|
|
|
);
|
|
|
|
return { geocodingAutocomplete, error, loading };
|
|
|
|
}
|
|
|
|
|
|
|
|
export function useMapTiles() {
|
|
|
|
const { result, error, loading } = useQuery<{
|
|
|
|
config: Pick<IConfig, "maps">;
|
2022-10-05 17:42:12 +02:00
|
|
|
}>(MAPS_TILES, undefined, { fetchPolicy: "cache-only" });
|
2022-07-12 10:55:28 +02:00
|
|
|
|
|
|
|
const tiles = computed(() => result.value?.config.maps.tiles);
|
|
|
|
return { tiles, error, loading };
|
|
|
|
}
|
|
|
|
|
2022-09-20 16:53:26 +02:00
|
|
|
export function useRoutingType() {
|
|
|
|
const { result, error, loading } = useQuery<{
|
|
|
|
config: Pick<IConfig, "maps">;
|
2022-10-05 17:42:12 +02:00
|
|
|
}>(ROUTING_TYPE, undefined, { fetchPolicy: "cache-only" });
|
2022-09-20 16:53:26 +02:00
|
|
|
|
|
|
|
const routingType = computed(() => result.value?.config.maps.routing.type);
|
|
|
|
return { routingType, error, loading };
|
|
|
|
}
|
|
|
|
|
2022-07-12 10:55:28 +02:00
|
|
|
export function useFeatures() {
|
|
|
|
const { result, error, loading } = useQuery<{
|
|
|
|
config: Pick<IConfig, "features">;
|
2022-10-05 17:42:12 +02:00
|
|
|
}>(FEATURES, undefined, { fetchPolicy: "cache-only" });
|
2022-07-12 10:55:28 +02:00
|
|
|
|
|
|
|
const features = computed(() => result.value?.config.features);
|
|
|
|
return { features, error, loading };
|
|
|
|
}
|
|
|
|
|
|
|
|
export function useResourceProviders() {
|
|
|
|
const { result, error, loading } = useQuery<{
|
|
|
|
config: Pick<IConfig, "resourceProviders">;
|
2022-10-05 17:42:12 +02:00
|
|
|
}>(RESOURCE_PROVIDERS, undefined, { fetchPolicy: "cache-only" });
|
2022-07-12 10:55:28 +02:00
|
|
|
|
|
|
|
const resourceProviders = computed(
|
|
|
|
() => result.value?.config.resourceProviders
|
|
|
|
);
|
|
|
|
return { resourceProviders, error, loading };
|
|
|
|
}
|
|
|
|
|
|
|
|
export function useServerProvidedLocation() {
|
|
|
|
const { result, error, loading } = useQuery<{
|
|
|
|
config: Pick<IConfig, "location">;
|
2022-10-05 17:42:12 +02:00
|
|
|
}>(LOCATION, undefined, { fetchPolicy: "cache-only" });
|
2022-07-12 10:55:28 +02:00
|
|
|
|
|
|
|
const location = computed(() => result.value?.config.location);
|
|
|
|
return { location, error, loading };
|
|
|
|
}
|
|
|
|
|
|
|
|
export function useIsDemoMode() {
|
|
|
|
const { result, error, loading } = useQuery<{
|
|
|
|
config: Pick<IConfig, "demoMode">;
|
2022-10-05 17:42:12 +02:00
|
|
|
}>(DEMO_MODE, undefined, { fetchPolicy: "cache-only" });
|
2022-07-12 10:55:28 +02:00
|
|
|
|
|
|
|
const isDemoMode = computed(() => result.value?.config.demoMode);
|
|
|
|
return { isDemoMode, error, loading };
|
|
|
|
}
|
|
|
|
|
|
|
|
export function useAnalytics() {
|
|
|
|
const { result, error, loading } = useQuery<{
|
|
|
|
config: Pick<IConfig, "analytics">;
|
2022-10-05 17:42:12 +02:00
|
|
|
}>(ANALYTICS, undefined, { fetchPolicy: "cache-only" });
|
2022-07-12 10:55:28 +02:00
|
|
|
|
|
|
|
const analytics = computed(() => result.value?.config.analytics);
|
|
|
|
return { analytics, error, loading };
|
|
|
|
}
|
2022-08-26 16:08:58 +02:00
|
|
|
|
|
|
|
export function useSearchConfig() {
|
|
|
|
const { result, error, loading, onResult } = useQuery<{
|
|
|
|
config: Pick<IConfig, "search">;
|
2022-10-05 17:42:12 +02:00
|
|
|
}>(SEARCH_CONFIG, undefined, { fetchPolicy: "cache-only" });
|
2022-08-26 16:08:58 +02:00
|
|
|
|
|
|
|
const searchConfig = computed(() => result.value?.config.search);
|
|
|
|
return { searchConfig, error, loading, onResult };
|
|
|
|
}
|
2022-10-28 12:58:52 +02:00
|
|
|
|
|
|
|
export function useRegistrationConfig() {
|
|
|
|
const { result, error, loading, onResult } = useQuery<{
|
|
|
|
config: Pick<IConfig, "registrationsOpen" | "registrationsAllowlist">;
|
|
|
|
}>(REGISTRATIONS, undefined, { fetchPolicy: "cache-only" });
|
|
|
|
|
|
|
|
const registrationsOpen = computed(
|
|
|
|
() => result.value?.config.registrationsOpen
|
|
|
|
);
|
|
|
|
const registrationsAllowlist = computed(
|
|
|
|
() => result.value?.config.registrationsAllowlist
|
|
|
|
);
|
|
|
|
return {
|
|
|
|
registrationsOpen,
|
|
|
|
registrationsAllowlist,
|
|
|
|
error,
|
|
|
|
loading,
|
|
|
|
onResult,
|
|
|
|
};
|
|
|
|
}
|