resources/js/frontend/store/modules/lang.js   A
last analyzed

Complexity

Total Complexity 4
Complexity/F 1

Size

Lines of Code 32
Function Count 4

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 16
c 0
b 0
f 0
dl 0
loc 32
rs 10
wmc 4
mnd 0
bc 0
fnc 4
bpm 0
cpm 1
noi 0
1
import Cookies from 'js-cookie'
2
import * as types from '../mutation-types'
3
4
const { locale, locales } = window.config
5
6
// state
7
export const state = {
8
  locale: Cookies.get('locale') || locale,
9
  locales: locales
10
}
11
12
// getters
13
export const getters = {
14
  locale: state => state.locale,
15
  locales: state => state.locales
16
}
17
18
// mutations
19
export const mutations = {
20
  [types.SET_LOCALE] (state, { locale }) {
21
    state.locale = locale
22
  }
23
}
24
25
// actions
26
export const actions = {
27
  setLocale ({ commit }, { locale }) {
28
    commit(types.SET_LOCALE, { locale })
29
30
    Cookies.set('locale', locale, { expires: 365 })
31
  }
32
}
33