Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

Rev 1316 | Rev 2468 | 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">
1318 steven 25
          <h2 className="card-title" style={{
26
            fontSize: '1.7rem'
27
          }}>Notificaciones</h2>
1311 steven 28
            <div className="messages-sec">
29
              <table className="table table-striped">
30
                <tbody>
31
                  {
32
                    !!notifications.length && (
33
                      notifications.map((element, i) => {
34
                        return(
35
                          <tr key={i.toString()}>
36
                            <td>
1314 steven 37
                              <div
1316 steven 38
                                className="row w-100"
1314 steven 39
                              >
40
                                <div
1316 steven 41
                                  className="col-md-6 col-sm-12"
1314 steven 42
                                >
43
                                  <a href={element.link}>
44
                                    {element.message}
45
                                  </a>
46
                                </div>
47
                                <div
1316 steven 48
                                  className="col-md-6 col-sm-12 text-right w-100"
1314 steven 49
                                >
50
                                  <span className="w-100 text-right"> {element.time_elapsed} </span>
51
                                </div>
52
                              </div>
1311 steven 53
                            </td>
54
                          </tr>
55
                        )
56
                      })
1310 steven 57
                    )
1311 steven 58
                  }
59
                </tbody>
60
              </table>
61
            </div>
62
          </div>
1309 steven 63
        </div>
64
      </div>
65
    </section>
1307 steven 66
  )
67
}