Migrate to Vue 3 and Vite

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel
2022-07-12 10:55:28 +02:00
parent 8f4099ee33
commit ee20e03cc2
464 changed files with 31515 additions and 32758 deletions

View File

@@ -1,22 +1,32 @@
import { IConfig } from "@/types/config.model";
import { ErrorCode } from "@/types/enums";
import { provideApolloClient, useQuery } from "@vue/apollo-composable";
import { NavigationGuard } from "vue-router";
import { CONFIG } from "../../graphql/config";
import apolloProvider from "../../vue-apollo";
import { apolloClient } from "../../vue-apollo";
import { ErrorRouteName } from "../error";
export const beforeRegisterGuard: NavigationGuard = async (to, from, next) => {
const { data } = await apolloProvider.defaultClient.query({
query: CONFIG,
const { onResult, onError } = provideApolloClient(apolloClient)(() =>
useQuery<{ config: IConfig }>(CONFIG)
);
onResult(({ data }) => {
const { config } = data;
if (!config.registrationsOpen && !config.registrationsAllowlist) {
return next({
name: ErrorRouteName.ERROR,
query: { code: ErrorCode.REGISTRATION_CLOSED },
});
}
return next();
});
const { config } = data;
if (!config.registrationsOpen && !config.registrationsAllowlist) {
return next({
name: ErrorRouteName.ERROR,
query: { code: ErrorCode.REGISTRATION_CLOSED },
});
}
onError((err) => {
console.error(err);
return next();
});
return next();
};