diff --git a/src/web/src/components/QuestionsRenderer.vue b/src/web/src/components/QuestionsRenderer.vue index c4ce656..93b3324 100644 --- a/src/web/src/components/QuestionsRenderer.vue +++ b/src/web/src/components/QuestionsRenderer.vue @@ -33,28 +33,42 @@ const questionGroups = computed(() => { let index = 0; for (let question of survey.value.questions) { + console.log("Q", index, question.isVisible); + if (question.TYPE == "title_question") { question.subQuestions = []; lastTitle = question; - question.questionIndex = index; + + if (question.isVisible) { + question.questionIndex = index; + index++; + } + list.push(question); - index++; } else if (question.TYPE == "matrix_question") { if (lastTitle) lastTitle.subQuestions.push(question); } else if (question.TYPE == "quadrant_title") { question.subQuestions = []; lastTitle = question; - question.questionIndex = index; + + if (question.isVisible) { + question.questionIndex = index; + index++; + } + list.push(question); - index++; } else if (question.TYPE == "quadrant") { if (lastTitle) lastTitle.subQuestions.push(question); } else if (question.TYPE == "text") { list.push(question); } else { - question.questionIndex = index; + + if (question.isVisible) { + question.questionIndex = index; + index++; + } + list.push(question); - index++; } } } diff --git a/src/web/src/modules/administration/router/index.ts b/src/web/src/modules/administration/router/index.ts index 3f35a8f..ae307f9 100644 --- a/src/web/src/modules/administration/router/index.ts +++ b/src/web/src/modules/administration/router/index.ts @@ -1,6 +1,6 @@ import { authGuard } from "@auth0/auth0-vue"; import { RouteLocation } from "vue-router"; -import { useUserStore } from "@/store/UserStore"; +import { User, useUserStore } from "@/store/UserStore"; const routes = [ { @@ -101,7 +101,7 @@ async function requireAccess(to: RouteLocation): Promise { return true; } -export async function waitForUserToLoad(): Promise { +export async function waitForUserToLoad(): Promise { let u = useUserStore(); await u.initialize(); return u.user; diff --git a/src/web/src/store/UserStore.ts b/src/web/src/store/UserStore.ts index a4af673..4371e20 100644 --- a/src/web/src/store/UserStore.ts +++ b/src/web/src/store/UserStore.ts @@ -6,18 +6,7 @@ import { PROFILE_URL } from "@/urls"; export const useUserStore = defineStore("user", { state: () => ({ isLoading: true, - user: { - display_name: "", - first_name: "", - last_name: "", - email: "", - EMAIL: "", - ynet_id: "", - sub: "", - STATUS: "", - ROLE: "", - IS_ADMIN: "", - }, + user: null as User | null, }), getters: { isAdmin(state) { @@ -26,7 +15,7 @@ export const useUserStore = defineStore("user", { }, actions: { async initialize() { - if (!this.user.sub) { + if (!this.user || !this.user.sub) { await this.loadCurrentUser(); console.log("Initialized user store"); } @@ -40,9 +29,25 @@ export const useUserStore = defineStore("user", { .then((resp) => { this.user = resp.data; }) + .catch(() => { + this.user = null; + }) .finally(() => { this.isLoading = false; }); }, }, }); + +export type User = { + display_name: string; + first_name: string; + last_name: string; + email: string; + EMAIL: string; + ynet_id: string; + sub: string; + STATUS: string; + ROLE: string; + IS_ADMIN: string; +};