Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

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

Rev 4095 Rev 4098
Línea 2... Línea 2...
2
import React, { useEffect, useState } from 'react';
2
import React, { useEffect, useState } from 'react';
3
import { addNotification } from '../../../redux/notification/notification.actions';
3
import { addNotification } from '../../../redux/notification/notification.actions';
4
import { axios } from '../../../utils';
4
import { axios } from '../../../utils';
Línea 5... Línea 5...
5
 
5
 
6
export default function HomeNews({
6
export default function HomeNews({
-
 
7
    containerClassName = '',
7
    containerClassName = ''
8
    currentPost = ''
8
}) {
9
}) {
9
    const [news, setNews] = useState([])
10
    const [news, setNews] = useState([])
10
    const loadNews = () => {
11
    const loadNews = () => {
11
        axios.get('/helpers/posts')
12
        axios.get('/helpers/posts')
12
            .then(({data : response}) => {
13
            .then(({ data: response }) => {
13
                if (!response.success) {
14
                if (!response.success) {
14
                    addNotification({
15
                    addNotification({
15
                        style: "danger",
16
                        style: "danger",
16
                        msg: response.data,
17
                        msg: response.data,
Línea 23... Línea 24...
23
                    style: "danger",
24
                    style: "danger",
24
                    msg: "Disculpe, ha ocurrido un error buscando novedades",
25
                    msg: "Disculpe, ha ocurrido un error buscando novedades",
25
                });
26
                });
26
            })
27
            })
27
    }
28
    }
28
    
29
 
29
    useEffect(() => {
30
    useEffect(() => {
30
        loadNews()
31
        loadNews()
31
    }, [])
32
    }, [])
Línea 32... Línea 33...
32
 
33
 
Línea 36... Línea 37...
36
                <h3>Novedades</h3>
37
                <h3>Novedades</h3>
37
            </div>
38
            </div>
38
            <div className="suggestions-list">
39
            <div className="suggestions-list">
39
                {
40
                {
40
                    news.map(element => {
41
                    news.map(element => {
-
 
42
                        
-
 
43
                        if (element.uuid === currentPost) {
-
 
44
                            return null
-
 
45
                        }
-
 
46
 
41
                        return (
47
                        return (
42
                            <div key={element.title} className='postsList'>
48
                            <div key={element.title} className='postsList'>
43
                                <img
49
                                <img
44
                                    src={element.image}
50
                                    src={element.image}
45
                                    alt={`${element.title} image`}
51
                                    alt={`${element.title} image`}