Fakultas Ilmu Komputer UI

AdminVacancy.jsx 1.76 KB
Newer Older
1
import React from 'react';
M. Reza Qorib's avatar
M. Reza Qorib committed
2
import { Item, Grid, Button } from 'semantic-ui-react';
3
import VerifyAdminModal from './VerifyAdminModal';
4
import Server from '../lib/Server';
5

6
export default class AdminVacancy extends React.Component {
7
8
  static propTypes = {
    data: React.PropTypes.object.isRequired,
M. Reza Qorib's avatar
M. Reza Qorib committed
9
    updateStatus: React.PropTypes.func.isRequired,
10
11
  };

M. Reza Qorib's avatar
M. Reza Qorib committed
12
  changeVerifiedStatus() {
13
    let data = {};
M. Reza Qorib's avatar
M. Reza Qorib committed
14
15
16
17
    if (this.props.data.verified) {
      data = { verified: false };
    } else {
      data = { verified: true };
18
19
    }
    Server.patch(`/vacancies/${this.props.data.id}/verify/`, data).then((status) => {
M. Reza Qorib's avatar
M. Reza Qorib committed
20
21
      this.props.updateStatus(this.props.data.id, status.status);
    });
22
23
  }

M. Reza Qorib's avatar
M. Reza Qorib committed
24
  generateButton() {
25
26
    const unverifyButton = <Button floated="right" color="red" onClick={this.changeVerifiedStatus.bind(this)}>Batalkan Verifikasi</Button>;
    const verifyButton = <Button floated="right" color="blue" onClick={this.changeVerifiedStatus.bind(this)}>Verifikasi</Button>;
27

M. Reza Qorib's avatar
M. Reza Qorib committed
28
    if (this.props.data.verified) {
29
30
31
32
      return unverifyButton;
    }
    return verifyButton;
  }
33
34

  render() {
Zamil Majdy's avatar
Zamil Majdy committed
35
    const defaultImage = 'https://semantic-ui.com/images/wireframe/image.png';
36
37
    return (
      <Item className="adminItems">
38
        <Item.Image src={this.props.data.company.logo ? this.props.data.company.logo : defaultImage} size="small" />
39
        <Item.Content>
40
          <Item.Header as="a">{this.props.data.name}</Item.Header>
41
42
          <Grid.Row>
            <Grid.Column floated="left">
43
              <h4>{this.props.data.company.name} </h4>
M. Reza Qorib's avatar
M. Reza Qorib committed
44
              {this.props.data.company.address}
45
46
            </Grid.Column>
            <Grid.Column floated="right">
47
              {this.generateButton()}
48
49
50
51
52
53
54
            </Grid.Column>
          </Grid.Row>
        </Item.Content>
      </Item>
    );
  }
}