Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

Rev 1309 | Rev 1311 | 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">
22
      <div className="container">
23
        <div
24
          className='w-100'
25
        >
26
          <h1>Notificaciones</h1>
27
        </div>
28
        <div className="messages-sec">
1310 steven 29
          <table class="table table-striped">
30
            <tbody>
31
              {
32
                !!notifications.length && (
33
                  notifications.map((element, i) => {
34
                    return(
35
                      <tr key={i.toString()}>
36
                        <td>
37
                          <a href={element.link}>
38
                            {element.message}
39
                            <span> {element.time_elapsed} </span>
40
                          </a>
41
                        </td>
42
                      </tr>
43
                    )
44
                  })
45
                )
46
              }
47
            </tbody>
48
          </table>
1309 steven 49
        </div>
50
      </div>
51
    </section>
1307 steven 52
  )
53
}