// noinspection DuplicatedCode // noinspection DuplicatedCode import Vue from 'vue'; import VueCompositionAPI, { computed, reactive } from '@vue/composition-api'; // We need to register it again because of Vue instance instantiation issues Vue.use(VueCompositionAPI); const state = reactive({ isCartSidebarOpen: false, isLoginModalOpen: false, isCategoryGridView: true, isFilterSidebarOpen: false, isNavigationSidebarOpen: false }); // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types const useUiState = () => { const isCartSidebarOpen = computed(() => state.isCartSidebarOpen); const toggleCartSidebar = () => { state.isCartSidebarOpen = !state.isCartSidebarOpen; }; const isNavigationSidebarOpen = computed(() => state.isNavigationSidebarOpen); const toggleNavigationSidebar = () => { state.isNavigationSidebarOpen = !state.isNavigationSidebarOpen; }; const isLoginModalOpen = computed(() => state.isLoginModalOpen); const toggleLoginModal = () => { state.isLoginModalOpen = !state.isLoginModalOpen; }; const isCategoryGridView = computed(() => state.isCategoryGridView); const toggleCategoryGridView = () => { state.isCategoryGridView = !state.isCategoryGridView; }; const isFilterSidebarOpen = computed(() => state.isFilterSidebarOpen); const toggleFilterSidebar = () => { state.isFilterSidebarOpen = !state.isFilterSidebarOpen; }; return { isCartSidebarOpen, isLoginModalOpen, isCategoryGridView, isFilterSidebarOpen, isNavigationSidebarOpen, toggleCartSidebar, toggleLoginModal, toggleCategoryGridView, toggleFilterSidebar, toggleNavigationSidebar }; }; export default useUiState;