Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

Rev 1310 | Rev 1312 | 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">
25
          <h5 className="card-title">Notificaciones</h5>
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>
35
                              <a href={element.link}>
36
                                {element.message}
37
                                <span> {element.time_elapsed} </span>
38
                              </a>
39
                            </td>
40
                          </tr>
41
                        )
42
                      })
1310 steven 43
                    )
1311 steven 44
                  }
45
                </tbody>
46
              </table>
47
            </div>
48
          </div>
1309 steven 49
        </div>
50
      </div>
51
    </section>
1307 steven 52
  )
53
}