Fakultas Ilmu Komputer UI

CompanyVacancy.jsx 2.25 KB
Newer Older
1
import React from 'react';
2
import moment from 'moment';
3
import { Button, Icon, Item, Grid } from 'semantic-ui-react';
4
import { Link } from 'react-router';
5
import Server from '../lib/Server';
6

7
8
const defaultImage = 'http://semantic-ui.com/images/wireframe/image.png';

9
export default class CompanyVacancy extends React.Component {
10
  static propTypes = {
11
    data: React.PropTypes.object.isRequired,
12
    deleteCallback: React.PropTypes.func,
13
14
  };

15
16
  static defaultProps = { deleteCallback: () => {} };

17
18
  constructor(props) {
    super(props);
19
    /* istanbul ignore next */
20
    moment.locale('id');
21
22
23
24
    this.state = { deleteLoading: false, count: 0, countNew: 0 };
    Server.get(`/vacancies/${this.props.data.id}/count/`, false).then((data) => {
      this.setState({ count: data.count, countNew: data.count_new });
    });
25
26
27
28
  }

  getLink = `/buat-lowongan/${this.props.data.id}`;

29
30
  render() {
    return (
sirinbaisa's avatar
sirinbaisa committed
31

32
33
      <Item className="applicantItems">
        <Item.Image src={this.props.data.company.logo ? this.props.data.company.logo : defaultImage} size="small" />
34
        <Item.Content verticalAlign="middle" style={{ wordWrap: 'break-word', width: '100%' }} >
35
          <Item.Header as="a">{this.props.data.name}</Item.Header>
36
37
          <Grid.Row>
            <Grid.Column floated="left">
38
39
40
              <p>{ this.state.count } Pendaftar<br/>
              { this.state.countNew } Pendaftar Baru<br/><br/>
              Ditutup {moment(moment(this.props.data.close_time)).fromNow()}</p>
41
42
43
44
45
46
47
48
            </Grid.Column>
            <Grid.Column floated="right">
              {this.props.data.verified ?
                (<h4> <Icon name="checkmark box" size="large" color="green" /> Terverifikasi </h4>) :
                (<h4> <Icon name="remove circle" size="large" color="red" /> Belum Terverifikasi </h4>)}
              <Button color="blue" floated="right" as={Link} to={this.getLink}>
                Ubah <Icon name="right chevron" />
              </Button>
49
              <Button loading={this.state.deleteLoading} color="red" floated="right" onClick={() => { this.setState({ deleteLoading: true }); this.props.deleteCallback(); }} >
50
51
52
53
                Hapus <Icon name="delete" />
              </Button>
            </Grid.Column>
          </Grid.Row>
54
55
        </Item.Content>
      </Item>
56
57
    );
  }
58
}