Fakultas Ilmu Komputer UI

Commit e3abecad authored by Syahrul Findi's avatar Syahrul Findi
Browse files

1506757352 191

parent c4d87b27
{ {
"extends": ["airbnb", "prettier"], "extends": ["airbnb", "prettier", "prettier/react"],
"env": { "env": {
"amd": true, "amd": true,
"browser": true, "browser": true,
......
...@@ -4,17 +4,15 @@ import Tabs from './components/Tabs'; ...@@ -4,17 +4,15 @@ import Tabs from './components/Tabs';
import Pane from './components/Pane'; import Pane from './components/Pane';
import AdminVacancy from './components/AdminVacancy'; import AdminVacancy from './components/AdminVacancy';
export default class AdminVacancyPage extends React.Component { const AdminVacancyPage = () => (
render() { <Tabs selected={0}>
return ( <Pane label="Lowongan Belum Terferivikasi">
<Tabs selected={0}> <Item.Group>
<Pane label="Lowongan Belum Terferivikasi"> <AdminVacancy />
<Item.Group> </Item.Group>
<AdminVacancy /> </Pane>
</Item.Group> <Pane label=" Semua Lamaran" />
</Pane> </Tabs>
<Pane label=" Semua Lamaran" /> );
</Tabs>
); export default AdminVacancyPage;
}
}
...@@ -3,25 +3,17 @@ import PropTypes from 'prop-types'; ...@@ -3,25 +3,17 @@ import PropTypes from 'prop-types';
import { Dropdown } from 'semantic-ui-react'; import { Dropdown } from 'semantic-ui-react';
import Tabs from './components/Tabs'; import Tabs from './components/Tabs';
import ApplicantList from './components/ApplicantList'; import ApplicantList from './components/ApplicantList';
import Applicant from './components/Applicant';
import Pagination from './components/Pagination'; import Pagination from './components/Pagination';
import Server from './lib/Server'; import Server from './lib/Server';
import { APPLICATION_STATUS } from './constants';
export default class ApplicantPage extends React.Component { export default class ApplicantPage extends React.Component {
static propTypes = {
user: PropTypes.object.isRequired,
};
constructor(props) { constructor(props) {
super(props); super(props);
/* istanbul ignore next */ /* istanbul ignore next */
this.state = { this.state = {
email: '',
password: '',
errorFlag: false,
company: { id: 1 },
urls: [], urls: [],
selected: `/companies/${this.props.user.data.company.id}/applications/`, selected: `/companies/${props.user.data.company.id}/applications/`,
refresh: 0, refresh: 0,
}; };
this.getVacancyList = this.getVacancyList.bind(this); this.getVacancyList = this.getVacancyList.bind(this);
...@@ -29,43 +21,56 @@ export default class ApplicantPage extends React.Component { ...@@ -29,43 +21,56 @@ export default class ApplicantPage extends React.Component {
this.getVacancyList(); this.getVacancyList();
} }
getVacancyList = () => Server.get( getVacancyList = () => {
`/companies/${this.props.user.data.company.id}/vacancies/`, const {
false, user: {
).then( data: {
(data) => { company: { id },
const { results } = data;
const urls = [
{
key: 0,
value: `/companies/${this.props.user.data.company.id}/applications/`,
text: 'Semua Lowongan',
}, },
]; },
results.map((vacancy) => { } = this.props;
names.push(vacancy.name);
const url = `/companies/${this.props.user.data.company.id}/applications/${vacancy.id}/by_vacancy/`; Server.get(`/companies/${id}/vacancies/`, false).then(
const info = { (data) => {
key: vacancy.id, const { results } = data;
value: url, const urls = [
text: vacancy.name, {
}; key: 0,
urls.push(info); value: `/companies/${id}/applications/`,
return urls; text: 'Semua Lowongan',
}); },
this.setState({ urls }); ];
}, results.map((vacancy) => {
(error) => error.then((r) => { const url = `/companies/${id}/applications/${vacancy.id}/by_vacancy/`;
this.modalAlert.open('Gagal mendapatkan daftar lowongan', r.detail); const info = {
}), key: vacancy.id,
); value: url,
text: vacancy.name,
};
urls.push(info);
return urls;
});
this.setState({ urls });
},
(error) =>
error.then((r) => {
this.modalAlert.open('Gagal mendapatkan daftar lowongan', r.detail);
}),
);
};
handleChange = (e, data) => { handleChange = (e, data) => {
this.setState({ selected: data.value, refresh: this.state.refresh + 6 }); const { refresh } = this.state;
this.setState({ selected: data.value, refresh: refresh + 6 });
}; };
render() { render() {
const { company } = this.props.user.data; const { refresh, selected, urls } = this.state;
const {
user: {
data: { company },
},
} = this.props;
return ( return (
<div> <div>
<div className="dropdownApplicant"> <div className="dropdownApplicant">
...@@ -73,90 +78,31 @@ export default class ApplicantPage extends React.Component { ...@@ -73,90 +78,31 @@ export default class ApplicantPage extends React.Component {
placeholder="Semua Lowongan" placeholder="Semua Lowongan"
search search
selection selection
options={this.state.urls} options={urls}
onChange={this.handleChange} onChange={this.handleChange}
/> />
</div> </div>
<Tabs selected={0}> <Tabs selected={0}>
<Pagination {Object.keys(APPLICATION_STATUS).map((status) => (
key={0 + this.state.refresh} <Pagination
url={`${this.state.selected}`} key={status + refresh}
label="Semua Lamaran" url={`${selected}${status.isUsingQuery &&
child={( `?status=${APPLICATION_STATUS[status]}`}`}
<ApplicantList label={status.label}
companyId={company.id} child={
status={Applicant.APPLICATION_STATUS.ALL} <ApplicantList
/> companyId={company.id}
)} status={APPLICATION_STATUS[status]}
/> />
<Pagination }
key={1 + this.state.refresh} />
url={`${this.state.selected}?status=${Applicant.APPLICATION_STATUS.NEW}`} ))}
label="Lamaran Baru"
child={(
<ApplicantList
companyId={company.id}
status={Applicant.APPLICATION_STATUS.NEW}
/>
)}
/>
<Pagination
key={2 + this.state.refresh}
url={`${this.state.selected}?status=${Applicant.APPLICATION_STATUS.READ}`}
label="Lamaran Dibaca"
child={(
<ApplicantList
companyId={company.id}
status={Applicant.APPLICATION_STATUS.READ}
/>
)}
/>
<Pagination
key={3 + this.state.refresh}
url={`${this.state.selected}?status=${Applicant.APPLICATION_STATUS.BOOKMARKED}`}
label="Lamaran Ditandai"
child={(
<ApplicantList
companyId={company.id}
status={Applicant.APPLICATION_STATUS.BOOKMARKED}
/>
)}
/>
<Pagination
key={4 + this.state.refresh}
url={`${this.state.selected}?status=${Applicant.APPLICATION_STATUS.ACCEPTED}`}
label="Lamaran Diterima"
child={(
<ApplicantList
companyId={company.id}
status={Applicant.APPLICATION_STATUS.ACCEPTED}
/>
)}
/>
<Pagination
key={5 + this.state.refresh}
url={`${this.state.selected}?status=${Applicant.APPLICATION_STATUS.REJECTED}`}
label="Lamaran Ditolak"
child={(
<ApplicantList
companyId={company.id}
status={Applicant.APPLICATION_STATUS.REJECTED}
/>
)}
/>
<Pagination
key={6 + this.state.refresh}
url={`${this.state.selected}?status=${Applicant.APPLICATION_STATUS.FINISHED}`}
label="Lamaran Selesai"
child={(
<ApplicantList
companyId={company.id}
status={Applicant.APPLICATION_STATUS.FINISHED}
/>
)}
/>
</Tabs> </Tabs>
</div> </div>
); );
} }
} }
ApplicantPage.propTypes = {
user: PropTypes.object.isRequired,
};
import React from 'react'; import React from 'react';
import PropTypes from 'prop-types';
import { Button } from 'semantic-ui-react'; import { Button } from 'semantic-ui-react';
import Tabs from './components/Tabs'; import Tabs from './components/Tabs';
import CompanyList from './components/CompanyList'; import CompanyList from './components/CompanyList';
import Company from './components/Company';
import Pagination from './components/Pagination'; import Pagination from './components/Pagination';
import { COMPANY_STATUS } from './constants';
export default class CompanyPage extends React.Component { const CompanyPage = () => {
static propTypes = { const handleClick = () => window.open('/admin/');
user: PropTypes.object.isRequired,
};
handleClick = () => window.open('/admin/'); return (
<div>
render() { <div className="administrationButtons">
return ( <Button
<div> onClick={handleClick}
<div className="administrationButtons"> icon="dashboard"
<Button labelPosition="left"
onClick={this.handleClick} color="facebook"
icon="dashboard" content="Buka Menu Administrasi"
labelPosition="left" />
color="facebook" </div>
content="Buka Menu Administrasi" <Tabs selected={0}>
/> {Object.keys(COMPANY_STATUS).map((status) => (
</div>
<Tabs selected={0}>
<Pagination <Pagination
key={1} key={status}
url={`/companies/?status=${Company.COMPANY_STATUS.NEW}`} url={`/companies/?status=${COMPANY_STATUS[status]}`}
label="Belum Diverifikasi" label="Belum Diverifikasi"
child={<CompanyList status={Company.COMPANY_STATUS.NEW} />} child={<CompanyList status={COMPANY_STATUS[status]} />}
/>
<Pagination
key={2}
url={`/companies/?status=${Company.COMPANY_STATUS.VERIFIED}`}
label="Terverifikasi"
child={<CompanyList status={Company.COMPANY_STATUS.VERIFIED} />}
/> />
<Pagination ))}
key={3} </Tabs>
url={`/companies/?status=${Company.COMPANY_STATUS.UNVERIFIED}`} </div>
label="Ditolak" );
child={<CompanyList status={Company.COMPANY_STATUS.UNVERIFIED} />} };
/>
<Pagination export default CompanyPage;
key={4}
url="/companies/"
label="Semua Perusahaan"
child={<CompanyList status={Company.COMPANY_STATUS.ALL} />}
/>
</Tabs>
</div>
);
}
}
import React from 'react'; import React from 'react';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import { import { Segment, Button, Form, Header, Icon, Input } from 'semantic-ui-react';
Segment, Button, Form, Header, Icon, Input,
} from 'semantic-ui-react';
import { browserHistory } from 'react-router'; import { browserHistory } from 'react-router';
import DatePicker from 'react-datepicker'; import DatePicker from 'react-datepicker';
import moment from 'moment'; import moment from 'moment';
...@@ -11,11 +9,6 @@ import ModalAlert from './components/ModalAlert'; ...@@ -11,11 +9,6 @@ import ModalAlert from './components/ModalAlert';
import Server from './lib/Server'; import Server from './lib/Server';
export default class CreateVacancy extends React.Component { export default class CreateVacancy extends React.Component {
static propTypes = {
params: PropTypes.object.isRequired,
user: PropTypes.object.isRequired,
};
constructor(props) { constructor(props) {
super(props); super(props);
/* istanbul ignore next */ /* istanbul ignore next */
...@@ -31,9 +24,9 @@ export default class CreateVacancy extends React.Component { ...@@ -31,9 +24,9 @@ export default class CreateVacancy extends React.Component {
this.state = { this.state = {
formLoading: false, formLoading: false,
loading: !!this.props.params.id, loading: !!props.params.id,
company: this.props.user.data.company, company: props.user.data.company,
vacancyId: this.props.params.id, vacancyId: props.params.id,
open_time: moment(), open_time: moment(),
close_time: moment(), close_time: moment(),
name: '', name: '',
...@@ -45,8 +38,8 @@ export default class CreateVacancy extends React.Component { ...@@ -45,8 +38,8 @@ export default class CreateVacancy extends React.Component {
responsibilities: '', responsibilities: '',
}; };
if (this.state.vacancyId) { if (props.params.id) {
Server.get(`/vacancies/${this.state.vacancyId}/`).then((r) => { Server.get(`/vacancies/${props.params.id}/`).then((r) => {
this.setState({ this.setState({
description: r.description, description: r.description,
benefits: r.benefits, benefits: r.benefits,
...@@ -77,189 +70,217 @@ export default class CreateVacancy extends React.Component { ...@@ -77,189 +70,217 @@ export default class CreateVacancy extends React.Component {
this.setState({ [e.target.name]: e.target.value }); this.setState({ [e.target.name]: e.target.value });
}; };
handleDescription(value) {
this.setState({ description: value });
}
handleBenefits(value) {
this.setState({ benefits: value });
}
handleRequirements(value) {
this.setState({ requirements: value });
}
handleResponsibilities(value) {
this.setState({ responsibilities: value });
}
handleSubmit = (e) => { handleSubmit = (e) => {
const {
name,
tag,
responsibilities,
description,
benefits,
requirements,
salary,
open_time,
close_time,
max_accepted_applicants,
working_period,
company,
vacancyId,
} = this.state;
e.preventDefault(); e.preventDefault();
this.setState({ formLoading: true }); this.setState({ formLoading: true });
const data = {}; const data = {};
data.name = this.state.name; data.name = name;
data.tag = this.state.tag; data.tag = tag;
data.responsibilities = this.state.responsibilities; data.responsibilities = responsibilities;
data.description = this.state.description; data.description = description;
data.benefits = this.state.benefits; data.benefits = benefits;
data.requirements = this.state.requirements; data.requirements = requirements;
data.salary = this.state.salary; data.salary = salary;
data.open_time = this.state.open_time.format(); data.open_time = open_time.format();
data.close_time = this.state.close_time.format(); data.close_time = close_time.format();
data.max_accepted_applicants = this.state.max_accepted_applicants; data.max_accepted_applicants = max_accepted_applicants;
data.working_period = this.state.working_period; data.working_period = working_period;
if (!this.state.vacancyId) { if (!vacancyId) {
data.company = this.state.company.id; data.company = company.id;
} }
const url = this.state.vacancyId const url = vacancyId ? `/vacancies/${vacancyId}/` : '/vacancies/';
? `/vacancies/${this.state.vacancyId}/` const method = vacancyId ? 'PATCH' : 'POST';
: '/vacancies/';
const method = this.state.vacancyId ? 'PATCH' : 'POST';
Server.sendRequest(url, method, data).then( Server.sendRequest(url, method, data).then(
() => { () => {
browserHistory.push('/lowongan'); browserHistory.push('/lowongan');
}, },
(error) => error.then((r) => { (error) =>
this.modalAlert.open('Gagal Membuat Lowongan', r.error); error.then((r) => {
this.setState({ formLoading: false }); this.modalAlert.open('Gagal Membuat Lowongan', r.error);
}), this.setState({ formLoading: false });
}),
); );
}; };
render = () => ( handleResponsibilities(value) {
<div className="create-lowongan"> this.setState({ responsibilities: value });
<ModalAlert }
ref={(modal) => {
this.modalAlert = modal; handleRequirements(value) {
}} this.setState({ requirements: value });
/> }
<Segment className="form-segment">
<Header as="h2" icon textAlign="center"> handleBenefits(value) {
<Icon name="briefcase" circular /> this.setState({ benefits: value });
<Header.Content>Lowongan KP</Header.Content> }
</Header>
<Form loading={this.state.formLoading} onSubmit={this.handleSubmit}>
<Form.Field
label="Posisi"
name="name"
control={Input}
onChange={this.handleChange}
value={this.state.name}
required
/>
<label htmlFor="description">
{' '}
<b> Deskripsi Lowongan </b>
{' '}
</label>
{!this.state.loading && (
<CKEditor
value={this.state.description}
onChange={this.handleDescription}
/>
)}
<script>CKEDITOR.replace( 'description' );</script>
<Form.Field
label="Periode Kerja"
name="working_period"
control={Input}
onChange={this.handleChange}
value={this.state.working_period}
/>
<label htmlFor="responsibilities">
{' '}
<b> Tanggung Jawab Lowongan </b>
{' '}
</label>
{!this.state.loading && (
<CKEditor
value={this.state.responsibilities}
onChange={this.handleResponsibilities}
/>
)}
<script>CKEDITOR.replace( 'responsibilities' );</script>
<br />
<Form.Field