Fakultas Ilmu Komputer UI

AdminVacancy.jsx 1.68 KB
Newer Older
1
import React from 'react';
2
import { Item, Grid, Icon, 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,
9
    updateStatus : React.PropTypes.func.isRequired,
10
11
12
  };


13
14
15
16
17
18
19
20
21
22
23
24

  changeVerifiedStatus(){
    let data = {};
    if(this.props.data.verified){
      data = {"verified" : false};
    }
    else{
      data = {"verified" : true}; 
    }
    Server.patch(`/vacancies/${this.props.data.id}/verify/`, data).then((status) => {
        this.props.updateStatus(this.props.data.id, status.status);
      });
Farhan Farasdak's avatar
Farhan Farasdak committed
25
    
26
27
28
  }

  generateButton(){
29
30
    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>;
31
32
33
34
35
36

    if(this.props.data.verified){
      return unverifyButton;
    }
    return verifyButton;
  }
37
38
39
40
41
42

  render() {
    return (
      <Item className="adminItems">
        <Item.Image src="http://semantic-ui.com/images/wireframe/image.png" size="small" />
        <Item.Content>
43
          <Item.Header as="a">{this.props.data.name}</Item.Header>
44
45
          <Grid.Row>
            <Grid.Column floated="left">
46
47
              <h4>{this.props.data.company.name} </h4>
                {this.props.data.company.address}
48
49
            </Grid.Column>
            <Grid.Column floated="right">
50
              {this.generateButton()}
51
52
53
54
55
56
57
            </Grid.Column>
          </Grid.Row>
        </Item.Content>
      </Item>
    );
  }
}