fix: moved isSidebarCollapsed value to globalStore

This commit is contained in:
Shariq Ansari 2024-01-29 22:53:49 +05:30
parent a5071a1be2
commit fe047ace93
2 changed files with 14 additions and 2 deletions

View File

@ -94,12 +94,16 @@ import NotificationsIcon from '@/components/Icons/NotificationsIcon.vue'
import SidebarLink from '@/components/SidebarLink.vue' import SidebarLink from '@/components/SidebarLink.vue'
import { viewsStore } from '@/stores/views' import { viewsStore } from '@/stores/views'
import { notificationsStore } from '@/stores/notifications' import { notificationsStore } from '@/stores/notifications'
import { useStorage } from '@vueuse/core' import { globalStore } from '@/stores/global'
import { computed } from 'vue' import { computed } from 'vue'
const { getPinnedViews, getPublicViews } = viewsStore() const { getPinnedViews, getPublicViews } = viewsStore()
const { toggle: toggleNotificationPanel } = notificationsStore() const { toggle: toggleNotificationPanel } = notificationsStore()
const isSidebarCollapsed = useStorage('sidebar_is_collapsed', false)
const isSidebarCollapsed = computed({
get: () => globalStore().isSidebarCollapsed,
set: (value) => globalStore().setIsSidebarCollapsed(value),
})
const links = [ const links = [
{ {

View File

@ -1,3 +1,4 @@
import { useStorage } from '@vueuse/core'
import { defineStore } from 'pinia' import { defineStore } from 'pinia'
import { getCurrentInstance, ref } from 'vue' import { getCurrentInstance, ref } from 'vue'
@ -6,6 +7,7 @@ export const globalStore = defineStore('crm-global', () => {
const { $dialog } = app.appContext.config.globalProperties const { $dialog } = app.appContext.config.globalProperties
let twilioEnabled = ref(false) let twilioEnabled = ref(false)
let isSidebarCollapsed = useStorage('isSidebarCollapsed', false)
let callMethod = () => {} let callMethod = () => {}
function setTwilioEnabled(value) { function setTwilioEnabled(value) {
@ -20,9 +22,15 @@ export const globalStore = defineStore('crm-global', () => {
callMethod(number) callMethod(number)
} }
function setIsSidebarCollapsed(value) {
isSidebarCollapsed.value = value
}
return { return {
$dialog, $dialog,
twilioEnabled, twilioEnabled,
isSidebarCollapsed,
setIsSidebarCollapsed,
makeCall, makeCall,
setTwilioEnabled, setTwilioEnabled,
setMakeCall, setMakeCall,