Fakultas Ilmu Komputer UI

Commit f0f6c9da authored by Zamil Majdy's avatar Zamil Majdy
Browse files

[#144502159] [#35] [Refactor] Fix lamaran dibaca bug

parent 0a070be0
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