Fakultas Ilmu Komputer UI

Commit a7a83280 authored by PRIAMBUDI LINTANG BAGASKARA's avatar PRIAMBUDI LINTANG BAGASKARA 🎱
Browse files

Merge branch '1606895171-177' into 'master'

1606895171 177

See merge request !211
parent 8e51e362
import React from 'react'; import React from 'react';
import PropTypes from 'prop-types'; 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 { Doughnut } from 'react-chartjs-2';
import Server from './lib/Server'; import Server from './lib/Server';
import Dumper from './lib/Dumper'; import Dumper from './lib/Dumper';
...@@ -8,8 +10,6 @@ import ModalAlert from './components/ModalAlert'; ...@@ -8,8 +10,6 @@ import ModalAlert from './components/ModalAlert';
export default class CompanyProfile extends React.Component { export default class CompanyProfile extends React.Component {
static propTypes = { static propTypes = {
route: PropTypes.object.isRequired,
params: PropTypes.object.isRequired,
user: PropTypes.object.isRequired, user: PropTypes.object.isRequired,
}; };
...@@ -41,17 +41,6 @@ export default class CompanyProfile extends React.Component { ...@@ -41,17 +41,6 @@ export default class CompanyProfile extends React.Component {
this.handleChange = this.handleChange.bind(this); this.handleChange = this.handleChange.bind(this);
this.handleSubmit = this.handleSubmit.bind(this); this.handleSubmit = this.handleSubmit.bind(this);
Server.get(
`/companies/${this.props.user.data.company.id}/vacancies/`,
false,
).then((result) => {
this.setState({ vacancies: result.results });
},
(error) => error.then(() => {
console.log(error);
}),
);
Server.get( Server.get(
`/companies/${this.props.user.data.company.id}/applications/`, `/companies/${this.props.user.data.company.id}/applications/`,
false, false,
...@@ -60,8 +49,7 @@ export default class CompanyProfile extends React.Component { ...@@ -60,8 +49,7 @@ export default class CompanyProfile extends React.Component {
}, },
(error) => error.then(() => { (error) => error.then(() => {
console.log(error); console.log(error);
}), }));
);
} }
getProfile() { getProfile() {
......
...@@ -2,7 +2,6 @@ import React from 'react'; ...@@ -2,7 +2,6 @@ import React from 'react';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import { import {
Segment, Segment,
Image,
Header, Header,
Icon, Icon,
Checkbox, Checkbox,
...@@ -13,6 +12,7 @@ import Server from './lib/Server'; ...@@ -13,6 +12,7 @@ import Server from './lib/Server';
import Storage from './lib/Storage'; import Storage from './lib/Storage';
import ModalAlert from './components/ModalAlert'; import ModalAlert from './components/ModalAlert';
import Dumper from './lib/Dumper'; import Dumper from './lib/Dumper';
import { isFromGithubLinkValid } from './Utils';
export default class EditProfile extends React.Component { export default class EditProfile extends React.Component {
static propTypes = { static propTypes = {
...@@ -26,26 +26,14 @@ export default class EditProfile extends React.Component { ...@@ -26,26 +26,14 @@ export default class EditProfile extends React.Component {
/* istanbul ignore next */ /* istanbul ignore next */
this.state = { this.state = {
id: '', id: '',
npm: '',
name: '', name: '',
major: '',
batch: '',
email: '', email: '',
gender: '',
region: '', region: '',
alamat: '', alamat: '',
cityOfBirth: '',
dateOfBirth: '',
resume: '',
phone_number: '', phone_number: '',
portfolio_link: '', portfolio_link: '',
show_transcript: '', show_transcript: '',
photo: '',
age: '',
intro: '', intro: '',
expected_salary: '',
job_seeking_status: '',
volunteer: '',
skills: '', skills: '',
form: { form: {
picture: '', picture: '',
...@@ -71,14 +59,10 @@ export default class EditProfile extends React.Component { ...@@ -71,14 +59,10 @@ export default class EditProfile extends React.Component {
seminar: '', seminar: '',
interests: '', interests: '',
}, },
bagikanTranskrip: '',
acceptedNo: 0,
readNo: 0,
refresh: 1, refresh: 1,
loading: false, loading: false,
linkedin_url: '', linkedin_url: '',
hackerrank_url: '', hackerrank_url: '',
self_description: '',
student_gpa: 0.0, student_gpa: 0.0,
website_url: '', website_url: '',
latest_work: '', latest_work: '',
...@@ -97,9 +81,6 @@ export default class EditProfile extends React.Component { ...@@ -97,9 +81,6 @@ export default class EditProfile extends React.Component {
this.handleCheckbox = this.handleCheckbox.bind(this); this.handleCheckbox = this.handleCheckbox.bind(this);
this.handleSubmit = this.handleSubmit.bind(this); this.handleSubmit = this.handleSubmit.bind(this);
this.handleFile = this.handleFile.bind(this); this.handleFile = this.handleFile.bind(this);
this.gotoLink = this.gotoLink.bind(this);
this.gotoStudentResume = this.gotoStudentResume.bind(this);
this.gotoStudentTranscript = this.gotoStudentTranscript.bind(this);
this.getProfile(); this.getProfile();
} }
...@@ -112,32 +93,16 @@ export default class EditProfile extends React.Component { ...@@ -112,32 +93,16 @@ export default class EditProfile extends React.Component {
this.setState({ this.setState({
id: data.id, id: data.id,
name: data.full_name, name: data.full_name,
npm: data.npm,
resume: data.resume,
major: data.major,
batch: data.batch,
email: data.user.email, email: data.user.email,
gender: data.gender,
region: data.region, region: data.region,
alamat: data.alamat, alamat: data.alamat,
cityOfBirth: data.birth_place,
dateOfBirth: this.parseIndonesianDateFormat(data.birth_date),
phone_number: data.phone_number, phone_number: data.phone_number,
portfolio_link: data.portfolio_link, portfolio_link: data.portfolio_link,
photo: data.photo,
show_transcript: data.show_transcript, show_transcript: data.show_transcript,
acceptedNo: data.accepted_no,
readNo: data.read_no,
bagikanTranskrip: data.show_transcript,
refresh: this.state.refresh + 1, refresh: this.state.refresh + 1,
age: data.age,
intro: data.intro, intro: data.intro,
expected_salary: data.expected_salary,
job_seeking_status: data.job_seeking_status,
volunteer: data.volunteer,
linkedin_url: data.linkedin_url, linkedin_url: data.linkedin_url,
hackerrank_url: data.hackerrank_url, hackerrank_url: data.hackerrank_url,
self_description: data.self_description,
student_gpa: data.student_gpa, student_gpa: data.student_gpa,
website_url: data.website_url, website_url: data.website_url,
latest_work: data.latest_work, latest_work: data.latest_work,
...@@ -164,12 +129,6 @@ export default class EditProfile extends React.Component { ...@@ -164,12 +129,6 @@ export default class EditProfile extends React.Component {
); );
} }
isFromGithubLinkValid = () => {
const github_link = this.state.form.github_url;
if (github_link == null) return;
return github_link.includes('https://github.com/');
};
parseIndonesianDateFormat(dateIndex) { parseIndonesianDateFormat(dateIndex) {
const monthNameIndex = { const monthNameIndex = {
'01': 'Januari', '01': 'Januari',
...@@ -194,7 +153,7 @@ export default class EditProfile extends React.Component { ...@@ -194,7 +153,7 @@ export default class EditProfile extends React.Component {
handleSubmit = (e) => { handleSubmit = (e) => {
e.preventDefault(); e.preventDefault();
if (!this.isFromGithubLinkValid()) { if (!isFromGithubLinkValid(this.state.form.github_url)) {
this.modalAlert.open( this.modalAlert.open(
'Pembaharuan profil gagal', 'Pembaharuan profil gagal',
'Pastikan link github yang anda tulis benar.(Berpola : https://github.com/<username>', 'Pastikan link github yang anda tulis benar.(Berpola : https://github.com/<username>',
...@@ -258,15 +217,6 @@ export default class EditProfile extends React.Component { ...@@ -258,15 +217,6 @@ export default class EditProfile extends React.Component {
this.setState({ form }); this.setState({ form });
}; };
gotoLink = (url) => {
const win = window.open(url);
win.focus();
};
gotoStudentResume = () => this.gotoLink(this.state.resume || '#');
gotoStudentTranscript = () => this.gotoLink(`transkrip/${this.state.id}`);
updateForm(show) { updateForm(show) {
if (show) { if (show) {
return ( return (
......
...@@ -16,6 +16,7 @@ import Server from './lib/Server'; ...@@ -16,6 +16,7 @@ import Server from './lib/Server';
import Storage from './lib/Storage'; import Storage from './lib/Storage';
import ModalAlert from './components/ModalAlert'; import ModalAlert from './components/ModalAlert';
import Dumper from './lib/Dumper'; import Dumper from './lib/Dumper';
import { isFromGithubLinkValid, gotoLink } from './Utils';
export default class ProfilePage extends React.Component { export default class ProfilePage extends React.Component {
static propTypes = { static propTypes = {
...@@ -104,7 +105,6 @@ export default class ProfilePage extends React.Component { ...@@ -104,7 +105,6 @@ export default class ProfilePage extends React.Component {
this.handleCheckbox = this.handleCheckbox.bind(this); this.handleCheckbox = this.handleCheckbox.bind(this);
this.handleSubmit = this.handleSubmit.bind(this); this.handleSubmit = this.handleSubmit.bind(this);
this.handleFile = this.handleFile.bind(this); this.handleFile = this.handleFile.bind(this);
this.gotoLink = this.gotoLink.bind(this);
this.gotoStudentResume = this.gotoStudentResume.bind(this); this.gotoStudentResume = this.gotoStudentResume.bind(this);
this.gotoStudentTranscript = this.gotoStudentTranscript.bind(this); this.gotoStudentTranscript = this.gotoStudentTranscript.bind(this);
this.getProfile(); this.getProfile();
...@@ -179,12 +179,6 @@ export default class ProfilePage extends React.Component { ...@@ -179,12 +179,6 @@ export default class ProfilePage extends React.Component {
); );
} }
isFromGithubLinkValid = () => {
const github_link = this.state.form.github_url;
if (github_link == null) return;
return github_link.includes('https://github.com/');
};
gitlabURL_is_valid = () => { gitlabURL_is_valid = () => {
if (this.state.form.gitlab_url != null) { if (this.state.form.gitlab_url != null) {
return this.state.form.gitlab_url.includes('https://gitlab.com/'); return this.state.form.gitlab_url.includes('https://gitlab.com/');
...@@ -239,7 +233,7 @@ export default class ProfilePage extends React.Component { ...@@ -239,7 +233,7 @@ export default class ProfilePage extends React.Component {
handleSubmit = (e) => { handleSubmit = (e) => {
e.preventDefault(); e.preventDefault();
if (!this.isFromGithubLinkValid()) { if (!isFromGithubLinkValid(this.state.form.github_url)) {
this.modalAlert.open( this.modalAlert.open(
'Pembaharuan profil gagal', 'Pembaharuan profil gagal',
'Pastikan link github yang anda tulis benar.(Berpola : https://github.com/<username>', 'Pastikan link github yang anda tulis benar.(Berpola : https://github.com/<username>',
...@@ -309,14 +303,9 @@ export default class ProfilePage extends React.Component { ...@@ -309,14 +303,9 @@ export default class ProfilePage extends React.Component {
this.setState({ form }); this.setState({ form });
}; };
gotoLink = (url) => { gotoStudentResume = () => gotoLink(this.state.resume || '#');
const win = window.open(url);
win.focus();
};
gotoStudentResume = () => this.gotoLink(this.state.resume || '#');
gotoStudentTranscript = () => this.gotoLink(`transkrip/${this.state.id}`); gotoStudentTranscript = () => gotoLink(`transkrip/${this.state.id}`);
updateForm(show) { updateForm(show) {
if (show) { if (show) {
......
export const isFromGithubLinkValid = github_link => {
if (github_link == null) return;
return github_link.includes('https://github.com/');
};
export const gotoLink = url => window.open(url).focus();
import React from 'react'; import React from 'react';
import { import { ModalComponent } from './ModalComponent';
Button, Header, Icon, Modal,
} from 'semantic-ui-react';
export default class ModalAlert extends React.Component { export default class ModalAlert extends React.Component {
constructor(props) { constructor(props) {
...@@ -39,26 +37,23 @@ export default class ModalAlert extends React.Component { ...@@ -39,26 +37,23 @@ export default class ModalAlert extends React.Component {
}; };
close = () => { close = () => {
this.setState({ open: false }); this.setState({
open: false,
});
this.state.callback(); this.state.callback();
}; };
render = () => { render = () => {
const style = { whiteSpace: 'pre-wrap' }; const style = { whiteSpace: 'pre-wrap' };
return ( return (
<Modal open={this.state.open} basic size="small"> <ModalComponent
<Header icon="warning sign" content={this.state.header} /> open={this.state.open}
<Modal.Content> icon="warning sign"
<p style={style}>{this.state.content}</p> header={this.state.header}
</Modal.Content> style={style}
<Modal.Actions> content={this.state.content}
<Button color="green" inverted onClick={this.close}> onClick={this.close}
<Icon name="checkmark" /> />
{' '}
OK
</Button>
</Modal.Actions>
</Modal>
); );
}; };
} }
import React from 'react';
import {
Button, Header, Icon, Modal,
} from 'semantic-ui-react';
export const ModalComponent = (props) => (
<Modal open={props.open} basic size="small">
<Header icon={props.icon} content={props.header} />
<Modal.Content>
<p style={props.style}>{props.content}</p>
</Modal.Content>
<Modal.Actions>
<Button color="green" inverted onClick={props.onClick}>
<Icon name="checkmark" />
{' '}
OK
</Button>
</Modal.Actions>
</Modal>
);
import React from 'react'; import React from 'react';
import { import { ModalComponent } from './ModalComponent';
Button, Header, Icon, Modal,
} from 'semantic-ui-react';
export default class ModalSuccess extends React.Component { export default class ModalSuccess extends React.Component {
constructor(props) { constructor(props) {
...@@ -27,9 +25,16 @@ export default class ModalSuccess extends React.Component { ...@@ -27,9 +25,16 @@ export default class ModalSuccess extends React.Component {
if (anotherModal > 0) document.body.classList.add('scrolling', 'dimmable', 'dimmed'); if (anotherModal > 0) document.body.classList.add('scrolling', 'dimmable', 'dimmed');
}; };
open = (header = this.state.header, content = this.state.content, callback = this.state.callback) => { open = (
header = this.state.header,
content = this.state.content,
callback = this.state.callback,
) => {
this.setState({ this.setState({
open: true, header, content, callback, open: true,
header,
content,
callback,
}); });
}; };
...@@ -41,19 +46,14 @@ export default class ModalSuccess extends React.Component { ...@@ -41,19 +46,14 @@ export default class ModalSuccess extends React.Component {
render = () => { render = () => {
const style = { whiteSpace: 'pre-wrap' }; const style = { whiteSpace: 'pre-wrap' };
return ( return (
<Modal open={this.state.open} basic size="small"> <ModalComponent
<Header icon="checkmark sign" content={this.state.header} /> open={this.state.open}
<Modal.Content> icon="checkmark sign"
<p style={style}>{this.state.content}</p> header={this.state.header}
</Modal.Content> style={style}
<Modal.Actions> content={this.state.content}
<Button color="green" inverted onClick={this.close}> onClick={this.close}
<Icon name="checkmark" /> />
{' '}
OK
</Button>
</Modal.Actions>
</Modal>
); );
}; };
} }
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