From be1b5996bfe4aa650d1d01aa3d9e88a494233613 Mon Sep 17 00:00:00 2001
From: "alsabila.shakina" <alsabila.shakina@ui.ac.id>
Date: Sun, 1 Dec 2019 18:56:55 +0700
Subject: [PATCH 1/4] Menghilangkan console.log

---
 assets/js/CompanyProfile.jsx | 15 +--------------
 1 file changed, 1 insertion(+), 14 deletions(-)

diff --git a/assets/js/CompanyProfile.jsx b/assets/js/CompanyProfile.jsx
index 794c6b96..9e5d27d9 100755
--- a/assets/js/CompanyProfile.jsx
+++ b/assets/js/CompanyProfile.jsx
@@ -1,15 +1,6 @@
 import React from 'react';
 import PropTypes from 'prop-types';
-import {
-  Segment,
-  Header,
-  Image,
-  Container,
-  Form,
-  Button,
-  Icon,
-  TextArea,
-} from 'semantic-ui-react';
+import { Segment, Header, Image, Container, Form, Button, Icon, TextArea } from 'semantic-ui-react';
 import { Doughnut } from 'react-chartjs-2';
 import TopMenu from './components/TopMenu';
 import Server from './lib/Server';
@@ -26,8 +17,6 @@ export default class CompanyProfile extends React.Component {
   constructor(props) {
     super(props);
     const data = TopMenu.getInfo(this.props.user);
-    console.log('ASdasdadasda');
-    console.log(data);
     this.state = {
       id: this.props.user.data.company.id,
       name: data.name,
@@ -57,7 +46,6 @@ export default class CompanyProfile extends React.Component {
       `/companies/${this.state.id}/`,
     ).then(
       (result) => {
-        console.log('ASDADS');
         this.setState({ linkedin_url: result.linkedin_url });
       },
     );
@@ -78,7 +66,6 @@ export default class CompanyProfile extends React.Component {
   getProfile() {
     return Server.get(`/companies/${this.state.id}/`).then(
       (result) => {
-        console.log(result);
         this.setState({
           name: result.name,
           address: result.address,
-- 
GitLab


From 1bd4b76a78423699f0733b59ecbcdd87f3675922 Mon Sep 17 00:00:00 2001
From: "alsabila.shakina" <alsabila.shakina@ui.ac.id>
Date: Sun, 1 Dec 2019 18:57:31 +0700
Subject: [PATCH 2/4] Menggunakan companySession dari Response.jsx untuk
 mencegah duplicate

---
 assets/js/__test__/CompanyProfile-test.jsx | 74 +++++++---------------
 1 file changed, 24 insertions(+), 50 deletions(-)

diff --git a/assets/js/__test__/CompanyProfile-test.jsx b/assets/js/__test__/CompanyProfile-test.jsx
index c065dc41..368018bb 100755
--- a/assets/js/__test__/CompanyProfile-test.jsx
+++ b/assets/js/__test__/CompanyProfile-test.jsx
@@ -1,74 +1,48 @@
 import React from 'react';
 import ReactTestUtils from 'react-dom/test-utils';
 import CompanyProfile from '../CompanyProfile';
-
-const companyUserVerified = {
-  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',
-      category: 'Belum ada kategori perusahaan',
-      website: 'Belum ada link website',
-      size: 'Jumlah karyawan belum dimasukan',
-      linkedin_url: 'Belum ada LinkedIn URL',
-    },
-    supervisor: null,
-    student: null,
-  },
-};
+import { companySession } from '../object/Response';
 
 describe('CompanyProfile', () => {
   it('renders without problem', () => {
     const companyProfile = ReactTestUtils.renderIntoDocument(
-      <CompanyProfile user={companyUserVerified} />);
+      <CompanyProfile
+        route={{ own: true, data: companySession }}
+        user={{ data: companySession }} params={{}}
+      />);
     expect(companyProfile).to.exist;
   });
 
   it('renders Doughnut chart without problem', () => {
     const companyProfile = ReactTestUtils.renderIntoDocument(
-      <CompanyProfile user={companyUserVerified} />);
+      <CompanyProfile
+        route={{ own: true, data: companySession }}
+        user={{ data: companySession }} params={{}}
+      />);
     const chart = ReactTestUtils.scryRenderedDOMComponentsWithTag(companyProfile, 'Doughnut');
     expect(chart).to.exist;
   });
 
   it('get company\'s profile without problem', () => {
     const profile = ReactTestUtils.renderIntoDocument(
-      <CompanyProfile user={companyUserVerified} />);
-    expect(profile.state.id).to.equal(companyUserVerified.data.company.id);
-    profile.getProfile().then(()=> {
-      expect(profile.state.name).to.equal(companyUserVerified.data.company.name);
-      expect(profile.state.address).to.equal(companyUserVerified.data.company.address);
-      expect(profile.state.category).to.equal(companyUserVerified.data.company.category);
-      expect(profile.state.description).to.equal(companyUserVerified.data.company.description);
-      expect(profile.state.size).to.equal(companyUserVerified.data.company.size);
-      expect(profile.state.website).to.equal(companyUserVerified.data.company.website);
-      expect(profile.state.logo).to.equal(companyUserVerified.data.company.logo);
-      expect(profile.state.linkedin_url).to.equal(companyUserVerified.data.company.linkedin_url);
-    });
+      <CompanyProfile
+        route={{ own: true, data: companySession }}
+        user={{ data: companySession }} params={{}}
+      />)
+      profile.getProfile().then(() => {
+        expect(profile.state.id).to.equal(companySession.company.id);
+      });
   });
 
-  it('submit edit form of verified company without problem', () => {
+  it('submit edit form of verified company', () => {
     const profile = ReactTestUtils.renderIntoDocument(
-      <CompanyProfile user={companyUserVerified} />);
-    profile.state.form = {name:'Restopedia', address:'Bulan', description:'Martabak Tilaar', website:'www.uenak.com', linkedin_url:'https://www.linkedin.com/in/bob/',  size:'1000'};
-    const submitButton = ReactTestUtils.scryRenderedDOMComponentsWithTag(profile, 'Input')[1];
+      <CompanyProfile
+        route={{ own: false, data: companySession }}
+        user={{ data: companySession }} params={{}}
+      />);
+    profile.state.form = {name:'Restopedia', address:'Bulan', description:'Martabak Tilaar', 
+    website:'www.uenak.com', linkedin_url:'https://www.linkedin.com/in/bob/',  size:'1000'};
+    const submitButton = ReactTestUtils.scryRenderedDOMComponentsWithTag(profile, 'Button')[0];
     ReactTestUtils.Simulate.click(submitButton);
 
     const form = ReactTestUtils.findRenderedDOMComponentWithTag(profile, 'Form');
-- 
GitLab


From d034aee412412988feb366b1c822b90d6d7a4731 Mon Sep 17 00:00:00 2001
From: "alsabila.shakina" <alsabila.shakina@ui.ac.id>
Date: Sun, 1 Dec 2019 19:07:57 +0700
Subject: [PATCH 3/4] Menghapus Server.get yang tidak perlu karena sudah
 di-cover di getProfile()

---
 assets/js/CompanyProfile.jsx | 7 -------
 1 file changed, 7 deletions(-)

diff --git a/assets/js/CompanyProfile.jsx b/assets/js/CompanyProfile.jsx
index 9e5d27d9..c6e92ff2 100755
--- a/assets/js/CompanyProfile.jsx
+++ b/assets/js/CompanyProfile.jsx
@@ -42,13 +42,6 @@ export default class CompanyProfile extends React.Component {
     this.getProfile = this.getProfile.bind(this);
     this.handleChange = this.handleChange.bind(this);
     this.handleSubmit = this.handleSubmit.bind(this);
-    Server.get(
-      `/companies/${this.state.id}/`,
-    ).then(
-      (result) => {
-        this.setState({ linkedin_url: result.linkedin_url });
-      },
-    );
     Server.get(
       `/companies/${this.props.user.data.company.id}/vacancies/`,
       false,
-- 
GitLab


From f08d6f89494c2db15bdb4036a2a6e0b4c03136e0 Mon Sep 17 00:00:00 2001
From: "alsabila.shakina" <alsabila.shakina@ui.ac.id>
Date: Sun, 1 Dec 2019 21:01:38 +0700
Subject: [PATCH 4/4] Mengurangi duplicate code di InfoLowonganModal

---
 assets/js/components/InfoLowonganModal.jsx | 55 +---------------------
 1 file changed, 2 insertions(+), 53 deletions(-)

diff --git a/assets/js/components/InfoLowonganModal.jsx b/assets/js/components/InfoLowonganModal.jsx
index 20dcc797..b765c5f0 100644
--- a/assets/js/components/InfoLowonganModal.jsx
+++ b/assets/js/components/InfoLowonganModal.jsx
@@ -2,60 +2,9 @@ import React from 'react';
 import PropTypes from 'prop-types';
 import { Modal, Button } from 'semantic-ui-react';
 import ModalAlert from './ModalAlert';
+import GeneralModal from './GeneralModal';
 
-export default class InfoLowonganModal extends React.Component {
-  static propTypes = {
-    data: PropTypes.object.isRequired,
-    active: PropTypes.bool.isRequired,
-    buttonTitle: PropTypes.string.isRequired,
-    resume: PropTypes.string,
-    studentId: PropTypes.number.isRequired,
-    updateStatus: PropTypes.func.isRequired,
-  };
-
-  constructor(props) {
-    super(props);
-    /* istanbul ignore next */
-    this.state = {
-      modalOpen: false,
-      coverLetter: '',
-      load: false,
-    };
-    this.handleChange = this.handleChange.bind(this);
-    this.handleOpen = this.handleOpen.bind(this);
-    this.handleApply = this.handleApply.bind(this);
-  }
-
-  componentWillUpdate() {
-    this.fixBody();
-  }
-
-  componentDidUpdate() {
-    this.fixBody();
-  }
-
-  fixBody = () => {
-    const anotherModal = document.getElementsByClassName('ui page modals')
-      .length;
-    if (anotherModal > 0) document.body.classList.add('scrolling', 'dimmable', 'dimmed');
-  };
-
-  handleChange(event) {
-    this.setState({ coverLetter: event.target.value });
-  }
-
-  handleOpen() {
-    this.setState({ modalOpen: true });
-  }
-
-  handleClose = () => this.setState({
-    modalOpen: false,
-    load: false,
-  });
-
-  handleApply = () => {
-    this.setState({ load: true });
-  };
+export default class InfoLowonganModal extends GeneralModal {
 
   render() {
     return (
-- 
GitLab