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