Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

Rev 2470 | Rev 2472 | 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">
2471 stevensc 43
            <h2
44
              className="card-title"
45
              style={{ fontSize: '1.7rem', fontWeight: '700' }}
46
            >
47
              Notificaciones
48
            </h2>
49
            <div className="messages-sec notification-container">
50
              <ul>
51
                {
52
                  notifications.length
53
                    ? notifications.map((element, i) => (
54
                      <li key={i}>
55
 
56
                        <div
57
                          className="row w-100"
58
                        >
59
                          <div
60
                            className="col-md-6 col-sm-12"
61
                          >
62
                            <a href={element.link}>
63
                              {element.message}
64
                            </a>
65
                          </div>
66
                          <div
67
                            className="col-md-6 col-sm-12 text-right w-100"
68
                          >
69
                            <span className="w-100 text-right"> {element.time_elapsed} </span>
70
                          </div>
71
                        </div>
72
                      </li>
1310 steven 73
                    )
2471 stevensc 74
                    )
75
                    :
76
                    <div
77
                      className="section_admin_title_buttons w-100"
78
                      style={{ display: 'grid', placeItems: 'center' }}
79
                    >
80
                      <h1 className="title">{title}</h1>
81
                    </div>
82
                }
83
              </ul>
1311 steven 84
            </div>
85
          </div>
1309 steven 86
        </div>
87
      </div>
2468 stevensc 88
    </section >
1307 steven 89
  )
90
}
2469 stevensc 91
export default Notifications