-
Notifications
You must be signed in to change notification settings - Fork 5
/
App.vue
101 lines (84 loc) · 2.79 KB
/
App.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
<template>
<Head>
<title>{{ isLevante ? '' : 'ROAR:' }} {{ pageTitle }}</title>
<meta name="description" content="A web-based tool to query ROAR assessment data!" />
<!-- Social -->
<meta property="og:title" content="ROAR Web Query" />
<meta property="og:description" content="A web-based tool to query ROAR assessment data!" />
<!-- Twitter -->
<meta name="twitter:title" content="ROAR Web Query" />
<meta name="twitter:description" content="A web-based tool to query ROAR assessment data!" />
</Head>
<div>
<PvToast />
<NavBar v-if="!navbarBlacklist.includes($route.name) && isAuthStoreReady" />
<router-view :key="$route.fullPath" />
<SessionTimer v-if="loadSessionTimeoutHandler" />
</div>
<VueQueryDevtools />
</template>
<script setup>
// @TODO: Make conditional import for local dev environment only.
import { VueQueryDevtools } from '@tanstack/vue-query-devtools';
import { computed, onBeforeMount, ref, defineAsyncComponent } from 'vue';
import { useRoute } from 'vue-router';
import { useRecaptchaProvider } from 'vue-recaptcha';
import { Head } from '@unhead/vue/components';
import NavBar from '@/components/NavBar.vue';
const SessionTimer = defineAsyncComponent(() => import('@/containers/SessionTimer/SessionTimer.vue'));
import { useAuthStore } from '@/store/auth';
import { fetchDocById } from '@/helpers/query/utils';
import { i18n } from '@/translations/i18n';
const isLevante = import.meta.env.MODE === 'LEVANTE';
const isAuthStoreReady = ref(false);
const authStore = useAuthStore();
const route = useRoute();
const pageTitle = computed(() => {
const locale = i18n.global.locale.value;
const fallbackLocale = i18n.global.fallbackLocale.value;
return route.meta?.pageTitle?.[locale] || route.meta?.pageTitle?.[fallbackLocale] || route.meta?.pageTitle;
});
const loadSessionTimeoutHandler = computed(() => isAuthStoreReady.value && authStore.isAuthenticated);
useRecaptchaProvider();
const navbarBlacklist = ref([
'SignIn',
'Register',
'Maintenance',
'PlayApp',
'SWR',
'SWR-ES',
'SRE',
'SRE-ES',
'PA',
'PA-ES',
'Letter',
'Letter-ES',
'Vocab',
'Multichoice',
'Morphology',
'Cva',
'Fluency-ARF',
'Fluency-ARF-ES',
'Fluency-CALF',
'Fluency-CALF-ES',
'Fluency-Alpaca',
'Fluency-Alpaca-ES',
'RAN',
'Crowding',
'MEP',
]);
onBeforeMount(async () => {
await authStore.initFirekit();
authStore.setUser();
await authStore.initStateFromRedirect().then(async () => {
if (authStore.uid) {
const userData = await fetchDocById('users', authStore.uid);
const userClaims = await fetchDocById('userClaims', authStore.uid);
authStore.userData = userData;
authStore.userClaims = userClaims;
authStore.updateTasksDictionary();
}
});
isAuthStoreReady.value = true;
});
</script>