Skip to content

Commit

Permalink
user dashboard added
Browse files Browse the repository at this point in the history
  • Loading branch information
S-kus committed Mar 29, 2022
1 parent 3f7892c commit 21d29e7
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 14 deletions.
1 change: 1 addition & 0 deletions project-tech/src/components/Navbar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<h1><router-link :to="{ name: 'Home' }">Project.Tech</router-link></h1>
<div class="links">
<div v-if="user">
<router-link :to="{ name: 'Home'}">Home</router-link>
<router-link :to="{ name: 'CreateProjectlist' }">Create Projectlist</router-link>
<router-link :to="{ name: 'UserProjectlists' }">My Projectlists</router-link>
<span>Hi there, {{ user.displayName }}</span>
Expand Down
6 changes: 5 additions & 1 deletion project-tech/src/composables/getCollection.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ref, watchEffect } from 'vue'
import { projectFirestore } from '../firebase/config'

const getCollection = (collection) => {
const getCollection = (collection, query) => {

const documents = ref(null)
const error = ref(null)
Expand All @@ -10,6 +10,10 @@ const getCollection = (collection) => {
let collectionRef = projectFirestore.collection(collection)
.orderBy('createdAt')

if (query) {
collectionRef = collectionRef.where(...query)
}

const unsub = collectionRef.onSnapshot(snap => {
let results = []
snap.docs.forEach(doc => {
Expand Down
26 changes: 13 additions & 13 deletions project-tech/src/views/projectlists/UserProjectlists.vue
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<template>
<div class="user-playlists">
<h2>My Playlists</h2>
<!-- <div v-if="playlists">
<ListView :playlists="playlists" />
<h2>My Projectlists</h2>
<div v-if="projectlists">
<ListView :projectlists="projectlists" />
</div>
<router-link :to="{ name: 'CreatePlaylist' }" class="btn">Create a New Playlist</router-link> -->
<router-link :to="{ name: 'CreateProjectlist' }" class="btn">Create a New Projectlist</router-link>
</div>
</template>

Expand All @@ -14,16 +14,16 @@ import getCollection from '@/composables/getCollection'
import ListView from '@/components/ListView.vue'
export default {
// components: { ListView },
// setup() {
// const { user } = getUser()
// const { documents: playlists } = getCollection(
// 'playlists',
// ['userId', '==', user.value.uid]
// )
components: { ListView },
setup() {
const { user } = getUser()
const { documents: projectlists } = getCollection(
'projectlists',
['userId', '==', user.value.uid]
)
// return { playlists }
// }
return { projectlists }
}
}
</script>

Expand Down

0 comments on commit 21d29e7

Please sign in to comment.