Fakultas Ilmu Komputer UI

Commit 0495fbed authored by Zamil Majdy's avatar Zamil Majdy
Browse files

[#140656091] [#33] [Refactor] Add transcript fetch

parent 5a1097bd
import React from 'react';
import CourseList from './components/CourseList';
import Server from './lib/Server';
export default class TranscriptPage extends React.Component {
constructor(props) {
super(props);
/* istanbul ignore next */
this.state = {
data: {"transcript":[{
"url": "http://api.cs.ui.ac.id/siakngcs/riwayat-mahasiswa/99731/",
"npm": "1406622616",
"kelas": {
"url": "http://api.cs.ui.ac.id/siakngcs/kelas/473569/",
"kd_kls": "473569",
"nm_kls": "MD 1 - B",
"nm_mk_cl": {
"url": "http://api.cs.ui.ac.id/siakngcs/matakuliah/817/",
"kd_mk": "CSF1600100",
"nm_mk": "Matematika Diskret 1",
"kd_org": "06.00.12.01",
"kd_kur": "06.00.12.01-2012",
"jml_sks": 3
},
"kd_kur_cl": "06.00.12.01-2012",
"kd_mk_cl": "CSF1600100",
"periode": {
"url": "http://api.cs.ui.ac.id/siakngcs/periode/25/",
"term": 1,
"tahun": 2014
},
"pengajar": [
{
"url":
"http://api.cs.ui.ac.id/siakngcs/dosen/196111251992031001/",
"nomor": "196111251992031001",
"nama": "Prof. Drs. T. Basaruddin M.Sc., Ph.D",
"id_skema": 1,
"nm_skema": "Skema Inti",
"maks_sks": 8
}
]
},
"kd_kls": "473569",
"kd_kur": "06.00.12.01-2012",
"kd_mk": "CSF1600100",
"kd_org": "01.00.12.01",
"term": 1,
"tahun": 2014,
"nilai": "A"
}],"name":"Si jagoan neon" }};//ambil dari database
static propTypes = {
params: React.PropTypes.object.isRequired,
};
}
constructor(props) {
super(props);
/* istanbul ignore next */
this.state = {};
Server.get(`/applications/${this.props.params.id}/`).then(response => this.setState({ data: response }));
}
render() {
return (
<CourseList data={this.state.data.transcript} name={this.state.data.name}/>
);
render() {
return (
this.state.data ? <CourseList data={this.state.data} /> : <h5 style={{ textAlign: 'center' }}> Mohon Tunggu.. </h5>
);
}
}
......@@ -7,47 +7,53 @@ import ApproveModal from '../../components/ApproveModal';
describe('ApproveModal', () => {
it('renders without problem', () => {
const modalApproval = ReactTestUtils.renderIntoDocument(
<ApproveModal updateStatus={() => {}} data={{ key: 'value' }} />);
<ApproveModal updateStatus={() => {}} data={{ key: 'value', student: { resume: 'asdasd' } }} />);
expect(modalApproval).to.exist;
});
it('open without problem', () => {
fetchMock.get('*', { student: { resume: 'asdasd' } });
const modalApproval = ReactTestUtils.renderIntoDocument(
<ApproveModal updateStatus={() => {}} data={{ key: 'value' }} />);
<ApproveModal updateStatus={() => {}} data={{ key: 'value', student: { resume: 'asdasd' } }} />);
const modal = ReactTestUtils.findRenderedDOMComponentWithTag(modalApproval, 'Button');
ReactTestUtils.Simulate.click(modal);
fetchMock.restore();
});
it('close without problem', () => {
fetchMock.get('*', { student: { resume: 'asdasd' } });
const modalApproval = ReactTestUtils.renderIntoDocument(
<ApproveModal updateStatus={() => {}} data={{ key: 'value' }} />);
<ApproveModal updateStatus={() => {}} data={{ key: 'value', student: { resume: 'asdasd' } }} />);
modalApproval.handleClose();
expect(modalApproval.state.modalOpen).to.equal(false);
fetchMock.restore();
});
it('reject without problem', () => {
fetchMock.get('*', { });
fetchMock.get('*', { student: { resume: 'asdasd' } });
fetchMock.patch('*', { });
const modalApproval = ReactTestUtils.renderIntoDocument(
<ApproveModal updateStatus={() => {}} data={{ key: 'value' }} />);
<ApproveModal updateStatus={() => {}} data={{ key: 'value', student: { resume: 'asdasd' }, cover_letter: 'asdasd' }} />);
modalApproval.modal = { open: () => {} };
modalApproval.reject();
modalApproval.rejectApplication();
modalApproval.gotoLink('link random');
expect(modalApproval.state.rejectLoading).to.equal(true);
fetchMock.restore();
});
it('apply without problem', () => {
fetchMock.get('*', { });
fetchMock.patch('*', { });
fetchMock.get('*', { student: { resume: 'asdasd' } });
fetchMock.patch('*', { });
const modalApproval = ReactTestUtils.renderIntoDocument(
<ApproveModal updateStatus={() => {}} data={{ key: 'value' }} />);
<ApproveModal updateStatus={() => {}} data={{ key: 'value', student: { resume: 'asdasd', show_transcript: true } }} />);
modalApproval.modal = { open: () => {} };
modalApproval.accept();
modalApproval.acceptApplication();
modalApproval.gotoLink('link random');
expect(modalApproval.state.acceptLoading).to.equal(true);
fetchMock.restore();
});
......
......@@ -51,6 +51,11 @@ export default class ApproveModal extends React.Component {
});
};
gotoLink = (url) => {
const win = window.open(url);
win.focus();
};
accept = () => {
this.modal.open(
'Terima Lamaran?',
......@@ -71,9 +76,12 @@ export default class ApproveModal extends React.Component {
<Modal.Header>Data Lamaran</Modal.Header>
<Modal.Content>
<h4> Cover Letter </h4>
{ this.props.data.cover_letter }
<div style={{ float: 'right' }}>
<a href={this.props.data.resume} >CV Pelamar </a>
{ this.props.data.cover_letter ? this.props.data.cover_letter : 'Kosong' }
<div style={{ float: 'right', textAlign: 'right' }}>
{this.props.data.student.resume ? <a onClick={() => this.gotoLink(this.props.data.student.resume)} href="#" >CV Pelamar </a> : ''}
<br />
{this.props.data.student.show_transcript ? <a onClick={() => this.gotoLink(`/transcript/${this.props.data.id}`)} href="#" >Transkrip Pelamar</a> : ''}
<br />
</div>
</Modal.Content>
<Modal.Actions>
......
......@@ -10,11 +10,10 @@ export default class Course extends React.Component {
render() {
return (
<Table.Row>
<Table.Cell>{this.props.courseName}</Table.Cell>
<Table.Cell>{this.props.grade}</Table.Cell>
</Table.Row>
<Table.Cell>{this.props.courseName}</Table.Cell>
<Table.Cell>{this.props.grade}</Table.Cell>
</Table.Row>
);
}
}
......@@ -4,45 +4,41 @@ import Course from './Course';
export default class CourseList extends React.Component {
static propTypes = {
data: React.PropTypes.array.isRequired,
name: React.PropTypes.array.isRequired,
data: React.PropTypes.object.isRequired,
};
constructor(props) {
super(props);
/* istanbul ignore next */
this.state = { course: this.props.data };
this.state = { course: this.props.data.transcript };
}
generateCourse() {
return this.state.course.map((course, index) =>
<Course
key={index}
courseName={course.kelas.nm_kls}
grade={course.nilai}
/>,
);
return this.state.course.map((course, index) => course.kelas ? (<Course
key={index}
grade={course.nilai}
courseName={course.kelas.nm_kls}
/>) : null);
}
render = () => (
<Grid.Column centered>
<Grid.Column>
<Segment>
<h2>Nama : {this.props.name}</h2>
<Table unstackable>
<Table.Header>
<Table.Row>
<Table.HeaderCell>Mata Kuliah</Table.HeaderCell>
<Table.HeaderCell>Nilai</Table.HeaderCell>
</Table.Row>
</Table.Header>
<h2>Nama : {this.props.data.name}</h2>
<Table unstackable>
<Table.Header>
<Table.Row>
<Table.HeaderCell>Mata Kuliah</Table.HeaderCell>
<Table.HeaderCell>Nilai</Table.HeaderCell>
</Table.Row>
</Table.Header>
<Table.Body>
{ this.generateCourse() }
</Table.Body>
</Table>
<Table.Body>
{ this.generateCourse() }
</Table.Body>
</Table>
</Segment>
</Grid.Column>
</Grid.Column>
);
}
......@@ -95,7 +95,7 @@ export default class VacancyList extends React.Component {
if (this.props.type === 'company') {
return (
<Grid textAlign="center">
<Button size="tiny" icon="eye" labelPosition="left" color="facebook" content="Lihat Semua Pendaftar" />
<Button size="tiny" as={Link} to="/pelamar" icon="eye" labelPosition="left" color="facebook" content="Lihat Semua Pendaftar" />
<Button size="tiny" as={Link} to="/buat-lowongan" icon="add" labelPosition="left" content="Tambah Lowongan Baru" color="teal" />
</Grid>
);
......
......@@ -8,6 +8,7 @@ import CreateVacancy from './CreateVacancy';
import Server from './lib/Server';
import Storage from './lib/Storage';
import ApplicantPage from './ApplicantPage';
import TranscriptPage from './TranscriptPage';
export default class App extends React.Component {
......@@ -86,6 +87,7 @@ export default class App extends React.Component {
<Router history={browserHistory}>
<Route path="/login" component={Login} />
<Route component={Dashboard} onEnter={this.handleAuth}>
<Route path="/transcript/:id" component={company(TranscriptPage)} />
<Route path="/lowongan" component={commonUser(VacancyPage)} />
<Route path="/buat-lowongan" component={company(CreateVacancy)} />
<Route path="/buat-lowongan/:id" component={company(CreateVacancy)} />
......
......@@ -159,4 +159,4 @@ SESSION_COOKIE_HTTPONLY = False
RUNNING_DEVSERVER = (len(sys.argv) > 1 and sys.argv[1] == 'runserver')
API_CS_CREDENTIALS = {'user' : 'lalala', 'password' : 'lalala'}
API_CS_CREDENTIALS = {'user': 'kape', 'password': 'ppla1~2017'}
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