Fakultas Ilmu Komputer UI

Commit e760baea authored by Reza Qorib's avatar Reza Qorib
Browse files

Merge branch 'Fixes/Lamaran-Dibaca-Bug' into 'develop'

Fixes/lamaran dibaca bug

See merge request !13
parents 99f4e825 f0f6c9da
...@@ -29,21 +29,11 @@ export default class ApplicantPage extends React.Component { ...@@ -29,21 +29,11 @@ export default class ApplicantPage extends React.Component {
const company = this.props.user.data.company; const company = this.props.user.data.company;
return ( return (
<Tabs selected={0}> <Tabs selected={0}>
<Pane label="Lamaran Baru" > <ApplicantList label="Lamaran Baru" key={1} companyId={company.id} url={`/companies/${company.id}/applications/?status=${Applicant.APPLICATION_STATUS.NEW}`} status={Applicant.APPLICATION_STATUS.NEW} />
<ApplicantList key={1} companyId={company.id} url={`/companies/${company.id}/applications/?status=${Applicant.APPLICATION_STATUS.NEW}`} status={Applicant.APPLICATION_STATUS.NEW} /> <ApplicantList label="Lamaran Dibaca" key={2} companyId={company.id} url={`/companies/${company.id}/applications/?status=${Applicant.APPLICATION_STATUS.READ}`} status={Applicant.APPLICATION_STATUS.READ} />
</Pane> <ApplicantList label="Lamaran Ditandai" key={3} companyId={company.id} url={`/companies/${company.id}/applications/?status=${Applicant.APPLICATION_STATUS.BOOKMARKED}`} status={Applicant.APPLICATION_STATUS.BOOKMARKED} />
<Pane label="Lamaran Dibaca" > <ApplicantList label="Lamaran Diterima" key={4} companyId={company.id} url={`/companies/${company.id}/applications/?status=${Applicant.APPLICATION_STATUS.ACCEPTED}`} status={Applicant.APPLICATION_STATUS.ACCEPTED} />
<ApplicantList key={2} companyId={company.id} url={`/companies/${company.id}/applications/?status=${Applicant.APPLICATION_STATUS.READ}`} status={Applicant.APPLICATION_STATUS.READ} /> <ApplicantList label="Lamaran Ditolak" key={5} companyId={company.id} url={`/companies/${company.id}/applications/?status=${Applicant.APPLICATION_STATUS.REJECTED}`} status={Applicant.APPLICATION_STATUS.REJECTED} />
</Pane>
<Pane label="Lamaran Ditandai" >
<ApplicantList key={3} companyId={company.id} url={`/companies/${company.id}/applications/?status=${Applicant.APPLICATION_STATUS.BOOKMARKED}`} status={Applicant.APPLICATION_STATUS.BOOKMARKED} />
</Pane>
<Pane label="Lamaran Diterima" >
<ApplicantList key={4} companyId={company.id} url={`/companies/${company.id}/applications/?status=${Applicant.APPLICATION_STATUS.ACCEPTED}`} status={Applicant.APPLICATION_STATUS.ACCEPTED} />
</Pane>
<Pane label="Lamaran Ditolak" >
<ApplicantList key={5} companyId={company.id} url={`/companies/${company.id}/applications/?status=${Applicant.APPLICATION_STATUS.REJECTED}`} status={Applicant.APPLICATION_STATUS.REJECTED} />
</Pane>
</Tabs> </Tabs>
); );
} }
......
import React from 'react'; import React from 'react';
import TopMenu from './components/TopMenu'; import TopMenu from './components/TopMenu';
import Footer from './components/Footer' import Footer from './components/Footer';
export default class Dashboard extends React.Component { export default class Dashboard extends React.Component {
static propTypes = { static propTypes = {
......
...@@ -89,7 +89,7 @@ export default class ProfilePage extends React.Component { ...@@ -89,7 +89,7 @@ export default class ProfilePage extends React.Component {
const form = this.state.form; const form = this.state.form;
form[e.target.name] = e.target.files[0]; form[e.target.name] = e.target.files[0];
this.setState({ form }); this.setState({ form });
} };
handleChange = (e) => { handleChange = (e) => {
const form = this.state.form; const form = this.state.form;
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
import React from 'react'; import React from 'react';
import ReactTestUtils from 'react-addons-test-utils'; import ReactTestUtils from 'react-addons-test-utils';
import ApplyModal from '../../components/ApplyModal'; import ApplyModal from '../../components/ApplyModal';
import fetchMock from 'fetch-mock';
describe('ApplyModal', () => { describe('ApplyModal', () => {
it('renders without problem', () => { it('renders without problem', () => {
...@@ -11,12 +12,25 @@ describe('ApplyModal', () => { ...@@ -11,12 +12,25 @@ describe('ApplyModal', () => {
}); });
it('open without problem', () => { it('open without problem', () => {
fetchMock.post('*', {});
const modalPendaftaran = ReactTestUtils.renderIntoDocument( const modalPendaftaran = ReactTestUtils.renderIntoDocument(
<ApplyModal id={4} data={{ key: 'value' }} buttonTitle="submit" apply={() => {}}/>); <ApplyModal id={4} data={{ key: 'value' }} buttonTitle="submit" apply={() => {}}/>);
const modal = ReactTestUtils.findRenderedDOMComponentWithTag(modalPendaftaran, 'Button'); const modal = ReactTestUtils.findRenderedDOMComponentWithTag(modalPendaftaran, 'Button');
modalPendaftaran.handleApply(); modalPendaftaran.handleApply();
ReactTestUtils.Simulate.click(modal); ReactTestUtils.Simulate.click(modal);
expect(modalPendaftaran).to.exist; expect(modalPendaftaran).to.exist;
fetchMock.restore();
});
it('open with problem', () => {
fetchMock.post('*', 404);
const modalPendaftaran = ReactTestUtils.renderIntoDocument(
<ApplyModal id={4} data={{ key: 'value' }} buttonTitle="submit" apply={() => {}}/>);
const modal = ReactTestUtils.findRenderedDOMComponentWithTag(modalPendaftaran, 'Button');
modalPendaftaran.handleApply();
ReactTestUtils.Simulate.click(modal);
expect(modalPendaftaran).to.exist;
fetchMock.restore();
}); });
it('change without problem', () => { it('change without problem', () => {
......
...@@ -3,6 +3,7 @@ import React from 'react'; ...@@ -3,6 +3,7 @@ import React from 'react';
import ReactTestUtils from 'react-addons-test-utils'; import ReactTestUtils from 'react-addons-test-utils';
import fetchMock from 'fetch-mock'; import fetchMock from 'fetch-mock';
import ApproveModal from '../../components/ApproveModal'; import ApproveModal from '../../components/ApproveModal';
import Applicant from '../../components/Applicant';
describe('ApproveModal', () => { describe('ApproveModal', () => {
it('renders without problem', () => { it('renders without problem', () => {
...@@ -14,7 +15,7 @@ describe('ApproveModal', () => { ...@@ -14,7 +15,7 @@ describe('ApproveModal', () => {
it('open without problem', () => { it('open without problem', () => {
fetchMock.get('*', { student: { resume: 'asdasd' } }); fetchMock.get('*', { student: { resume: 'asdasd' } });
const modalApproval = ReactTestUtils.renderIntoDocument( const modalApproval = ReactTestUtils.renderIntoDocument(
<ApproveModal updateStatus={() => {}} data={{ key: 'value', student: { resume: 'asdasd' } }} />); <ApproveModal updateStatus={() => {}} data={{ key: 'value', student: { resume: 'asdasd' }, status: Applicant.APPLICATION_STATUS.NEW }} />);
const modal = ReactTestUtils.findRenderedDOMComponentWithTag(modalApproval, 'Button'); const modal = ReactTestUtils.findRenderedDOMComponentWithTag(modalApproval, 'Button');
ReactTestUtils.Simulate.click(modal); ReactTestUtils.Simulate.click(modal);
...@@ -24,8 +25,9 @@ describe('ApproveModal', () => { ...@@ -24,8 +25,9 @@ describe('ApproveModal', () => {
it('close without problem', () => { it('close without problem', () => {
fetchMock.get('*', { student: { resume: 'asdasd' } }); fetchMock.get('*', { student: { resume: 'asdasd' } });
fetchMock.patch('*', { student: { resume: 'asdasd' } });
const modalApproval = ReactTestUtils.renderIntoDocument( const modalApproval = ReactTestUtils.renderIntoDocument(
<ApproveModal updateStatus={() => {}} data={{ key: 'value', student: { resume: 'asdasd' } }} />); <ApproveModal updateStatus={() => {}} data={{ key: 'value', student: { resume: 'asdasd' }, status: Applicant.APPLICATION_STATUS.NEW }} />);
modalApproval.handleClose(); modalApproval.handleClose();
expect(modalApproval.state.modalOpen).to.equal(false); expect(modalApproval.state.modalOpen).to.equal(false);
......
...@@ -99,30 +99,4 @@ describe('Vacancy', () => { ...@@ -99,30 +99,4 @@ describe('Vacancy', () => {
expect(lowongan.bookmark()).to.be.undefined; expect(lowongan.bookmark()).to.be.undefined;
fetchMock.restore(); fetchMock.restore();
}); });
it('apply without problem', () => {
fetchMock.post('*', response);
fetchMock.delete('*', response);
const lowongan = ReactTestUtils.renderIntoDocument(
<Vacancy status="Daftar" data={response2} bookmarked={1}/>);
const response3 = { student: { id: 1, name: 2 } };
lowongan.apply(1);
expect(lowongan.props.data.id).to.equal(3);
Storage.set('user-data', response3);
expect(lowongan.bookmark()).to.be.undefined;
fetchMock.restore();
});
it('apply with problem', () => {
fetchMock.post('*', 404);
fetchMock.delete('*', response);
const lowongan = ReactTestUtils.renderIntoDocument(
<Vacancy status="Daftar" data={response2} bookmarked={1}/>);
const response3 = { student: { id: 1, name: 2 } };
lowongan.apply(1);
expect(lowongan.props.data.id).to.equal(3);
Storage.set('user-data', response3);
expect(lowongan.bookmark()).to.be.undefined;
fetchMock.restore();
});
}); });
import React from 'react'; import React from 'react';
import { Icon, Modal, Button, TextArea, Form } from 'semantic-ui-react'; import { Icon, Modal, Button, TextArea, Form } from 'semantic-ui-react';
import ModalAlert from './../components/ModalAlert'; import ModalAlert from './../components/ModalAlert';
import Server from './../lib/Server';
export default class ApplyModal extends React.Component { export default class ApplyModal extends React.Component {
static propTypes = { static propTypes = {
data: React.PropTypes.object.isRequired, data: React.PropTypes.object.isRequired,
active: React.PropTypes.bool.isRequired, active: React.PropTypes.bool.isRequired,
buttonTitle: React.PropTypes.string.isRequired, buttonTitle: React.PropTypes.string.isRequired,
apply: React.PropTypes.func.isRequired, studentId: React.PropTypes.number.isRequired,
}; };
constructor(props) { constructor(props) {
...@@ -36,12 +37,15 @@ export default class ApplyModal extends React.Component { ...@@ -36,12 +37,15 @@ export default class ApplyModal extends React.Component {
}); });
handleApply = () => { handleApply = () => {
this.load(); this.setState({ load: true });
this.props.apply(); const requestData = { vacancy_id: this.props.data.id, cover_letter: this.state.coverLetter };
Server.post(`/students/${this.props.studentId}/applied-vacancies/`, requestData).then(() => {
this.modalAlert.open('Pendaftaran Berhasil', 'Pendaftaran anda berhasil direkam. Harap menunggu kabar selanjutnya dari pihak yang terkait\n', this.handleClose);
this.setState({ status: 'registered' });
}, () => this.modalAlert.open('Pendaftaran Gagal', 'Maaf pendaftaran yang anda lakukan gagal. Harap ulangi pendaftaran atau hubungi administrator\n', this.handleClose),
);
}; };
load = () => this.setState({ load: true });
render = () => ( render = () => (
<Modal <Modal
trigger={<Button primary onClick={this.handleOpen} floated="right">{this.props.buttonTitle}</Button>} trigger={<Button primary onClick={this.handleOpen} floated="right">{this.props.buttonTitle}</Button>}
......
...@@ -24,7 +24,7 @@ export default class ApproveModal extends React.Component { ...@@ -24,7 +24,7 @@ export default class ApproveModal extends React.Component {
} }
handleOpen = () => this.setState({ modalOpen: true }); handleOpen = () => this.setState({ modalOpen: true });
handleClose = () => this.readApplication() && this.setState({ modalOpen: false }); handleClose = () => { this.readApplication(); this.setState({ modalOpen: false }); }
readApplication = () => { readApplication = () => {
const data = { status: Applicant.APPLICATION_STATUS.READ }; const data = { status: Applicant.APPLICATION_STATUS.READ };
......
...@@ -11,6 +11,7 @@ export default class CompanyRegisterModal extends React.Component { ...@@ -11,6 +11,7 @@ export default class CompanyRegisterModal extends React.Component {
super(props); super(props);
/* istanbul ignore next */ /* istanbul ignore next */
this.handleChange = this.handleChange.bind(this); this.handleChange = this.handleChange.bind(this);
this.handleFile = this.handleFile.bind(this);
this.handleSubmit = this.handleSubmit.bind(this); this.handleSubmit = this.handleSubmit.bind(this);
} }
...@@ -18,6 +19,11 @@ export default class CompanyRegisterModal extends React.Component { ...@@ -18,6 +19,11 @@ export default class CompanyRegisterModal extends React.Component {
this.setState({ [e.target.name]: e.target.value }); this.setState({ [e.target.name]: e.target.value });
}; };
handleFile = (e) => {
this.setState({ [e.target.name]: e.target.files[0] });
console.log(e.target.files[0]);
};
handlePassword = (e) => { handlePassword = (e) => {
if (e.target.name === 'password') this.passwordField = e.target; else if (e.target.name === 'password') this.passwordField = e.target; else
...@@ -34,7 +40,7 @@ export default class CompanyRegisterModal extends React.Component { ...@@ -34,7 +40,7 @@ export default class CompanyRegisterModal extends React.Component {
handleSubmit = (e) => { handleSubmit = (e) => {
e.preventDefault(); e.preventDefault();
console.log(this.state);
Server.submit('/register/', this.state).then((response) => { Server.submit('/register/', this.state).then((response) => {
Storage.set('user-data', response); Storage.set('user-data', response);
browserHistory.push('/home'); browserHistory.push('/home');
...@@ -81,7 +87,7 @@ export default class CompanyRegisterModal extends React.Component { ...@@ -81,7 +87,7 @@ export default class CompanyRegisterModal extends React.Component {
<Form.Field required> <Form.Field required>
<label htmlFor="logo">Logo</label> <label htmlFor="logo">Logo</label>
<Input <Input
onChange={this.handleChange} onChange={this.handleFile}
name="logo" name="logo"
icon={{ name: 'attach', circular: true, link: true }} icon={{ name: 'attach', circular: true, link: true }}
placeholder="attach logo" placeholder="attach logo"
......
...@@ -65,22 +65,12 @@ export default class Vacancy extends React.Component { ...@@ -65,22 +65,12 @@ export default class Vacancy extends React.Component {
); );
} }
apply = () => {
const requestData = { vacancy_id: this.props.data.id, cover_letter: this.state.coverLetter };
Server.post(`/students/${this.props.studentId}/applied-vacancies/`, requestData).then(() => {
this.modalAlert.open('Pendaftaran Berhasil', 'Pendaftaran anda berhasil direkam. Harap menunggu kabar selanjutnya dari pihak yang terkait\n', this.handleClose);
this.setState({ status: 'registered' });
}, () => this.modalAlert.open('Pendaftaran Gagal', 'Maaf pendaftaran yang anda lakukan gagal. Harap ulangi pendaftaran atau hubungi administrator\n', this.handleClose),
);
};
generateAction() { generateAction() {
const applyModal = (<ApplyModal const applyModal = (<ApplyModal
active={this.state.status === 'new'} active={this.state.status === 'new'}
data={{ header: this.props.data.name, description: this.props.data.description }} data={{ header: this.props.data.name, description: this.props.data.description, id: this.props.data.id }}
buttonTitle="Detail" buttonTitle="Detail"
apply={this.apply} studentId={this.props.studentId}
/>); />);
const cancelButton = <Button loading={this.state.deleteLoading} floated="right" color="red" onClick={this.openConfirmationModal}>Batal</Button>; const cancelButton = <Button loading={this.state.deleteLoading} floated="right" color="red" onClick={this.openConfirmationModal}>Batal</Button>;
......
import React from 'react'; import React from 'react';
import { Item, Button, Grid } from 'semantic-ui-react'; import { Item, Button, Grid, Loader } 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 {
...@@ -25,7 +24,7 @@ export default class VacancyList extends React.Component { ...@@ -25,7 +24,7 @@ export default class VacancyList extends React.Component {
constructor(props) { constructor(props) {
super(props); super(props);
/* istanbul ignore next */ /* istanbul ignore next */
this.state = { vacancies: [], bookmarkList: [], appliedList: [] }; this.state = { vacancies: [], bookmarkList: [], appliedList: [], loading: true };
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);
...@@ -34,7 +33,7 @@ export default class VacancyList extends React.Component { ...@@ -34,7 +33,7 @@ export default class VacancyList extends React.Component {
if (this.props.type === 'student') { if (this.props.type === 'student') {
this.updateStatusList(); this.updateStatusList();
} else Server.get(this.props.url, false).then((data) => { } else Server.get(this.props.url, false).then((data) => {
this.setState({ vacancies: data }); this.setState({ vacancies: data, loading: false });
}); });
} }
...@@ -58,7 +57,7 @@ export default class VacancyList extends React.Component { ...@@ -58,7 +57,7 @@ export default class VacancyList extends React.Component {
}).then(() => Server.get(`/students/${this.props.userId}/applied-vacancies/`, false).then((data) => { }).then(() => Server.get(`/students/${this.props.userId}/applied-vacancies/`, false).then((data) => {
this.setState({ appliedList: data }); this.setState({ appliedList: data });
})).then(() => Server.get(this.props.url, false).then((data) => { })).then(() => Server.get(this.props.url, false).then((data) => {
this.setState({ vacancies: data }); this.setState({ vacancies: data, loading: false });
})); }));
} }
...@@ -111,6 +110,7 @@ export default class VacancyList extends React.Component { ...@@ -111,6 +110,7 @@ export default class VacancyList extends React.Component {
render = () => ( render = () => (
<div> <div>
<Loader active={this.state.loading} />
<ModalAlert ref={(modal) => { this.modalAlert = modal; }} /> <ModalAlert ref={(modal) => { this.modalAlert = modal; }} />
<Grid container columns="eleven" doubling> <Grid container columns="eleven" doubling>
{ this.companyHeader() } { this.companyHeader() }
......
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