import { VuexModule, getModule, Module, Mutation } from 'vuex-module-decorators'
import { Store } from 'vuex'
import LocalStorageHelper from '../helpers/LocalStorageHelper'

@Module({
  name: 'NotificationsConfigStore',
  namespaced: true,
})
export default class NotificationsConfigStore extends VuexModule {
  notificationsCount = 5
  notificationDuration = 20 // cек
  isShowConfig = false
  isMuted = false

  @Mutation
  setNotificationCount(value: number) {
    this.notificationsCount = value
    LocalStorageHelper.saveNotificationsCount(value)
  }

  @Mutation
  setNotificationDuration(value: number) {
    this.notificationDuration = value
    LocalStorageHelper.saveDuration(value)
  }

  @Mutation
  setIsMuted(value: boolean) {
    this.isMuted = value
    LocalStorageHelper.saveIsMuted(value)
  }

  @Mutation
  setIsShowConfig(value: boolean) {
    this.isShowConfig = value
  }
}

export function getNotificationsConfigStore(store: Store<any>) {
  return getModule(NotificationsConfigStore, store)
}
