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';
5
import { addNotification } from '@app/redux/notification/notification.actions';
6
 
7
import Table from '@components/table/Table';
8
 
9
const IPColumns = [
10
  {
11
    field: 'ip',
12
    headerName: 'IP'
13
  },
14
  {
15
    field: 'country_name',
16
    headerName: 'País'
17
  },
18
  {
19
    field: 'state_name',
20
    headerName: 'Estado'
21
  },
22
  {
23
    field: 'city',
24
    headerName: 'Ciudad'
25
  },
26
  {
27
    field: 'postal_code',
28
    headerName: 'Código Postal'
29
  }
30
];
31
 
32
const Ips = () => {
33
  const [ips, setIps] = useState({});
34
  const dispatch = useDispatch();
35
 
36
  const getDevices = () => {
37
    axios
38
      .get('/account-settings/ips')
39
      .then((response) => {
40
        const { data, success } = response.data;
41
 
42
        if (!success) {
43
          throw new Error('Error interno. Por favor, intente mas tarde');
44
        }
45
 
46
        setIps(data);
47
      })
48
      .catch((err) => {
49
        dispatch(addNotification({ style: 'danger', msg: err.message }));
50
      });
51
  };
52
 
53
  useEffect(() => {
54
    getDevices();
55
  }, []);
56
 
57
  return (
58
    <div className='acc-setting'>
59
      <h3>Navegadores</h3>
60
      <div className='cp-field mb-3'>
61
        <Table columns={IPColumns} rows={ips.items} />
62
      </div>
63
    </div>
64
  );
65
};
66
 
67
export default Ips;