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 {
const company = this.props.user.data.company;
return (
<Tabs selected={0}>
<Pane label="Lamaran Baru" >
<ApplicantList key={1} companyId={company.id} url={`/companies/${company.id}/applications/?status=${Applicant.APPLICATION_STATUS.NEW}`} status={Applicant.APPLICATION_STATUS.NEW} />
</Pane>
<Pane label="Lamaran Dibaca" >
<ApplicantList key={2} companyId={company.id} url={`/companies/${company.id}/applications/?status=${Applicant.APPLICATION_STATUS.READ}`} status={Applicant.APPLICATION_STATUS.READ} />
</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>
<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 label="Lamaran Dibaca" key={2} companyId={company.id} url={`/companies/${company.id}/applications/?status=${Applicant.APPLICATION_STATUS.READ}`} status={Applicant.APPLICATION_STATUS.READ} />
<ApplicantList label="Lamaran Ditandai" key={3} companyId={company.id} url={`/companies/${company.id}/applications/?status=${Applicant.APPLICATION_STATUS.BOOKMARKED}`} status={Applicant.APPLICATION_STATUS.BOOKMARKED} />
<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 label="Lamaran Ditolak" key={5} companyId={company.id} url={`/companies/${company.id}/applications/?status=${Applicant.APPLICATION_STATUS.REJECTED}`} status={Applicant.APPLICATION_STATUS.REJECTED} />
</Tabs>
);
}
......
import React from 'react';
import TopMenu from './components/TopMenu';
import Footer from './components/Footer'
import Footer from './components/Footer';
export default class Dashboard extends React.Component {
static propTypes = {
......
......@@ -89,7 +89,7 @@ export default class ProfilePage extends React.Component {
const form = this.state.form;
form[e.target.name] = e.target.files[0];
this.setState({ form });
}
};
handleChange = (e) => {
const form = this.state.form;
......
......@@ -2,6 +2,7 @@
import React from 'react';
import ReactTestUtils from 'react-addons-test-utils';
import ApplyModal from '../../components/ApplyModal';
import fetchMock from 'fetch-mock';
describe('ApplyModal', () => {
it('renders without problem', () => {
......@@ -11,12 +12,25 @@ describe('ApplyModal', () => {
});
it('open without problem', () => {
fetchMock.post('*', {});
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('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', () => {
......
......@@ -3,6 +3,7 @@ import React from 'react';
import ReactTestUtils from 'react-addons-test-utils';
import fetchMock from 'fetch-mock';
import ApproveModal from '../../components/ApproveModal';
import Applicant from '../../components/Applicant';
describe('ApproveModal', () => {
it('renders without problem', () => {
......@@ -14,7 +15,7 @@ describe('ApproveModal', () => {
it('open without problem', () => {
fetchMock.get('*', { student: { resume: 'asdasd' } });
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');
ReactTestUtils.Simulate.click(modal);
......@@ -24,8 +25,9 @@ describe('ApproveModal', () => {
it('close without problem', () => {
fetchMock.get('*', { student: { resume: 'asdasd' } });
fetchMock.patch('*', { student: { resume: 'asdasd' } });
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();
expect(modalApproval.state.modalOpen).to.equal(false);
......
......@@ -99,30 +99,4 @@ describe('Vacancy', () => {
expect(lowongan.bookmark()).to.be.undefined;
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 { Icon, Modal, Button, TextArea, Form } from 'semantic-ui-react';
import ModalAlert from './../components/ModalAlert';
import Server from './../lib/Server';
export default class ApplyModal extends React.Component {
static propTypes = {
data: React.PropTypes.object.isRequired,
active: React.PropTypes.bool.isRequired,
buttonTitle: React.PropTypes.string.isRequired,
apply: React.PropTypes.func.isRequired,
studentId: React.PropTypes.number.isRequired,
};
constructor(props) {
......@@ -36,12 +37,15 @@ export default class ApplyModal extends React.Component {
});
handleApply = () => {
this.load();
this.props.apply();
this.setState({ load: true });
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 = () => (
<Modal
trigger={<Button primary onClick={this.handleOpen} floated="right">{this.props.buttonTitle}</Button>}
......
......@@ -24,7 +24,7 @@ export default class ApproveModal extends React.Component {
}
handleOpen = () => this.setState({ modalOpen: true });
handleClose = () => this.readApplication() && this.setState({ modalOpen: false });
handleClose = () => { this.readApplication(); this.setState({ modalOpen: false }); }
readApplication = () => {
const data = { status: Applicant.APPLICATION_STATUS.READ };
......
......@@ -11,6 +11,7 @@ export default class CompanyRegisterModal extends React.Component {
super(props);
/* istanbul ignore next */
this.handleChange = this.handleChange.bind(this);
this.handleFile = this.handleFile.bind(this);
this.handleSubmit = this.handleSubmit.bind(this);
}
......@@ -18,6 +19,11 @@ export default class CompanyRegisterModal extends React.Component {
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) => {
if (e.target.name === 'password') this.passwordField = e.target; else
......@@ -34,7 +40,7 @@ export default class CompanyRegisterModal extends React.Component {
handleSubmit = (e) => {
e.preventDefault();
console.log(this.state);
Server.submit('/register/', this.state).then((response) => {
Storage.set('user-data', response);
browserHistory.push('/home');
......@@ -81,7 +87,7 @@ export default class CompanyRegisterModal extends React.Component {
<Form.Field required>
<label htmlFor="logo">Logo</label>
<Input
onChange={this.handleChange}
onChange={this.handleFile}
name="logo"
icon={{ name: 'attach', circular: true, link: true }}
placeholder="attach logo"
......
......@@ -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() {
const applyModal = (<ApplyModal
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"
apply={this.apply}
studentId={this.props.studentId}
/>);
const cancelButton = <Button loading={this.state.deleteLoading} floated="right" color="red" onClick={this.openConfirmationModal}>Batal</Button>;
......
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 Vacancy from './Vacancy';
import CompanyVacancy from './CompanyVacancy';
import Server from '../lib/Server';
import ModalAlert from '../components/ModalAlert';
import Aplicant from './../components/Applicant';
export default class VacancyList extends React.Component {
......@@ -25,7 +24,7 @@ export default class VacancyList extends React.Component {
constructor(props) {
super(props);
/* istanbul ignore next */
this.state = { vacancies: [], bookmarkList: [], appliedList: [] };
this.state = { vacancies: [], bookmarkList: [], appliedList: [], loading: true };
this.updateStatusList = this.updateStatusList.bind(this);
this.generateVacancies = this.generateVacancies.bind(this);
this.checkBookmark = this.checkBookmark.bind(this);
......@@ -34,7 +33,7 @@ export default class VacancyList extends React.Component {
if (this.props.type === 'student') {
this.updateStatusList();
} 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 {
}).then(() => Server.get(`/students/${this.props.userId}/applied-vacancies/`, false).then((data) => {
this.setState({ appliedList: 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 {
render = () => (
<div>
<Loader active={this.state.loading} />
<ModalAlert ref={(modal) => { this.modalAlert = modal; }} />
<Grid container columns="eleven" doubling>
{ 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