Fakultas Ilmu Komputer UI

Commit 96885206 authored by zamil majdy's avatar zamil majdy
Browse files

Merge branch 'Features/create-vacancy-company' into 'UserStory4'

Features/create vacancy company

See merge request !8
parents 2a832043 1ad20c9b
.center{
text-align: center;
}
* {
box-sizing: border-box;
-webkit-box-sizing: border-box;
......@@ -26,14 +23,19 @@
background-color: #EEEEEE;
}
.create-lowongan{
margin: 60px 19% 100px;
}
.ui.segment.form-segment{
padding-bottom: 50px;
}
.tabs {
margin-top: 100px;
margin-left: 100px;
margin-right: 100px;
background: #fff;
border: 1px solid #e5e5e5;
border-radius: 3px;
margin-bottom: 30px;
margin: 100px 100px 30px;
}
.tabs__labels {
margin: 0;
......@@ -57,21 +59,23 @@ background-color: #EEEEEE;
}
.halamanLogin{
background-image: url("../img/bw-blur.png");
background-size: cover;
background-position: center;
background-attachment: fixed;
background: url("../img/background.png")no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
padding-bottom: 80px;
}
.headerLoginform{
background-color: #2e6da4;
}
.formLogin{
margin: 0 auto;
margin-top: 80px;
width: 430px;
margin: 30px auto 0;
width: 430px;
}
.registerModal{
......@@ -104,7 +108,7 @@ font-size: 32px;
}
.daftar{
float: right;
margin-top:10px;
margin-top:10px;
}
.coverLetter{
......@@ -121,7 +125,7 @@ font-size: 32px;
.registerForm{
margin: 0 auto;
padding:50px;
/*padding:50px;*/
background-color: #3B8686;
}
......@@ -137,13 +141,6 @@ h5{
color: black;
}
textarea{
width: 800px !important;
height: 160px !important;
}
.note {
color: gray;
margin: 8px 0;
......@@ -167,7 +164,7 @@ card .formRegis{
margin-top: 100px;
}
itemLowongan{
.itemLowongan{
color: black;
}
......@@ -175,6 +172,11 @@ itemLowongan{
background-color: #ffffff;
}
.item.applicantItems{
height: 110px;
}
\ No newline at end of file
.extra.extra-company h3{
padding-top:10px;
}
.extra.extra-company h2{
color: black;
}
import React from 'react';
import { Segment, Button, Form, Header, Icon, Input } from 'semantic-ui-react';
import { browserHistory } from 'react-router';
import DatePicker from 'react-datepicker';
import moment from 'moment';
import ModalAlert from './components/ModalAlert';
import Server from './lib/Server';
import Storage from './lib/Storage';
import Dumper from './lib/Dumper';
export default class CreateVacancy extends React.Component {
static propTypes = {
params: React.PropTypes.object.isRequired,
};
constructor(props) {
super(props);
/* istanbul ignore next */
this.handleChange = this.handleChange.bind(this);
this.handleSubmit = this.handleSubmit.bind(this);
this.state = {
formLoading: false,
company: Storage.get('user-data').company,
vacancyId: this.props.params.id,
open_time: moment(),
close_time: moment(),
name: '',
description: '',
};
this.state.vacancyId && Server.get(`/vacancies/${this.state.vacancyId}/`).then((r) => {
this.setState({
description: r.description,
name: r.name,
open_time: moment(r.open_time),
close_time: moment(r.close_time),
});
});
}
handleChange = (e) => {
this.setState({ [e.target.name]: e.target.value });
};
handleSubmit = (e) => {
e.preventDefault();
this.setState({ formLoading: true });
const data = Object.assign({}, this.state);
data.open_time = data.open_time.format();
data.close_time = data.close_time.format();
data.company = this.state.company.id;
const url = this.state.vacancyId ? `/vacancies/${this.state.vacancyId}/` : '/vacancies/';
const method = this.state.vacancyId ? 'PATCH' : 'POST';
Server.sendRequest(url, method, data).then(() => {
browserHistory.push('/lowongan');
}, error => error.then((r) => {
this.modalAlert.open('Gagal Membuat Lowongan', Dumper.dump(r, ' '));
this.setState({ formLoading: false });
}));
};
render = () => (
<div className="create-lowongan" >
<ModalAlert ref={(modal) => { this.modalAlert = modal; }} />
<Segment className="form-segment">
<Header as="h2" icon textAlign="center">
<Icon name="briefcase" circular />
<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 />
<Form.TextArea
name="description"
label="Deskripsi"
placeholder="Deskripsi Lowongan..."
onChange={this.handleChange}
value={this.state.description} required
/>
<Form.Group widths="equal">
<Form.Field
className="open-time-field"
control={DatePicker}
label="Waktu Buka Lowongan"
selected={this.state.open_time}
onChange={date => this.setState({ open_time: date })}
required
/>
<Form.Field
className="close-time-field"
control={DatePicker}
label="Waktu Tutup Lowongan"
selected={this.state.close_time}
onChange={date => this.setState({ close_time: date })}
required
/>
</Form.Group>
<Button type="submit" primary floated="right">Submit</Button>
</Form>
</Segment>
</div>
);
}
......@@ -11,7 +11,7 @@ export default class Dashboard extends React.Component {
render = () => (
<div>
<TopMenu />
<TopMenu />
{this.props.children}
</div>
)
......
import React from 'react';
import CompanyVacancy from './components/CompanyVacancy';
import { Segment } from 'semantic-ui-react';
export default class ApplicantPage extends React.Component {
render() {
return (
<CompanyVacancy header="Software Engineer" />
<CompanyVacancy header="Software Engineer" />
);
}
}
......@@ -59,7 +59,7 @@ export default class VacancyPage extends React.Component {
);
} else if (this.state.role === 'company') {
return (
<VacancyList key={1} userId={this.state.id} url="/vacancies/" type="company" />
<VacancyList key={1} userId={this.state.id} url={`/companies/${this.state.id}/vacancies/`} type="company" />
);
}
......
import React from 'react';
import ReactTestUtils from 'react-addons-test-utils';
import fetchMock from 'fetch-mock';
import CreateVacancy from '../CreateVacancy';
import Storage from '../lib/Storage';
describe('CreateVacancy', () => {
const companySession = {
url: 'http://localhost:8001/api/users/8/',
username: 'Tutuplapak',
email: '',
is_staff: false,
company: {
id: 3,
user: {
url: 'http://localhost:8001/api/users/8/',
username: 'Tutuplapak',
email: '',
is_staff: false,
},
name: 'Tutuplapak',
created: '2017-03-28T07:30:10.535000Z',
updated: '2017-03-28T07:30:10.535000Z',
description: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla aliquet semper neque a fermentum. Duis ac tellus vitae augue iaculis ultrices. Curabitur commodo et neque nec feugiat. Morbi ac diam vel nunc commodo cursus. Phasellus nulla sapien, hendrerit vitae bibendum at, sollicitudin eu ante. Maecenas maximus, ante eu sollicitudin convallis, mauris nunc posuere risus, eu porttitor diam lacus vitae enim. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Suspendisse at lectus a elit sollicitudin tempor. Nullam condimentum, justo nec tincidunt maximus, neque mi vulputate leo, sit amet lacinia massa ex eget sem. Duis ac erat facilisis, fringilla mauris in, consequat neque. In et neque consequat, vehicula magna at, efficitur ante. Mauris ac lacinia nibh.\r\n\r\nProin sagittis, lectus quis maximus varius, libero justo sollicitudin augue, non lacinia risus orci a enim. Curabitur iaculis enim quis ullamcorper commodo. Vivamus id nisi rhoncus, dignissim tellus quis, interdum est. Fusce sollicitudin eu libero ac feugiat. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Maecenas semper posuere ex, sed accumsan libero iaculis faucibus. Fusce laoreet ac ligula ut consectetur. Donec tortor mauris, rutrum at sodales et, viverra in dolor. Sed bibendum elit et maximus volutpat. Phasellus justo ipsum, laoreet sit amet faucibus eu, ultricies suscipit mauris. Nullam aliquam libero eu ante ultrices mattis. Donec non justo hendrerit neque volutpat placerat. Ut euismod est nec sem mollis, sit amet porttitor massa rhoncus. Aenean id erat sit amet nunc ultrices scelerisque non in ipsum. Curabitur sollicitudin nulla id mi accumsan venenatis.',
verified: true,
logo: 'http://localhost:8001/files/company-logo/8a258a48-3bce-4873-b5d1-538b360d0059.png',
address: 'Jl. Kebayoran Baru nomor 13, Jakarta Barat',
},
supervisor: null,
student: null,
};
const errorSession = {
url: 'http://localhost:8001/api/users/8/',
username: 'Tutuplapak',
email: '',
is_staff: false,
company: null,
supervisor: null,
student: null,
};
it('renders for companies without problem', () => {
fetchMock.get('*', {});
Storage.set('user-data', companySession);
const createVacancy = ReactTestUtils.renderIntoDocument(
<CreateVacancy params={{ id: 1 }} />,
);
expect(createVacancy).to.exist;
fetchMock.restore();
});
it('renders without problem for error case', () => {
fetchMock.get('*', {});
Storage.set('user-data', errorSession);
const createVacancy = ReactTestUtils.renderIntoDocument(
<CreateVacancy params={{ id: 1 }} />,
);
expect(createVacancy).to.exist;
fetchMock.restore();
});
it('support handle change', () => {
fetchMock.get('*', {});
Storage.set('user-data', companySession);
const createVacancy = ReactTestUtils.renderIntoDocument(
<CreateVacancy params={{ id: 1 }} />,
);
createVacancy.setState({
name: 'stub',
description: 'stub',
});
createVacancy.handleChange({ target: { name: 'test', value: 'hue' } });
expect(createVacancy.state.test).to.equal('hue');
fetchMock.restore();
});
it('submit vacancy properly (loading)', () => {
fetchMock.post('*', 404);
fetchMock.get('*', {});
Storage.set('user-data', companySession);
const createVacancy = ReactTestUtils.renderIntoDocument(
<CreateVacancy params={{ id: undefined }} />,
);
createVacancy.setState({
name: 'stub',
description: 'stub',
});
const openField = ReactTestUtils.findRenderedDOMComponentWithClass(createVacancy, 'open-time-field');
const closeField = ReactTestUtils.findRenderedDOMComponentWithClass(createVacancy, 'close-time-field');
ReactTestUtils.Simulate.click(openField);
ReactTestUtils.Simulate.keyDown(openField, { key: 'Enter', keyCode: 13, which: 13 });
ReactTestUtils.Simulate.click(closeField);
ReactTestUtils.Simulate.keyDown(closeField, { key: 'Enter', keyCode: 13, which: 13 });
expect(createVacancy.state.formLoading).to.equal(false);
createVacancy.handleSubmit(new Event('click'));
expect(createVacancy.state.formLoading).to.equal(true);
fetchMock.restore();
});
it('submit vacancy properly (success)', () => {
fetchMock.post('*', { data: 'value' });
fetchMock.get('*', {});
Storage.set('user-data', companySession);
const createVacancy = ReactTestUtils.renderIntoDocument(
<CreateVacancy params={{ id: undefined }} />,
);
createVacancy.setState({
name: 'stub',
description: 'stub',
});
expect(createVacancy.state.formLoading).to.equal(false);
createVacancy.handleSubmit(new Event('click'));
expect(createVacancy.state.formLoading).to.equal(true);
fetchMock.restore();
});
it('submit vacancy properly (loading)', () => {
fetchMock.patch('*', 404);
fetchMock.get('*', {});
Storage.set('user-data', companySession);
const createVacancy = ReactTestUtils.renderIntoDocument(
<CreateVacancy params={{ id: 1 }} />,
);
createVacancy.setState({
name: 'stub',
description: 'stub',
});
const openField = ReactTestUtils.findRenderedDOMComponentWithClass(createVacancy, 'open-time-field');
const closeField = ReactTestUtils.findRenderedDOMComponentWithClass(createVacancy, 'close-time-field');
ReactTestUtils.Simulate.click(openField);
ReactTestUtils.Simulate.keyDown(openField, { key: 'Enter', keyCode: 13, which: 13 });
ReactTestUtils.Simulate.click(closeField);
ReactTestUtils.Simulate.keyDown(closeField, { key: 'Enter', keyCode: 13, which: 13 });
expect(createVacancy.state.formLoading).to.equal(false);
createVacancy.handleSubmit(new Event('click'));
expect(createVacancy.state.formLoading).to.equal(true);
fetchMock.restore();
});
it('submit vacancy properly (success)', () => {
fetchMock.patch('*', { data: 'value' });
fetchMock.get('*', {});
Storage.set('user-data', companySession);
const createVacancy = ReactTestUtils.renderIntoDocument(
<CreateVacancy params={{ id: 1 }} />,
);
createVacancy.setState({
name: 'stub',
description: 'stub',
});
expect(createVacancy.state.formLoading).to.equal(false);
createVacancy.handleSubmit(new Event('click'));
expect(createVacancy.state.formLoading).to.equal(true);
fetchMock.restore();
});
});
/* eslint-disable no-unused-expressions */
import React from 'react';
import ReactTestUtils from 'react-addons-test-utils';
import fetchMock from 'fetch-mock';
import VacancyPage from '../VacancyPage';
import Storage from '../lib/Storage';
// import Server from '../../lib/Server';
describe('VacancyList', () => {
describe('VacancyPage', () => {
fetchMock.get('*', { data: 'value' });
const studentSession = {
url: 'http://localhost:8000/api/users/9/',
username: 'muhammad.reza42',
......
import React from 'react';
import ReactTestUtils from 'react-addons-test-utils';
import ApplyConfirmationModal from '../../components/ApplyConfirmationModal';
import fetchMock from 'fetch-mock';
import Storage from '../../lib/Storage';
import Server from '../../lib/Server';
describe('ApplyConfirmationModal', () => {
it('renders without problem', () => {
const applyModal = ReactTestUtils.renderIntoDocument(
<ApplyConfirmationModal id={4} coverLetter="letter" onChangeValue={() => {}} />,
);
expect(applyModal).to.exist;
});
it('test apply without problem', () => {
const applyModal = ReactTestUtils.renderIntoDocument(
<ApplyConfirmationModal id={4} coverLetter="letter" onChangeValue={() => {}} />,
);
const response = { student: { id: 1, name: 2 } };
Storage.set('user-data', response);
fetchMock.post('*', { data: 'value' });
applyModal.open();
applyModal.handleOpen();
applyModal.close();
expect(applyModal.state.header).to.equal('Menghubungkan ke Server');
fetchMock.restore();
});
it('test apply with problem', () => {
const applyModal = ReactTestUtils.renderIntoDocument(
<ApplyConfirmationModal id={4} coverLetter="letter" onChangeValue={() => {}} />,
);
const response = { student: { id: 1, name: 2 } };
Storage.set('user-data', response);
fetchMock.post('*', 404);
applyModal.open();
applyModal.handleOpen();
applyModal.close();
expect(applyModal.state.header).to.equal('Menghubungkan ke Server');
fetchMock.restore();
});
});
\ No newline at end of file
/* eslint-disable no-unused-expressions */
import React from 'react';
import ReactTestUtils from 'react-addons-test-utils';
import fetchMock from 'fetch-mock';
import CancelModal from '../../components/CancelModal';
import Storage from '../../lib/Storage';
......@@ -29,6 +30,7 @@ describe('CancelModal', () => {
});
it('remove vacancy without problem', () => {
fetchMock.delete('*', { data: 'value' });
const modalPendaftaran = ReactTestUtils.renderIntoDocument(
<CancelModal id={4} />);
......@@ -36,21 +38,32 @@ describe('CancelModal', () => {
Storage.set('user-data', response3);
modalPendaftaran.removeVacancy();
expect(modalPendaftaran.state.header).to.exist;
fetchMock.restore();
});
it('confirm without problem', () => {
const fetchMock = require('fetch-mock');
fetchMock.delete('*', { data: 'value' });
it('remove vacancy with problem', () => {
fetchMock.delete('*', 404);
const modalPendaftaran = ReactTestUtils.renderIntoDocument(
<CancelModal id={4} />);
const response3 = { student: { id: 1, name: 2 } };
Storage.set('user-data', response3);
modalPendaftaran.removeVacancy();
expect(modalPendaftaran.state.header).to.exist;
fetchMock.restore();
});
it('confirm with problem', () => {
fetchMock.delete('*', 404);
const modalPendaftaran = ReactTestUtils.renderIntoDocument(
<CancelModal id={4} />);
modalPendaftaran.confirm();
expect(modalPendaftaran.state.header).to.equal('Permintaan gagal');
fetchMock.restore();
});
it('render next modal without problem', () => {
const fetchMock = require('fetch-mock');
fetchMock.delete('*', { data: 'value' });
const modalPendaftaran = ReactTestUtils.renderIntoDocument(
<CancelModal id={4} />);
......@@ -58,5 +71,4 @@ describe('CancelModal', () => {
modalPendaftaran.forceUpdate()
expect(modalPendaftaran).to.exist;
});
});
......@@ -53,7 +53,7 @@ describe('LoginForm', () => {
});
it('submit form without problem', () => {
fetchMock.post('*', {data: 'value'});
fetchMock.post('*', { data: 'value' });
const formLogin = ReactTestUtils.renderIntoDocument(
<LoginForm url="" />);
......@@ -62,5 +62,19 @@ describe('LoginForm', () => {
const form = ReactTestUtils.findRenderedDOMComponentWithTag(formLogin, 'Form');
ReactTestUtils.Simulate.submit(form);
fetchMock.restore();
});
it('submit form with problem', () => {
fetchMock.post('*', 404);
const formLogin = ReactTestUtils.renderIntoDocument(
<LoginForm url="" />);
const submitButton = ReactTestUtils.findRenderedDOMComponentWithTag(formLogin, 'Button');
ReactTestUtils.Simulate.click(submitButton);
const form = ReactTestUtils.findRenderedDOMComponentWithTag(formLogin, 'Form');
ReactTestUtils.Simulate.submit(form);
fetchMock.restore();
});
});
/* eslint-disable no-unused-expressions */
import React from 'react';
import ReactTestUtils from 'react-addons-test-utils';
import ModalAlert from '../../components/ModalAlert';
describe('ModalAlert', () => {
it('renders without problem', () => {
const modalAlert = ReactTestUtils.renderIntoDocument(