From 50d5c4080d840c652cadeb0ab46b82b247c7eb01 Mon Sep 17 00:00:00 2001 From: Christian Cueni Date: Thu, 13 Jun 2024 15:35:20 +0200 Subject: [PATCH] Revert "wip: Remove old code" This reverts commit 06572c9e1f4969d1d67c73e5902fd360c9a1028e. --- client/src/stores/dashboard.ts | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/client/src/stores/dashboard.ts b/client/src/stores/dashboard.ts index dbcdcae3..69be8744 100644 --- a/client/src/stores/dashboard.ts +++ b/client/src/stores/dashboard.ts @@ -4,12 +4,17 @@ import type { DashboardConfigType, } from "@/gql/graphql"; import type { DashboardCourseConfigType } from "@/services/dashboard"; -import { fetchDashboardConfigv2, fetchStatisticData } from "@/services/dashboard"; +import { + fetchDashboardConfig, + fetchDashboardConfigv2, + fetchStatisticData, +} from "@/services/dashboard"; import { defineStore } from "pinia"; import type { Ref } from "vue"; import { ref } from "vue"; export const useDashboardStore = defineStore("dashboard", () => { + const dashboardConfigs: Ref = ref([]); const dashboardConfigsv2: Ref = ref([]); const currentDashboardConfig: Ref = ref(); const dashBoardDataCache: Record< @@ -25,6 +30,15 @@ export const useDashboardStore = defineStore("dashboard", () => { await loadDashboardDetails(); }; + const loadDashboardConfig = async () => { + if (dashboardConfigs.value.length > 0) return; + const configData = await fetchDashboardConfig(); + if (configData && configData.length > 0) { + dashboardConfigs.value = configData; + await switchAndLoadDashboardConfig(configData[0]); + } + }; + const loadDashboardDetails = async () => { loading.value = true; dashboardConfigsv2.value = await fetchDashboardConfigv2(); @@ -45,9 +59,11 @@ export const useDashboardStore = defineStore("dashboard", () => { }; return { + dashboardConfigs, dashboardConfigsv2, currentDashboardConfig, switchAndLoadDashboardConfig, + loadDashboardConfig, loadDashboardDetails, currentDashBoardData, loading,