Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

Rev 2469 | Rev 2471 | 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';
2468 stevensc 4
import ProfileInfo from '../dashboard/components/home-section/ProfileInfo';
5
import SocialNetworks from '../dashboard/components/home-section/SocialNetworks';
1309 steven 6
import { axios } from '../utils';
1307 steven 7
 
2470 stevensc 8
const Notifications = ({ backendVars }) => {
2468 stevensc 9
 
2470 stevensc 10
  const { image, fullName, country, visits, connections, description } = backendVars
1309 steven 11
  const [notifications, setNotifications] = useState([]);
2468 stevensc 12
 
1309 steven 13
  const handleNotifications = async () => {
1310 steven 14
    try {
15
      const _notifications = await axios.get('/notifications');
16
      setNotifications(_notifications.data.data)
2468 stevensc 17
      console.log('>>: _notifications ', notifications)
1310 steven 18
    } catch (error) {
19
      console.log('>>: error > ', error)
20
    }
1309 steven 21
  }
2468 stevensc 22
 
1309 steven 23
  useLayoutEffect(() => {
24
    handleNotifications();
25
  }, []);
2468 stevensc 26
 
1307 steven 27
  return (
1309 steven 28
    <section className="notifications-page">
2468 stevensc 29
      <div className="card notifications-grid">
30
        <div className='main-left-sidebar'>
31
          <ProfileInfo
32
            image={image}
33
            fullName={fullName}
34
            description={description}
35
            visits={visits}
36
            country={country}
37
            connections={connections}
38
          />
39
          <SocialNetworks />
40
        </div>
1311 steven 41
        <div className="card-body">
42
          <div className="container">
2468 stevensc 43
            <h2 className="card-title" style={{
44
              fontSize: '1.7rem'
45
            }}>Notificaciones</h2>
1311 steven 46
            <div className="messages-sec">
47
              <table className="table table-striped">
48
                <tbody>
49
                  {
50
                    !!notifications.length && (
51
                      notifications.map((element, i) => {
2468 stevensc 52
                        return (
1311 steven 53
                          <tr key={i.toString()}>
54
                            <td>
1314 steven 55
                              <div
1316 steven 56
                                className="row w-100"
1314 steven 57
                              >
58
                                <div
1316 steven 59
                                  className="col-md-6 col-sm-12"
1314 steven 60
                                >
61
                                  <a href={element.link}>
62
                                    {element.message}
63
                                  </a>
64
                                </div>
65
                                <div
1316 steven 66
                                  className="col-md-6 col-sm-12 text-right w-100"
1314 steven 67
                                >
68
                                  <span className="w-100 text-right"> {element.time_elapsed} </span>
69
                                </div>
70
                              </div>
1311 steven 71
                            </td>
72
                          </tr>
73
                        )
74
                      })
1310 steven 75
                    )
1311 steven 76
                  }
77
                </tbody>
78
              </table>
79
            </div>
80
          </div>
1309 steven 81
        </div>
82
      </div>
2468 stevensc 83
    </section >
1307 steven 84
  )
85
}
2469 stevensc 86
export default Notifications