Skip to content
This repository has been archived by the owner on Mar 19, 2024. It is now read-only.

Commit

Permalink
merge: from feat/public-projects
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinKanera authored Jan 27, 2021
2 parents 2ab35a3 + 1c0063f commit 49257c1
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 24 deletions.
20 changes: 10 additions & 10 deletions components/navbar/navbar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
.user-wrap
.avatar-wrap(v-if='mainStore.isLoggedIn')
img.avatar(:src='mainStore.profilePicture')/
.user-info
.user-info.flex(@click='toggleSettings', v-on-clickaway='closeSettings')
.user-text(v-if='mainStore.isLoggedIn')
span.user-name {{ mainStore.displayName }}
span.user-role(v-if='mainStore.isTeacher && !mainStore.isAdmin') Učitel
Expand All @@ -14,15 +14,12 @@
ps-btn(text, @click='loginModal = !loginModal') Přihlášení
template(#icon-right)
arrow-right/
ps-modal(v-model='loginModal')
.flex.justify-center
ps-login-form
.flex.justify-center.items-center.relative(v-if='mainStore.isLoggedIn', v-on-clickaway='closeSettings')
drop-down.drop(:class='{ "active-drop": displaySettings }', @click='toggleSettings')/
ps-dropdown(:value='displaySettings')
ps-btn.text-ps-red(block, text, @click='logOut') Odhlásit
template(#icon-left)
logout/
.flex.justify-center.items-center.relative(v-if='mainStore.isLoggedIn')
drop-down.drop(:class='{ "active-drop": displaySettings }')/
ps-dropdown(:value='displaySettings')
ps-btn.text-ps-red(block, text, @click='logOut') Odhlásit
template(#icon-left)
logout/
.flex.justify-center.items-center.relative(v-if='mainStore.isLoggedIn', v-on-clickaway='closeNotifications')
.notifications-number(@click='toggleNotifications')
span {{ notificationsLength }}
Expand All @@ -31,6 +28,9 @@
ps-notifications-list(@update-notifications='updateNotifications')
.menu-btn(v-if='!isDesktop', @click='toggleBurger')
.burger(:class='{ active: burger }')
ps-modal(v-model='loginModal')
.flex.justify-center
ps-login-form
</template>

<script lang="ts">
Expand Down
6 changes: 2 additions & 4 deletions pages/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
</template>

<script lang="ts">
import { defineComponent, ref, watchEffect, computed, useContext, useFetch, onMounted, ssrRef, onBeforeUnmount, watch } from '@nuxtjs/composition-api';
import { defineComponent, ref, watchEffect, computed, useContext, useFetch, onMounted } from '@nuxtjs/composition-api';
import { useMainStore } from '@/store';
import firebase from 'firebase/app';
Expand Down Expand Up @@ -89,7 +89,7 @@ export default defineComponent({
btnLoading.value = false;
};
const lastProjectId = ssrRef('');
const lastProjectId = ref('');
const publicProjects = ref([] as Array<PublicProject>);
const { fetch } = useFetch(async () => {
Expand Down Expand Up @@ -120,8 +120,6 @@ export default defineComponent({
fetch();
};
onBeforeUnmount(() => (lastProjectId.value = ''));
return {
yearModalDisplay,
currentYear,
Expand Down
18 changes: 8 additions & 10 deletions server/api/public-projects/get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@ const formatProjectsData = async (projects: admin.firestore.QuerySnapshot<admin.
transaction,
);

return students.docs.map((student) => {
const currentProject = projects.docs.find((project) => project.data().studentId === student.id);
return projects.docs.map((project) => {
const currentStudent = students.docs.find((student) => project.data().studentId === student.id);

return {
id: currentProject?.id,
title: currentProject?.data().title,
description: currentProject?.data().description,
displayName: student.data().displayName,
profilePicture: student.data().profilePicture,
year: (currentProject?.data()?.currentYear as admin.firestore.Timestamp).toDate().getFullYear(),
id: project.id,
title: project.data().title,
description: project.data().description,
displayName: currentStudent?.data().displayName,
profilePicture: currentStudent?.data().profilePicture,
year: (project.data()?.currentYear as admin.firestore.Timestamp).toDate().getFullYear(),
};
});
};
Expand All @@ -33,8 +33,6 @@ export default async (req: Request, res: Response) => {
const limit = 10;

try {
console.log(lastProjectId);

const projects = await admin.firestore().runTransaction(async (transaction) => {
if (!lastProjectId) {
const projects = await transaction.get(admin.firestore().collection('projects').where('public', '==', true).orderBy('currentYear', 'desc').limit(limit));
Expand Down

0 comments on commit 49257c1

Please sign in to comment.