Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

Rev 2476 | Rev 2611 | 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">
2478 stevensc 30
        <div className='main-left-sidebar' style={{ marginTop: '1.25rem' }}>
2468 stevensc 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">
2471 stevensc 43
            <h2
44
              className="card-title"
45
              style={{ fontSize: '1.7rem', fontWeight: '700' }}
46
            >
47
              Notificaciones
48
            </h2>
2476 stevensc 49
            <div className="messages-sec border-gray px-5 py-4">
2471 stevensc 50
              <ul>
51
                {
52
                  notifications.length
53
                    ? notifications.map((element, i) => (
54
                      <li key={i}>
2478 stevensc 55
                        <div className="notification-item">
2473 stevensc 56
                          <a href={element.link}>
57
                            {element.message}
58
                          </a>
59
                          <span>
60
                            {element.time_elapsed}
61
                          </span>
2471 stevensc 62
                        </div>
63
                      </li>
1310 steven 64
                    )
2471 stevensc 65
                    )
66
                    :
67
                    <div
68
                      className="section_admin_title_buttons w-100"
69
                      style={{ display: 'grid', placeItems: 'center' }}
70
                    >
2472 stevensc 71
                      <h1 className="title">No hay notificaciones</h1>
2471 stevensc 72
                    </div>
73
                }
74
              </ul>
1311 steven 75
            </div>
76
          </div>
1309 steven 77
        </div>
78
      </div>
2468 stevensc 79
    </section >
1307 steven 80
  )
81
}
2469 stevensc 82
export default Notifications