Proyectos de Subversion LeadersLinked - SPA

Rev

Rev 3432 | | Comparar con el anterior | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
3719 stevensc 1
import React, { useEffect, useState } from 'react';
2
import { useDispatch } from 'react-redux';
3
 
4
import { axios } from '@utils/index.js';
5
import { addNotification } from '@app/redux/notification/notification.actions';
6
 
7
import Table from '@components/table/Table';
8
 
9
const DevicesColumns = [
10
  {
11
    field: 'platform',
12
    headerName: 'Plataforma'
13
  },
14
  {
15
    field: 'brand',
16
    headerName: 'Marca'
17
  },
18
  {
19
    field: 'manufacturer',
20
    headerName: 'Fabricante'
21
  },
22
  {
23
    field: 'model',
24
    headerName: 'Modelo'
25
  },
26
  {
27
    field: 'version',
28
    headerName: 'Versión'
29
  },
30
  {
31
    field: 'ip',
32
    headerName: 'IP'
33
  },
34
  {
35
    field: 'updated_on',
36
    headerName: 'Fecha'
37
  }
38
];
39
 
40
const Devices = () => {
41
  const [devices, setDevices] = useState({});
42
  const dispatch = useDispatch();
43
 
44
  const getDevices = () => {
45
    axios
46
      .get('/account-settings/devices')
47
      .then((response) => {
48
        const { data, success } = response.data;
49
 
50
        if (!success) {
51
          throw new Error('Error interno. Por favor, intente mas tarde');
52
        }
53
 
54
        setDevices(data);
55
      })
56
      .catch((err) => {
57
        dispatch(addNotification({ style: 'danger', msg: err.message }));
58
      });
59
  };
60
 
61
  useEffect(() => {
62
    getDevices();
63
  }, []);
64
 
65
  return (
66
    <div className='acc-setting'>
67
      <h3>Navegadores</h3>
68
      <div className='cp-field mb-3'>
69
        <Table columns={DevicesColumns} rows={devices.items} />
70
      </div>
71
    </div>
72
  );
73
};
74
 
75
export default Devices;