Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

Rev 1309 | Rev 1311 | Ir a la última revisión | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 1309 Rev 1310
Línea 1... Línea 1...
1
import React from 'react';
1
import React from 'react';
2
import { useState } from 'react';
2
import { useState } from 'react';
3
import { useLayoutEffect } from 'react';
3
import { useLayoutEffect } from 'react';
4
import { axios } from '../utils';
4
import { axios } from '../utils';
5
import Notification from './notification';
-
 
Línea 6... Línea 5...
6
 
5
 
7
export default () => {
6
export default () => {
8
  const [notifications, setNotifications] = useState([]);
7
  const [notifications, setNotifications] = useState([]);
-
 
8
  const handleNotifications = async () => {
-
 
9
    try {
9
  const handleNotifications = async () => {
10
      console.log('>>: _notifications ', notifications)
10
    const _notifications = await axios.get('/notifications');
11
      const _notifications = await axios.get('/notifications');
-
 
12
      setNotifications(_notifications.data.data)
-
 
13
    } catch (error) {
-
 
14
      console.log('>>: error > ', error)
11
    console.log('>>: _notifications ', _notifications)
15
    }
12
  }
16
  }
13
  useLayoutEffect(() => {
17
  useLayoutEffect(() => {
14
    handleNotifications();
18
    handleNotifications();
15
  }, []);
19
  }, []);
Línea 20... Línea 24...
20
          className='w-100'
24
          className='w-100'
21
        >
25
        >
22
          <h1>Notificaciones</h1>
26
          <h1>Notificaciones</h1>
23
        </div>
27
        </div>
24
        <div className="messages-sec">
28
        <div className="messages-sec">
-
 
29
          <table class="table table-striped">
25
          <Notification
30
            <tbody>
-
 
31
              {
-
 
32
                !!notifications.length && (
-
 
33
                  notifications.map((element, i) => {
-
 
34
                    return(
-
 
35
                      <tr key={i.toString()}>
-
 
36
                        <td>
-
 
37
                          <a href={element.link}>
-
 
38
                            {element.message}
-
 
39
                            <span> {element.time_elapsed} </span>
-
 
40
                          </a>
-
 
41
                        </td>
-
 
42
                      </tr>
-
 
43
                    )
-
 
44
                  })
-
 
45
                )
26
          />
46
              }
-
 
47
            </tbody>
-
 
48
          </table>
27
        </div>
49
        </div>
28
      </div>
50
      </div>
29
    </section>
51
    </section>
30
  )
52
  )
31
}
53
}