That's a huge commit if you ask me

This commit is contained in:
Florian Sylvain
2023-02-21 14:00:29 +01:00
parent ce0ab23555
commit a1b8716bc2
13 changed files with 3615 additions and 409 deletions
+16 -5
View File
@@ -1,5 +1,13 @@
import { createRouter, createWebHistory } from 'vue-router'
import GroupSelection from '@/views/GroupSelection.vue'
import { doc, getDoc } from "firebase/firestore"
import { db } from '@/utils/firestore'
import { useSessionStore } from '@/stores/useSessionStore'
async function isGroupOk(id: string): Promise<boolean> {
const docSnap = await getDoc(doc(db, "groups", id))
return docSnap.exists()
}
const router = createRouter({
history: createWebHistory(import.meta.env.BASE_URL),
@@ -10,12 +18,15 @@ const router = createRouter({
component: GroupSelection
},
{
path: '/group',
path: '/group/:groupId',
name: 'Group',
component: GroupSelection,
// beforeEnter: (to, from) => {
// return '/'
// }
component: () => import('@/views/Chat.vue'),
beforeEnter: async (to, from) => {
const sessionStore = useSessionStore()
const userAllowed = await isGroupOk(to.params.groupId as string)
if (!userAllowed) return '/'
sessionStore.groupId = to.params.groupId as string
}
},
]
})