Fakultas Ilmu Komputer UI

Commit 2cb50372 authored by IVANA IRENE THOMAS's avatar IVANA IRENE THOMAS
Browse files

Merge branch '1606887352-194' into 'master'

#194 Refactor duplicate form handling pada CreateVacancy.jsx, increase code coverage pada CreateVacancy.jsx

See merge request !225
parents 49d4cc0d b89c5938
Pipeline #26605 passed with stages
in 16 minutes and 28 seconds
......@@ -13,14 +13,10 @@ export default class CreateVacancy extends React.Component {
super(props);
/* istanbul ignore next */
this.handleChange = this.handleChange.bind(this);
this.handleEditorChange = this.handleEditorChange.bind(this);
this.handleSubmit = this.handleSubmit.bind(this);
this.handleDescription = this.handleDescription.bind(this);
this.handleRequirements = this.handleRequirements.bind(this);
this.handleResponsibilities = this.handleResponsibilities.bind(this);
this.setCloseTime = this.setCloseTime.bind(this);
this.setOpenTime = this.setOpenTime.bind(this);
this.handleDescription = this.handleDescription.bind(this);
this.handleBenefits = this.handleBenefits.bind(this);
this.state = {
formLoading: false,
......@@ -70,6 +66,10 @@ export default class CreateVacancy extends React.Component {
this.setState({ [e.target.name]: e.target.value });
};
handleEditorChange = (field, val) => {
this.setState({[field]: val});
}
handleSubmit = (e) => {
const {
name,
......@@ -120,22 +120,6 @@ export default class CreateVacancy extends React.Component {
);
};
handleResponsibilities(value) {
this.setState({ responsibilities: value });
}
handleRequirements(value) {
this.setState({ requirements: value });
}
handleBenefits(value) {
this.setState({ benefits: value });
}
handleDescription(value) {
this.setState({ description: value });
}
render = () => {
const {
name,
......@@ -178,7 +162,7 @@ export default class CreateVacancy extends React.Component {
<b> Deskripsi Lowongan </b>{' '}
</label>
{!loading && (
<CKEditor value={description} onChange={this.handleDescription} />
<CKEditor value={description} onChange={(val) => this.handleEditorChange("description", val)} />
)}
<script>CKEDITOR.replace( &lsquo;description&rsquo; );</script>
<Form.Field
......@@ -195,7 +179,7 @@ export default class CreateVacancy extends React.Component {
{!loading && (
<CKEditor
value={responsibilities}
onChange={this.handleResponsibilities}
onChange={(val) => this.handleEditorChange("responsibilities", val)}
/>
)}
<script>CKEDITOR.replace( &lsquo;responsibilities&rsquo; );</script>
......@@ -215,7 +199,7 @@ export default class CreateVacancy extends React.Component {
<b> Keuntungan </b>{' '}
</label>
{!loading && (
<CKEditor value={benefits} onChange={this.handleBenefits} />
<CKEditor value={benefits} onChange={(val) => this.handleEditorChange("benefits", val)} />
)}
<script>CKEDITOR.replace( &lsquo;benefits&rsquo; );</script>
<br />
......@@ -226,7 +210,7 @@ export default class CreateVacancy extends React.Component {
{!loading && (
<CKEditor
value={requirements}
onChange={this.handleRequirements}
onChange={(val) => this.handleEditorChange("requirements", val)}
/>
)}
<script>CKEDITOR.replace( &lsquo;requirements&rsquo; );</script>
......
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