2022-09-15 19:15:07 +02:00
|
|
|
<template>
|
2022-09-20 15:53:44 +02:00
|
|
|
<div v-if="!userLoaded" class="bg-neutral-100 dark:bg-neutral-900 text-primary h-screen flex flex-col">
|
|
|
|
Loading
|
|
|
|
</div>
|
|
|
|
<div v-else>
|
|
|
|
<div v-if="isAuthenticated" class="bg-neutral-100 dark:bg-neutral-900 text-primary h-screen flex flex-col">
|
|
|
|
<LayoutTopbar />
|
|
|
|
<div class="overflow-y-auto pt-3">
|
|
|
|
<NuxtPage />
|
|
|
|
</div>
|
|
|
|
<LayoutNavbar class="mt-auto" />
|
|
|
|
</div>
|
|
|
|
<div v-else class="bg-neutral-100 dark:bg-neutral-900 text-primary h-screen flex flex-col">
|
|
|
|
<Login />
|
2022-09-19 15:11:13 +02:00
|
|
|
</div>
|
2022-09-15 19:15:07 +02:00
|
|
|
</div>
|
2022-09-19 09:36:47 +02:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script setup>
|
2022-09-20 15:53:44 +02:00
|
|
|
import { doc, getFirestore, serverTimestamp, writeBatch, collection, getDocs } from "firebase/firestore";
|
|
|
|
import { getAuth, onAuthStateChanged, signInWithEmailAndPassword } from "firebase/auth";
|
2022-09-19 09:36:47 +02:00
|
|
|
|
|
|
|
const db = getFirestore()
|
2022-09-20 15:53:44 +02:00
|
|
|
const route = useRoute()
|
|
|
|
|
|
|
|
const isAuthenticated = ref(false)
|
|
|
|
const user = ref('frikandel')
|
|
|
|
const auth = ref(null)
|
|
|
|
const userLoaded = ref(false)
|
|
|
|
|
|
|
|
onMounted(() => {
|
|
|
|
auth.value = getAuth()
|
|
|
|
|
|
|
|
onAuthStateChanged(auth.value, (usr) => {
|
|
|
|
if (usr) {
|
|
|
|
isAuthenticated.value = true
|
|
|
|
user.value = usr
|
|
|
|
} else {
|
|
|
|
isAuthenticated.value = false
|
|
|
|
user.value = null
|
|
|
|
}
|
|
|
|
|
|
|
|
userLoaded.value = true
|
|
|
|
})
|
|
|
|
})
|
2022-09-19 09:36:47 +02:00
|
|
|
|
2022-09-19 15:11:13 +02:00
|
|
|
const ledenlijst = ref([])
|
2022-09-19 09:36:47 +02:00
|
|
|
|
2022-09-19 15:11:13 +02:00
|
|
|
|
2022-09-20 15:53:44 +02:00
|
|
|
provide('firebase', { db, ledenlijst, isAuthenticated, user, auth })
|
2022-09-19 09:36:47 +02:00
|
|
|
</script>
|