Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

Rev 1313 | Rev 1316 | Ir a la última revisión | | Comparar con el anterior | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1309 steven 1
import React from 'react';
2
import { useState } from 'react';
3
import { useLayoutEffect } from 'react';
4
import { axios } from '../utils';
1307 steven 5
 
1309 steven 6
export default () => {
7
  const [notifications, setNotifications] = useState([]);
8
  const handleNotifications = async () => {
1310 steven 9
    try {
10
      console.log('>>: _notifications ', notifications)
11
      const _notifications = await axios.get('/notifications');
12
      setNotifications(_notifications.data.data)
13
    } catch (error) {
14
      console.log('>>: error > ', error)
15
    }
1309 steven 16
  }
17
  useLayoutEffect(() => {
18
    handleNotifications();
19
  }, []);
1307 steven 20
  return (
1309 steven 21
    <section className="notifications-page">
1311 steven 22
      <div className="card">
23
        <div className="card-body">
24
          <div className="container">
1312 steven 25
          <h2 className="card-title">Notificaciones</h2>
1311 steven 26
            <div className="messages-sec">
27
              <table className="table table-striped">
28
                <tbody>
29
                  {
30
                    !!notifications.length && (
31
                      notifications.map((element, i) => {
32
                        return(
33
                          <tr key={i.toString()}>
34
                            <td>
1314 steven 35
                              <div
36
                                className="row"
37
                              >
38
                                <div
39
                                  className="col-6 col-sm-12"
40
                                >
41
                                  <a href={element.link}>
42
                                    {element.message}
43
                                  </a>
44
                                </div>
45
                                <div
46
                                  className="col-6 col-sm-12 text-right w-100"
47
                                >
48
                                  <span className="w-100 text-right"> {element.time_elapsed} </span>
49
                                </div>
50
                              </div>
1311 steven 51
                            </td>
52
                          </tr>
53
                        )
54
                      })
1310 steven 55
                    )
1311 steven 56
                  }
57
                </tbody>
58
              </table>
59
            </div>
60
          </div>
1309 steven 61
        </div>
62
      </div>
63
    </section>
1307 steven 64
  )
65
}