-
Notifications
You must be signed in to change notification settings - Fork 0
/
bron-overzicht-pagina.js
90 lines (84 loc) · 2.58 KB
/
bron-overzicht-pagina.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
import React, { Component } from 'react';
import {
BrowserRouter as Router,
Switch,
Route,
Link
} from 'react-router-dom';
import ItemsLijstPlaceholder from './placeholder/items-lijst-placeholder.js';
import BronPagina from './bron-pagina';
import ServerFoutPlaceholder from './placeholder/server-fout-placeholder.js';
class BronOverzichtPagina extends Component {
constructor(props) {
super(props)
this.state = {
error: null,
isLoaded: false,
resultaten: []
};
}
componentDidMount() {
const requestOptions = {
method: 'GET',
headers: { 'Content-Type': 'application/json' },
};
fetch(process.env.REACT_APP_BRAKDAGFLASK + "/items/statistics", requestOptions)
.then(res => res.json())
.then(
(result) => {
this.setState({
isLoaded: true,
resultaten: result
});
},
(error) => {
this.setState({
isLoaded: true,
error
});
}
)
}
render() {
const { resultaten, isLoaded, error } = this.state;
if (error) {
return <div><ServerFoutPlaceholder message={error.message} /></div>;
} else if (!isLoaded) {
return <div><header className="pagina-header"></header><ItemsLijstPlaceholder /></div>;
} else {
return (
<div>
<header className="pagina-header">
Bronnen
<span className="pagina-header-sub">{resultaten.length} nieuwsbronnen</span>
</header>
<div id='wrap'>
<ul className='lijst'>
{resultaten.map(item => (
<li key={item['id']}>
<Link to={"/bron/" + item['id']}>
<ul className='lijst-item'>
<li className='bron'>
<img alt={item['bron_title']} src={item['logo']} data-bron={item['bron_id']} />
</li>
<li className='title'>
<a className='title-ref' target="blank" href={item['link_home']}>{item['title']}</a>
<div className='description'>
{item['description']}
</div>
</li>
<li className='right'>
<div className='whats-the-count'>{item['aantal_items']} artikelen</div>
</li>
</ul>
</Link>
</li>
))}
</ul>
</div>
</div>
);
}
}
}
export default BronOverzichtPagina;