Fakultas Ilmu Komputer UI

Commit 94cba547 authored by Yusuf Sholeh's avatar Yusuf Sholeh
Browse files

Merge branch '1606862791-246' into 'master'

refactor: remove duplicate lines

See merge request !295
parents 00c4403a 408ab7ea
Pipeline #27211 failed with stages
in 6 minutes and 21 seconds
...@@ -12,6 +12,11 @@ export default class ProfileHandler extends React.Component { ...@@ -12,6 +12,11 @@ export default class ProfileHandler extends React.Component {
'Pastikan link github yang anda tulis benar.(Berpola : https://github.com/<username>', 'Pastikan link github yang anda tulis benar.(Berpola : https://github.com/<username>',
); );
} else { } else {
this.submitForm();
}
};
submitForm = () => {
const submitForm = {}; const submitForm = {};
Object.keys(this.state.form).forEach((key) => { Object.keys(this.state.form).forEach((key) => {
if (this.state.form[key] !== '') { if (this.state.form[key] !== '') {
...@@ -38,7 +43,6 @@ export default class ProfileHandler extends React.Component { ...@@ -38,7 +43,6 @@ export default class ProfileHandler extends React.Component {
}), }),
); );
} }
};
handleFile = (e) => { handleFile = (e) => {
const { form } = this.state; const { form } = this.state;
......
...@@ -253,31 +253,7 @@ export default class ProfilePage extends ProfileHandler { ...@@ -253,31 +253,7 @@ export default class ProfilePage extends ProfileHandler {
return; return;
} }
{ {
const submitForm = {}; this.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));
}),
);
} }
}; };
......
This diff is collapsed.
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