Fakultas Ilmu Komputer UI

Commit 72aedee9 authored by M. Reza Qorib's avatar M. Reza Qorib
Browse files

Merge branch 'UserStory3' of https://gitlab.com/PPL2017csui/PPLA1 into Features/ProfilePage

# Conflicts:
#	assets/css/custom.css
#	assets/js/index.jsx
parents 5b209db2 5dd947d2
......@@ -11,6 +11,7 @@
"func-names": ["error", "never"],
"react/prefer-stateless-function": [0, { "ignorePureComponents": true }],
"react/forbid-prop-types": [0],
"react/no-multi-comp": [0, { "ignoreStateless": 1 }],
"import/extensions": ["off", "never"],
"import/no-unresolved": 0,
"no-underscore-dangle" : 0,
......
......@@ -8,7 +8,6 @@
-moz-box-sizing: border-box;
}
.ui.inverted.segment.header{
background-color: #EEEEEE;
color:black;
......@@ -176,53 +175,3 @@ card .formRegis{
color: black;
}
.biodata h5{
line-height: 30%;
}
.biodata-company h4{
color: grey;
}
.button-profile{
margin-top:30px;
}
.ui.segment.profile-form{
padding-bottom: 37px;
margin-top:4%;
}
.profilePage{
margin-bottom:40px;
margin-left:5%;
margin-right:5%;
}
.ui.segment.segment-profile-company{
margin-left: 10%;
margin-right: 10%;
padding: 5%;
}
.ui.segment.profile-form-company{
margin-top:4%;
margin-left: 10%;
margin-right: 10%;
padding-bottom:3%;
}
.company-profile{
padding-bottom:5%;
}
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" />
);
}
}
import React from 'react';
import { Segment, Image, Header, Icon, Container, Button, Form } from 'semantic-ui-react';
import { Segment, Image, Header, Icon, Checkbox, Container, Button, Form } from 'semantic-ui-react';
import Server from './lib/Server';
export default class ProfilePage extends React.Component {
......@@ -7,6 +7,7 @@ export default class ProfilePage extends React.Component {
static propTypes = {
route: React.PropTypes.object.isRequired,
params: React.PropTypes.object.isRequired,
user: React.PropTypes.object.isRequired,
};
constructor(props) {
......@@ -24,9 +25,17 @@ export default class ProfilePage extends React.Component {
resume: '',
phone: '',
showTranscript: '',
form: {
picture: '',
name: '',
phone: '',
resume: '',
showTranscript: '',
},
};
this.getProfile = this.getProfile.bind(this);
this.handleChange = this.handleChange.bind(this);
this.handleCheckbox = this.handleCheckbox.bind(this);
this.getProfile();
}
......@@ -34,17 +43,24 @@ export default class ProfilePage extends React.Component {
if (this.props.route.own) {
// check api format in /api#!/login
this.state = {
id: this.props.route.data.student.id,
npm: this.props.route.data.student.npm,
name: this.props.route.data.student.name,
major: this.props.route.data.student.major,
batch: this.props.route.data.student.batch,
email: this.props.route.data.student.user.email,
cityOfBirth: this.props.route.data.student.birth_place,
dateOfBirth: this.props.route.data.student.birth_date,
resume: this.props.route.data.student.resume,
phone: this.props.route.data.student.phone_number,
showTranscript: this.props.route.data.student.show_transcript,
id: this.props.user.data.student.id,
npm: this.props.user.data.student.npm,
name: this.props.user.data.student.name,
major: this.props.user.data.student.major,
batch: this.props.user.data.student.batch,
email: this.props.user.data.student.user.email,
cityOfBirth: this.props.user.data.student.birth_place,
dateOfBirth: this.props.user.data.student.birth_date,
resume: this.props.user.data.student.resume,
phone: this.props.user.data.student.phone_number,
showTranscript: this.props.user.data.student.show_transcript,
form: {
picture: '',
name: '',
phone: '',
resume: '',
showTranscript: '',
},
};
return Promise.resolve(this.state);
} else {
......@@ -70,7 +86,18 @@ export default class ProfilePage extends React.Component {
}
handleChange = (e) => {
this.setState({ [e.target.name]: e.target.value });
console.log(e.target.name);
const form = this.state.form;
form[e.target.name] = e.target.value;
this.setState({ form });
console.log(this.state.form);
};
handleCheckbox = (e, d) => {
const form = this.state.form;
form[d.name] = d.checked;
this.setState({ form });
console.log(this.state.form);
};
updateForm(show) {
......@@ -100,6 +127,13 @@ export default class ProfilePage extends React.Component {
<label htmlFor="resume">Resume</label>
<input onChange={this.handleChange} placeholder="Resume" name="resume" type="File" />
</Form.Field>
<Form.Field>
<Checkbox
onChange={this.handleCheckbox}
label="Ijinkan perusahaan tempat saya mendaftar untuk melihat transkrip akademik saya"
name="showTranscript"
/>
</Form.Field>
<Button type="submit" size="small" primary floated="right">Submit</Button>
</Form>
</Segment>
......
import React from 'react';
import Tabs from './components/Tabs';
import Pane from './components/Pane';
import Storage from './lib/Storage';
import VacancyList from './components/VacancyList';
export default class VacancyPage extends React.Component {
static getRole() {
const student = Storage.get('user-data').student;
const company = Storage.get('user-data').company;
if (student) {
return { id: student.id, type: 'student' };
} else if (company) {
return { id: company.id, type: 'company' };
static propTypes = {
user: React.PropTypes.object.isRequired,
};
static getId(user) {
const role = user.role;
if (role === 'student') {
return user.data.student.id;
} else if (role === 'company') {
return user.data.company.id;
}
return { id: '0', type: 'error' };
return 0;
}
constructor(props) {
super(props);
/* istanbul ignore next */
const role = VacancyPage.getRole();
this.state = {
vacancies: [],
id: role.id,
role: role.type,
id: VacancyPage.getId(this.props.user),
};
}
generateVacancies() {
if (this.state.role === 'student') {
if (this.props.user.role === 'student') {
return (
<Tabs selected={0}>
<Pane label="Semua Lowongan" >
......@@ -43,7 +43,6 @@ export default class VacancyPage extends React.Component {
<Pane label="Lamaran saya" >
<VacancyList
key={2}
status="Batal"
userId={this.state.id}
url={`/students/${this.state.id}/applied-vacancies/`}
/>
......@@ -57,7 +56,7 @@ export default class VacancyPage extends React.Component {
</Pane>
</Tabs>
);
} else if (this.state.role === 'company') {
} else if (this.props.user.role === 'company') {
return (
<VacancyList key={1} userId={this.state.id} url={`/companies/${this.state.id}/vacancies/`} type="company" />
);
......
......@@ -8,94 +8,97 @@ import Storage from '../lib/Storage';
describe('VacancyPage', () => {
fetchMock.get('*', { data: 'value' });
const studentSession = {
url: 'http://localhost:8000/api/users/9/',
username: 'muhammad.reza42',
email: 'muhammad.reza42@ui.ac.id',
is_staff: false,
company: null,
supervisor: null,
student: {
id: 3,
user: {
url: 'http://localhost:8000/api/users/9/',
username: 'muhammad.reza42',
email: 'muhammad.reza42@ui.ac.id',
is_staff: false,
const studentUser = {
role: 'student',
data: {
url: 'http://localhost:8000/api/users/9/',
username: 'muhammad.reza42',
email: 'muhammad.reza42@ui.ac.id',
is_staff: false,
company: null,
supervisor: null,
student: {
id: 3,
user: {
url: 'http://localhost:8000/api/users/9/',
username: 'muhammad.reza42',
email: 'muhammad.reza42@ui.ac.id',
is_staff: false,
},
name: 'Muhammad R.',
created: '2017-03-28T13:33:46.147241Z',
updated: '2017-03-28T13:33:46.148248Z',
npm: 1406543593,
resume: null,
phone_number: null,
bookmarked_vacancies: [
3,
],
applied_vacancies: [
3,
1,
],
},
name: 'Muhammad R.',
created: '2017-03-28T13:33:46.147241Z',
updated: '2017-03-28T13:33:46.148248Z',
npm: 1406543593,
resume: null,
phone_number: null,
bookmarked_vacancies: [
3,
],
applied_vacancies: [
3,
1,
],
},
};
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,
const companyUser = {
role: 'company',
data: {
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',
},
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,
},
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,
const errorUser = {
role: 'error',
data: {
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', () => {
Storage.set('user-data', companySession);
const vacancyPage = ReactTestUtils.renderIntoDocument(
<VacancyPage studentId={1} url="test" />);
<VacancyPage user={companyUser} />);
expect(vacancyPage).to.exist;
expect(vacancyPage.state.role).to.equal('company');
});
it('renders for students without problem', () => {
Storage.set('user-data', studentSession);
const vacancyPage = ReactTestUtils.renderIntoDocument(
<VacancyPage studentId={1} url="test" />);
<VacancyPage user={studentUser} />);
expect(vacancyPage).to.exist;
expect(vacancyPage.state.role).to.equal('student');
});
it('renders without problem for error case', () => {
Storage.set('user-data', errorSession);
const vacancyPage = ReactTestUtils.renderIntoDocument(
<VacancyPage studentId={1} url="test" />);
<VacancyPage user={errorUser} />);
expect(vacancyPage).to.exist;
expect(vacancyPage.state.role).to.equal('error');
});
});
......@@ -12,10 +12,11 @@ describe('ApplyModal', () => {
it('open without problem', () => {
const modalPendaftaran = ReactTestUtils.renderIntoDocument(
<ApplyModal id={4} data={{ key: 'value' }} buttonTitle="submit" />);
<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;
});
it('change without problem', () => {
......
/* 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';
describe('CancelModal', () => {
it('renders without problem', () => {
const modalPendaftaran = ReactTestUtils.renderIntoDocument(
<CancelModal id={4} />);
expect(modalPendaftaran).to.exist;
});
it('open without problem', () => {
const modalPendaftaran = ReactTestUtils.renderIntoDocument(
<CancelModal id={4} />);
const modal = ReactTestUtils.findRenderedDOMComponentWithTag(modalPendaftaran, 'Button');
ReactTestUtils.Simulate.click(modal);
expect(modalPendaftaran.state.modalOpen).to.equal(true);
});
it('close without problem', () => {
const modalPendaftaran = ReactTestUtils.renderIntoDocument(
<CancelModal id={4} />);
modalPendaftaran.handleClose();
expect(modalPendaftaran.state.modalOpen).to.equal(false);
});
it('remove vacancy without problem', () => {
fetchMock.delete('*', { data: 'value' });
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('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 modalPendaftaran = ReactTestUtils.renderIntoDocument(
<CancelModal id={4} />);
modalPendaftaran.state.confirmed = true;
modalPendaftaran.forceUpdate()
expect(modalPendaftaran).to.exist;
});
});
// /* eslint-disable no-unused-expressions */
// import React from 'react';
// import ReactTestUtils from 'react-addons-test-utils';
// import fetchMock from 'fetch-mock';
// import ConfirmationModal from '../../components/ConfirmationModal';
// import Storage from '../../lib/Storage';
//
// describe('ConfirmationModal', () => {
// it('renders without problem', () => {
// const modalPendaftaran = ReactTestUtils.renderIntoDocument(
// <ConfirmationModal id={4} />);
// expect(modalPendaftaran).to.exist;
// });
//
// it('open without problem', () => {
// const modalPendaftaran = ReactTestUtils.renderIntoDocument(
// <ConfirmationModal id={4} />);
//
// const modal = ReactTestUtils.findRenderedDOMComponentWithTag(modalPendaftaran, 'Button');
// ReactTestUtils.Simulate.click(modal);
// expect(modalPendaftaran.state.modalOpen).to.equal(true);
// });
//
// it('close without problem', () => {
// const modalPendaftaran = ReactTestUtils.renderIntoDocument(
// <ConfirmationModal id={4} />);
//
// modalPendaftaran.handleClose();
// expect(modalPendaftaran.state.modalOpen).to.equal(false);
// });
//
// it('remove vacancy without problem', () => {
// fetchMock.delete('*', { data: 'value' });
// const modalPendaftaran = ReactTestUtils.renderIntoDocument(
// <ConfirmationModal 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('remove vacancy with problem', () => {
// fetchMock.delete('*', 404);
// const modalPendaftaran = ReactTestUtils.renderIntoDocument(
// <ConfirmationModal 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(
// <ConfirmationModal id={4} />);
//
// modalPendaftaran.confirm();
// expect(modalPendaftaran.state.header).to.equal('Permintaan gagal');
// fetchMock.restore();
// });
//
// it('render next modal without problem', () => {
// const modalPendaftaran = ReactTestUtils.renderIntoDocument(
// <ConfirmationModal id={4} />);
//
// modalPendaftaran.state.confirmed = true;
// modalPendaftaran.forceUpdate()
// expect(modalPendaftaran).to.exist;
// });
// });
import React from 'react';
import ReactTestUtils from 'react-addons-test-utils';
import ApplyConfirmationModal from '../../components/ApplyConfirmationModal';
import ConfirmationModal from '../../components/ConfirmationModal';
import fetchMock from 'fetch-mock';
import Storage from '../../lib/Storage';
import Server from '../../lib/Server';
describe('ApplyConfirmationModal', () => {
describe('ConfirmationModal', () => {
it('renders without problem', () => {
const applyModal = ReactTestUtils.renderIntoDocument(