Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

Rev 5399 | Ir a la última revisión | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 5399 Rev 5753
Línea -... Línea 1...
-
 
1
import { axios } from '../../utils'
1
import { intlTypes } from './intl.types'
2
import { intlTypes } from './intl.types'
Línea -... Línea 3...
-
 
3
 
-
 
4
export const getLanguage = () => {
-
 
5
  return async (dispatch) => {
-
 
6
    try {
-
 
7
      const { data: response } = await axios.get('/language')
-
 
8
      const { success, data } = response
-
 
9
 
-
 
10
      if (!success) {
-
 
11
        throw new Error(data.message)
-
 
12
      }
-
 
13
 
-
 
14
      dispatch(setIntlLabels(labelsAdapter(data)))
-
 
15
    } catch (error) {
-
 
16
      throw new Error(error)
-
 
17
    }
-
 
18
  }
-
 
19
}
-
 
20
 
-
 
21
const labelsAdapter = (labels) => {
-
 
22
  const newKeys = Object.entries(labels).map(([key, value]) => [
-
 
23
    key.replace('LABEL_', '').toLowerCase(),
-
 
24
    value,
-
 
25
  ])
-
 
26
 
-
 
27
  return Object.fromEntries(newKeys)
-
 
28
}
2
 
29
 
3
export const setIntlLabels = (labels) => ({
30
export const setIntlLabels = (labels) => ({
4
  type: intlTypes.SET_LABELS,
31
  type: intlTypes.SET_LABELS,
5
  payload: labels
32
  payload: labels,