Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

Rev 1309 | Rev 1311 | Ir a la última revisión | Autoría | Comparar con el anterior | Ultima modificación | Ver Log |

import React from 'react';
import { useState } from 'react';
import { useLayoutEffect } from 'react';
import { axios } from '../utils';

export default () => {
  const [notifications, setNotifications] = useState([]);
  const handleNotifications = async () => {
    try {
      console.log('>>: _notifications ', notifications)
      const _notifications = await axios.get('/notifications');
      setNotifications(_notifications.data.data)
    } catch (error) {
      console.log('>>: error > ', error)
    }
  }
  useLayoutEffect(() => {
    handleNotifications();
  }, []);
  return (
    <section className="notifications-page">
      <div className="container">
        <div
          className='w-100'
        >
          <h1>Notificaciones</h1>
        </div>
        <div className="messages-sec">
          <table class="table table-striped">
            <tbody>
              {
                !!notifications.length && (
                  notifications.map((element, i) => {
                    return(
                      <tr key={i.toString()}>
                        <td>
                          <a href={element.link}>
                            {element.message}
                            <span> {element.time_elapsed} </span>
                          </a>
                        </td>
                      </tr>
                    )
                  })
                )
              }
            </tbody>
          </table>
        </div>
      </div>
    </section>
  )
}