From 4b8ae76132d2342f40cec703b3d5145ea075c451 Mon Sep 17 00:00:00 2001 From: vnugent Date: Wed, 13 Dec 2023 17:58:51 -0500 Subject: log time coming ui and lib updates --- front-end/src/store/index.ts | 49 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 front-end/src/store/index.ts (limited to 'front-end/src/store/index.ts') diff --git a/front-end/src/store/index.ts b/front-end/src/store/index.ts new file mode 100644 index 0000000..924bf1b --- /dev/null +++ b/front-end/src/store/index.ts @@ -0,0 +1,49 @@ +import { useSession } from "@vnuge/vnlib.browser"; +import { set } from "@vueuse/core"; +import { defineStore } from "pinia"; +import { computed, shallowRef } from "vue"; + +/** + * Loads the main store for the application + */ +export const useStore = defineStore('main', () => { + + const { loggedIn, isLocalAccount } = useSession(); + + //MANAGED STATE + const headerRoutes = shallowRef(Array()); + const authRoutes = shallowRef(Array()); + const siteTitle = shallowRef(""); + const pageTitle = shallowRef(""); + const showCookieWarning = shallowRef(!navigator.cookieEnabled); //Default to current cookie status + + /** + * The current routes to display in the header depending on the + * user's login status + */ + const currentRoutes = computed(() => loggedIn.value ? authRoutes.value : headerRoutes.value); + + const setHeaderRouteNames = (routeNames: string[], authRouteNames: string[]) => { + set(headerRoutes, [...routeNames]); + set(authRoutes, [...authRouteNames]); + } + + const setSiteTitle = (title: string) => set(siteTitle, title); + const setPageTitle = (title: string) => set(pageTitle, title); + const setCookieWarning = (show: boolean) => set(showCookieWarning, show); + + return{ + loggedIn, + isLocalAccount, + headerRoutes, + authRoutes, + siteTitle, + pageTitle, + showCookieWarning, + setCookieWarning, + setPageTitle, + currentRoutes, + setHeaderRouteNames, + setSiteTitle + } +}) -- cgit