Fakultas Ilmu Komputer UI

Commit 5c24e219 authored by Nixi Sendya Putri's avatar Nixi Sendya Putri
Browse files

1606918383 211

parent 300c2a9a
......@@ -11,9 +11,10 @@ import {
import Server from './lib/Server';
import Storage from './lib/Storage';
import ModalAlert from './components/ModalAlert';
import ProfileHandler from './ProfileHandler';
import Dumper from './lib/Dumper';
import { isFromGithubLinkValid } from './Utils';
export default class EditProfile extends ProfileHandler {
export default class EditProfile extends React.Component {
static propTypes = {
route: PropTypes.object.isRequired,
params: PropTypes.object.isRequired,
......@@ -156,6 +157,72 @@ export default class EditProfile extends ProfileHandler {
return dateIndexArray.reverse().join(' ');
}
handleSubmit = (e) => {
e.preventDefault();
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>',
);
} else {
const submitForm = {};
Object.keys(this.state.form).forEach((key) => {
if (this.state.form[key] !== '') {
submitForm[key] = this.state.form[key];
}
});
this.setState({ loading: true });
Server.submit(
`/students/${this.state.id}/profile/`,
submitForm,
'PATCH',
).then(
() => {
this.setState({ loading: false });
this.modalAlert.open(
'Profil berhasil diperbaharui',
'Silakan periksa kembali profil anda',
this.getProfile,
);
},
(error) => error.then((r) => {
this.setState({ loading: false });
this.modalAlert.open('Pembaharuan profil gagal', Dumper.dump(r));
}),
);
}
};
handleFile = (e) => {
const { form } = this.state;
form[e.target.name] = e.target.files[0];
this.setState({ form });
};
handleChange = (e) => {
const { form } = this.state;
form[e.target.name] = e.target.value;
this.setState({ form });
};
handleCheckbox = (e, d) => {
const { form } = this.state;
form[d.name] = d.checked;
this.setState({ form, show_transcript: d.checked });
};
handleRadioGender = (e, { value }) => {
const { form } = this.state;
form.gender = value;
this.setState({ form });
};
handleRadio = (e, { value }) => {
const { form } = this.state;
form.job_seeking_status = value;
this.setState({ form });
};
updateForm(show) {
if (show) {
return (
......
......@@ -5,7 +5,6 @@ import {
Image,
Header,
Icon,
Checkbox,
Container,
Button,
Form,
......
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