Fakultas Ilmu Komputer UI

Commit 3b870580 authored by Tyagita Larasati's avatar Tyagita Larasati
Browse files

1606918616 208

parent e5e2e3fc
......@@ -11,10 +11,9 @@ import {
import Server from './lib/Server';
import Storage from './lib/Storage';
import ModalAlert from './components/ModalAlert';
import Dumper from './lib/Dumper';
import { isFromGithubLinkValid } from './Utils';
import ProfileHandler from './ProfileHandler';
export default class EditProfile extends React.Component {
export default class EditProfile extends ProfileHandler {
static propTypes = {
route: PropTypes.object.isRequired,
params: PropTypes.object.isRequired,
......@@ -157,72 +156,6 @@ export default class EditProfile extends React.Component {
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 (
......
import React from 'react';
import Server from './lib/Server';
import Dumper from './lib/Dumper';
import { isFromGithubLinkValid } from './Utils';
......
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