wip: Remove old code
This commit is contained in:
parent
e955d6dddc
commit
06572c9e1f
|
|
@ -4,17 +4,12 @@ import type {
|
|||
DashboardConfigType,
|
||||
} from "@/gql/graphql";
|
||||
import type { DashboardCourseConfigType } from "@/services/dashboard";
|
||||
import {
|
||||
fetchDashboardConfig,
|
||||
fetchDashboardConfigv2,
|
||||
fetchStatisticData,
|
||||
} from "@/services/dashboard";
|
||||
import { 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<DashboardConfigType[]> = ref([]);
|
||||
const dashboardConfigsv2: Ref<DashboardCourseConfigType[]> = ref([]);
|
||||
const currentDashboardConfig: Ref<DashboardConfigType | undefined> = ref();
|
||||
const dashBoardDataCache: Record<
|
||||
|
|
@ -25,55 +20,16 @@ export const useDashboardStore = defineStore("dashboard", () => {
|
|||
ref(null);
|
||||
const loading = ref(false);
|
||||
|
||||
// const loadDashboardData = async (type: DashboardType, id: string) => {
|
||||
// let data;
|
||||
// switch (type) {
|
||||
// case "STATISTICS_DASHBOARD":
|
||||
// data = await fetchStatisticData(id);
|
||||
// break;
|
||||
// case "PROGRESS_DASHBOARD":
|
||||
// data = await fetchProgressData(id);
|
||||
// break;
|
||||
// default:
|
||||
// return;
|
||||
// }
|
||||
// dashBoardDataCache[id] = data;
|
||||
// currentDashBoardData.value = data;
|
||||
// };
|
||||
|
||||
const switchAndLoadDashboardConfig = async (config: DashboardConfigType) => {
|
||||
currentDashboardConfig.value = config;
|
||||
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();
|
||||
console.log("got dashboard config v2: ", dashboardConfigsv2.value);
|
||||
try {
|
||||
// if (!currentDashboardConfig.value) {
|
||||
// await loadDashboardConfig();
|
||||
// return;
|
||||
// }
|
||||
// const { id, dashboard_type } = currentDashboardConfig.value;
|
||||
// if (dashBoardDataCache[id]) {
|
||||
// currentDashBoardData.value = dashBoardDataCache[id];
|
||||
// return;
|
||||
// }
|
||||
// // await loadDashboardData(dashboard_type, id);
|
||||
} finally {
|
||||
console.log("done loading dashboard details");
|
||||
loading.value = false;
|
||||
}
|
||||
loading.value = false;
|
||||
};
|
||||
|
||||
const loadStatisticsData = async (id: string) => {
|
||||
|
|
@ -89,11 +45,9 @@ export const useDashboardStore = defineStore("dashboard", () => {
|
|||
};
|
||||
|
||||
return {
|
||||
dashboardConfigs,
|
||||
dashboardConfigsv2,
|
||||
currentDashboardConfig,
|
||||
switchAndLoadDashboardConfig,
|
||||
loadDashboardConfig,
|
||||
loadDashboardDetails,
|
||||
currentDashBoardData,
|
||||
loading,
|
||||
|
|
|
|||
Loading…
Reference in New Issue