Proyectos de Subversion LeadersLinked - SPA

Rev

Rev 3432 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

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