-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.vue
67 lines (60 loc) · 2.27 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
<script lang="ts" setup>
// import { initializeApp, FirebaseOptions } from 'firebase/app';
// import { signInWithPopup, GoogleAuthProvider, signOut, signInWithRedirect } from "firebase/auth"
import { collection } from "firebase/firestore";
// import { useFirebaseApp, useFirebaseAuth, useFirestore, useCollection } from 'vuefire';
// const auth = useFirebaseAuth()
// const user = useCurrentUser()
console.log('🔥 -- inside App');
const firestore = useFirestore()
console.log('🔥 -- after firestore', firestore)
const testCollection = collection(firestore, "test-collection")
console.log('🔥 -- after test collection', testCollection);
const testCollectionData = useCollection(testCollection)
console.log('🔥 -- after test collection data', testCollectionData);
// const loginPopup = () => {
// if (auth) {
// signInWithPopup(auth, new GoogleAuthProvider())
// }
// }
// const loginRedirect = () => {
// if (auth) {
// signInWithRedirect(auth, new GoogleAuthProvider())
// }
// }
// const logout = () => {
// if (auth) {
// signOut(auth)
// }
// }
</script>
<template>
<div>
<h1>I am a worker.</h1>
<ClientOnly>
<h1>This is Client Only: {{ new Date() }} {{ Date.now() }}</h1>
</ClientOnly>
<h2>This should come from the server: {{ new Date() }} {{ Date.now() }}</h2>
<!-- <div v-if="user === null">
<button @click="loginPopup">Login (Popup)</button>
<button @click="loginRedirect">Login (Redirect)</button>
</div>
<button v-else @click="logout">Logout</button>
<div>
<h2>Server Info (individual user fields work on server and should SSR):</h2>
<div v-if="user">{{ user.uid }} | {{ user.email }}</div>
<div v-else>No user logged in on server</div>
</div>
<ClientOnly>
<h2>Client Info (toJSON / stringify of `user` fails on server):</h2>
<code><pre>{{ JSON.stringify(user, null, 2) }}</pre></code>
</ClientOnly>
<hr> -->
<!-- <div>
<h2>SSR Data from Firestore:</h2>
<div v-for="test in testCollection" :key="test.id">
<div>hello: "{{ test.hello }}" (between quotes comes from firestore)</div>
</div>
</div> -->
</div>
</template>