Proyectos de Subversion LeadersLinked - SPA

Rev

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

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