Fakultas Ilmu Komputer UI

Commit 30b6238a authored by M. Reza Qorib's avatar M. Reza Qorib
Browse files

Update applicancy status

parent 5dac8617
...@@ -44,6 +44,7 @@ export default class VacancyPage extends React.Component { ...@@ -44,6 +44,7 @@ export default class VacancyPage extends React.Component {
<VacancyList <VacancyList
key={2} key={2}
userId={this.state.id} userId={this.state.id}
status="applied"
url={`/students/${this.state.id}/applied-vacancies/`} url={`/students/${this.state.id}/applied-vacancies/`}
/> />
</Pane> </Pane>
......
...@@ -20,6 +20,8 @@ export default class Applicant extends React.Component { ...@@ -20,6 +20,8 @@ export default class Applicant extends React.Component {
ACCEPTED: 4, ACCEPTED: 4,
}; };
static APPLICATION_STATUS_TEXT = ['Baru', 'Sudah Dibaca', 'Ditandai', 'Diterima', 'Ditolak'];
constructor(props) { constructor(props) {
super(props); super(props);
/* istanbul ignore next */ /* istanbul ignore next */
......
...@@ -13,10 +13,12 @@ export default class Vacancy extends React.Component { ...@@ -13,10 +13,12 @@ export default class Vacancy extends React.Component {
data: React.PropTypes.object.isRequired, data: React.PropTypes.object.isRequired,
bookmarked: React.PropTypes.number, bookmarked: React.PropTypes.number,
status: React.PropTypes.string.isRequired, status: React.PropTypes.string.isRequired,
applicationStatus: React.PropTypes.string,
}; };
static defaultProps = { static defaultProps = {
bookmarked: 0, bookmarked: 0,
applicationStatus: '',
}; };
constructor(props) { constructor(props) {
...@@ -104,6 +106,7 @@ export default class Vacancy extends React.Component { ...@@ -104,6 +106,7 @@ export default class Vacancy extends React.Component {
</Grid.Row> </Grid.Row>
<Grid.Row> <Grid.Row>
{ this.generateAction() } { this.generateAction() }
<p>{ this.props.applicationStatus }</p>
</Grid.Row> </Grid.Row>
</Grid.Column> </Grid.Column>
</Grid.Row> </Grid.Row>
......
import React from 'react'; import React from 'react';
import { Item, Button, Grid, Segment } from 'semantic-ui-react'; import { Item, Button, Grid } from 'semantic-ui-react';
import { Link } from 'react-router'; import { Link } from 'react-router';
import Vacancy from './Vacancy'; import Vacancy from './Vacancy';
import CompanyVacancy from './CompanyVacancy'; import CompanyVacancy from './CompanyVacancy';
import Server from '../lib/Server'; import Server from '../lib/Server';
import ModalAlert from '../components/ModalAlert'; import ModalAlert from '../components/ModalAlert';
import Aplicant from './../components/Applicant';
export default class VacancyList extends React.Component { export default class VacancyList extends React.Component {
...@@ -13,10 +14,12 @@ export default class VacancyList extends React.Component { ...@@ -13,10 +14,12 @@ export default class VacancyList extends React.Component {
url: React.PropTypes.string.isRequired, url: React.PropTypes.string.isRequired,
userId: React.PropTypes.number.isRequired, userId: React.PropTypes.number.isRequired,
type: React.PropTypes.string, type: React.PropTypes.string,
status: React.PropTypes.string,
}; };
static defaultProps = { static defaultProps = {
type: 'student', type: 'student',
status: 'new',
}; };
constructor(props) { constructor(props) {
...@@ -29,6 +32,7 @@ export default class VacancyList extends React.Component { ...@@ -29,6 +32,7 @@ export default class VacancyList extends React.Component {
Server.get(this.props.url, false).then((data) => { Server.get(this.props.url, false).then((data) => {
this.setState({ vacancies: data }); this.setState({ vacancies: data });
}); });
console.log(this.state.vacancies);
this.updateStatusList = this.updateStatusList.bind(this); this.updateStatusList = this.updateStatusList.bind(this);
this.generateVacancies = this.generateVacancies.bind(this); this.generateVacancies = this.generateVacancies.bind(this);
this.checkBookmark = this.checkBookmark.bind(this); this.checkBookmark = this.checkBookmark.bind(this);
...@@ -45,7 +49,7 @@ export default class VacancyList extends React.Component { ...@@ -45,7 +49,7 @@ export default class VacancyList extends React.Component {
checkApplied(id) { checkApplied(id) {
for (let i = 0; i < this.state.appliedList.length; i += 1) { for (let i = 0; i < this.state.appliedList.length; i += 1) {
if (id === this.state.appliedList[i].id) { return 'registered'; } if (id === this.state.appliedList[i].vacancy.id) { return 'registered'; }
} }
return 'new'; return 'new';
} }
...@@ -55,7 +59,12 @@ export default class VacancyList extends React.Component { ...@@ -55,7 +59,12 @@ export default class VacancyList extends React.Component {
this.setState({ bookmarkList: data }); this.setState({ bookmarkList: data });
}); });
Server.get(`/students/${this.props.userId}/applied-vacancies/`, false).then((data) => { Server.get(`/students/${this.props.userId}/applied-vacancies/`, false).then((data) => {
// console.log('hasil api:');
// console.log(data);
// console.log(data.vacancy);
this.setState({ appliedList: data }); this.setState({ appliedList: data });
console.log('applied list:')
console.log(this.state.appliedList);
}); });
} }
...@@ -73,12 +82,14 @@ export default class VacancyList extends React.Component { ...@@ -73,12 +82,14 @@ export default class VacancyList extends React.Component {
return this.state.vacancies.map(vacancy => return this.state.vacancies.map(vacancy =>
( (
<Vacancy <Vacancy
key={vacancy.id} key={this.props.status === 'applied' ? vacancy.vacancy.id : vacancy.id}
status={this.checkApplied(vacancy.id)} status={this.checkApplied(this.props.status === 'applied' ? vacancy.vacancy.id : vacancy.id)}
bookmarked={this.checkBookmark(vacancy.id)} bookmarked={this.checkBookmark(this.props.status === 'applied' ? vacancy.vacancy.id : vacancy.id)}
data={vacancy} data={this.props.status === 'applied' ? vacancy.vacancy : vacancy}
studentId={this.props.userId} studentId={this.props.userId}
/> applicationStatus= {this.props.status === 'applied' ? (vacancy.status === 4 ? 'Ditolak' :
(vacancy.status === 3 ? 'Diterima' : 'Terdaftar')) : ''}
>{console.log(this.checkApplied(this.props.status === 'applied' ? vacancy.vacancy.id : vacancy.id))}</Vacancy>
), ),
); );
} }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment