Rev 2759 | Rev 2933 | Ir a la última revisión | Autoría | Comparar con el anterior | Ultima modificación | Ver Log |
import React, { useEffect, useState } from 'react';
import { addNotification } from '../../../redux/notification/notification.actions';
import { axios } from '../../../utils';
import styles from './HomeSection.module.scss';
export default function HomeNews({ containerClassName = '', suggestionsContainerClassName = '' }) {
const [news, setNews] = useState([])
const loadNews = () => {
axios.get('/helpers/posts')
.then(res => {
if (res.data.success) {
setNews(res.data.data)
}
})
.catch(() => {
addNotification({
style: "error",
msg: "Disculpe, ha ocurrido un error buscando novedades",
});
})
}
useEffect(() => {
loadNews()
}, [])
return (
<div className={containerClassName} style={{ paddingBottom: '5%' }}>
<div className={styles.suggestions}>
<div className="sd-title">
<h3>Novedades</h3>
</div>
<div className="suggestions-list">
{
news.map(element => {
return (
<div key={element.title}>
<div className="d-flex align-items-center">
<span className='list-icon'>
</span>
<div>
<a
href={element.link}
target="_blank"
className='text-dark'
>
{element.title}
</a>
<p style={{ lineHeight: '1', marginBottom: '5px' }}>
{element.date}
</p>
</div>
</div>
</div>
)
})
}
</div>
</div>
</div >
)
}