diff --git a/src/shared/stores/events/events-store.ts b/src/shared/stores/events/events-store.ts index 5186e835..60ea9cc4 100644 --- a/src/shared/stores/events/events-store.ts +++ b/src/shared/stores/events/events-store.ts @@ -34,6 +34,7 @@ export const useEventsStore = defineStore("eventsStore", { projects: { available: [] as TProjects['data'], activeKey: null as string | null, + default: null as string | null, } }), getters: { @@ -217,6 +218,9 @@ export const useEventsStore = defineStore("eventsStore", { this.projects.activeKey = null; removeStoredProject(); + }, + setDefaultProject(key: string) { + this.projects.default = key; } }, }); diff --git a/src/shared/stores/settings/settings-store.ts b/src/shared/stores/settings/settings-store.ts index dcbc66da..67cbac80 100644 --- a/src/shared/stores/settings/settings-store.ts +++ b/src/shared/stores/settings/settings-store.ts @@ -1,6 +1,7 @@ import {defineStore} from "pinia"; import {useSettings} from "../../lib/use-settings"; import type { TSettings } from "../../types"; +import {useEventsStore} from "../events/events-store"; import {THEME_MODES} from "./constants"; import { getStoredEventsCountVisibility, @@ -26,8 +27,9 @@ export const useSettingsStore = defineStore("settingsStore", { actions: { initialize() { const {api: { getSettings }} = useSettings(); + const { setDefaultProject } = useEventsStore(); - getSettings().then(({ version, auth } = {} as TSettings) => { + getSettings().then(({ version, auth, project } = {} as TSettings) => { if (version) { this.apiVersion = version } @@ -36,6 +38,11 @@ export const useSettingsStore = defineStore("settingsStore", { this.auth.isEnabled = auth.enabled; this.auth.loginUrl = auth.login_url; } + + if (project.default) { + // TODO: need to load default project within project request + setDefaultProject(project.default) + } }) }, changeTheme() { diff --git a/src/shared/types/settings.ts b/src/shared/types/settings.ts index f5d1bca8..01c16413 100644 --- a/src/shared/types/settings.ts +++ b/src/shared/types/settings.ts @@ -10,6 +10,9 @@ export type TSettings = { login_url: string, }, version: string, + project: { + default: string, + } }