Fakultas Ilmu Komputer UI

VacancyList.jsx 843 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
    /* istanbul ignore next */
15
    this.state = { vacancies: [] };
16
    Server.get(this.props.url, false).then((data) => {
17
18
19
20
21
22
      this.setState({ vacancies: data });
    }, () => {
    });
    this.generateVacancies = this.generateVacancies.bind(this);
  }

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

29

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