Fakultas Ilmu Komputer UI

VacancyList.jsx 795 Bytes
Newer Older
1
import React from 'react';
2
import { Item } from 'semantic-ui-react';
3
import Lowongan from './Vacancy';
4
import Server from '../lib/Server';
5
6
7
8

export default class VacancyList extends React.Component {

  static propTypes = {
9
    url: React.PropTypes.string.isRequired,
10
11
  };

12
13
  constructor(props) {
    super(props);
14
    Server.get(this.props.url, false).then((data) => {
15
16
      this.setState({ vacancies: data });
    });
17
18
    /* istanbul ignore next */
    this.state = { vacancies: [] };
19
20
21
    this.generateVacancies = this.generateVacancies.bind(this);
  }

22

23
  generateVacancies() {
24
    return this.state.vacancies.map(vacancy =>
25
      <Lowongan key={vacancy.id} data={vacancy} />,
26
27
28
    );
  }

29

30
31
32
33
34
  render = () => (
    <Item.Group relaxed>
      { this.generateVacancies() }
    </Item.Group>
  );
35
}