Fakultas Ilmu Komputer UI

Commit eb13ad0c authored by Hilya Auli Fesmia's avatar Hilya Auli Fesmia
Browse files

1606890933 125

parent 91ddf4eb
...@@ -4,6 +4,7 @@ import Vacancy from './Vacancy'; ...@@ -4,6 +4,7 @@ import Vacancy from './Vacancy';
import CompanyVacancy from './CompanyVacancy'; import CompanyVacancy from './CompanyVacancy';
import AdminVacancy from './AdminVacancy'; import AdminVacancy from './AdminVacancy';
import Server from '../lib/Server'; import Server from '../lib/Server';
import moment from 'moment';
export default class VacancyList extends React.Component { export default class VacancyList extends React.Component {
...@@ -34,10 +35,17 @@ export default class VacancyList extends React.Component { ...@@ -34,10 +35,17 @@ export default class VacancyList extends React.Component {
{ key: 3, text: '3-5 juta', value: 3 }, { key: 3, text: '3-5 juta', value: 3 },
{ key: 4, text: '> 5 juta', value: 4 }, { key: 4, text: '> 5 juta', value: 4 },
], ],
vacancyStateFilter: 0,
vacancyStateFilterBy: [
{ key: 0, text: 'Semua', value: 0 },
{ key: 1, text: 'Masih Menerima', value: 1 },
{ key: 2, text: 'Sudah Tutup', value: 2 },
],
}; };
this.generateVacancies = this.generateVacancies.bind(this); this.generateVacancies = this.generateVacancies.bind(this);
this.updateStatus = this.updateStatus.bind(this); this.updateStatus = this.updateStatus.bind(this);
this.handleChangeSalaryFilter = this.handleChangeSalaryFilter.bind(this); this.handleChangeSalaryFilter = this.handleChangeSalaryFilter.bind(this);
this.handleChangeVacancyStateFilter = this.handleChangeVacancyStateFilter.bind(this);
} }
updateStatus(id, status) { updateStatus(id, status) {
...@@ -74,10 +82,26 @@ export default class VacancyList extends React.Component { ...@@ -74,10 +82,26 @@ export default class VacancyList extends React.Component {
return filteredVacancies; return filteredVacancies;
} }
filterVacanciesBasedOnVacancyStatus = (vacancies) => {
const vacancyStateFilter = this.state.vacancyStateFilter;
let filteredVacancies = vacancies;
if (vacancyStateFilter === 1) {
filteredVacancies = filteredVacancies.filter((vacancy) => vacancy.props.data.close_time >= moment().format());
} else if (vacancyStateFilter === 2) {
filteredVacancies = filteredVacancies.filter((vacancy) => vacancy.props.data.close_time < moment().format());
}
return filteredVacancies;
}
handleChangeSalaryFilter = (e, data) => { handleChangeSalaryFilter = (e, data) => {
this.setState({ salaryFilter: data.value }); this.setState({ salaryFilter: data.value });
} }
handleChangeVacancyStateFilter = (e, data) => {
this.setState({ vacancyStateFilter: data.value });
}
generateVacancies() { generateVacancies() {
if (this.state.vacancies.length === 0) { if (this.state.vacancies.length === 0) {
return ( return (
...@@ -114,6 +138,7 @@ export default class VacancyList extends React.Component { ...@@ -114,6 +138,7 @@ export default class VacancyList extends React.Component {
}); });
} }
vacancies = this.filterVacanciesBasedOnSalary(vacancies); vacancies = this.filterVacanciesBasedOnSalary(vacancies);
vacancies = this.filterVacanciesBasedOnVacancyStatus(vacancies);
return vacancies; return vacancies;
} else if ((this.props.user.role === 'admin' && this.props.user.data.company != null) } else if ((this.props.user.role === 'admin' && this.props.user.data.company != null)
|| this.props.user.role === 'company') { || this.props.user.role === 'company') {
...@@ -147,6 +172,13 @@ export default class VacancyList extends React.Component { ...@@ -147,6 +172,13 @@ export default class VacancyList extends React.Component {
options={this.state.salaryFilterBy} options={this.state.salaryFilterBy}
onChange={this.handleChangeSalaryFilter} onChange={this.handleChangeSalaryFilter}
/> />
<Dropdown
placeholder='Filter Berdasarkan Batas Daftar Lowongan'
className="dropdownApplicant"
selection
options={this.state.vacancyStateFilterBy}
onChange={this.handleChangeVacancyStateFilter}
/>
<Grid container columns="eleven" doubling style={{ display: 'block' }}> <Grid container columns="eleven" doubling style={{ display: 'block' }}>
<Item.Group relaxed style={{ width: '100%' }}> <Item.Group relaxed style={{ width: '100%' }}>
{ this.generateVacancies() } { this.generateVacancies() }
......
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