Fakultas Ilmu Komputer UI

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

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 {
'Pastikan link github yang anda tulis benar.(Berpola : https://github.com/<username>',
);
} else {
this.submitForm();
}
};
submitForm = () => {
const submitForm = {};
Object.keys(this.state.form).forEach((key) => {
if (this.state.form[key] !== '') {
......@@ -37,8 +42,7 @@ export default class ProfileHandler extends React.Component {
this.modalAlert.open('Pembaharuan profil gagal', Dumper.dump(r));
}),
);
}
};
}
handleFile = (e) => {
const { form } = this.state;
......
......@@ -253,31 +253,7 @@ export default class ProfilePage extends ProfileHandler {
return;
}
{
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));
}),
);
this.submitForm();
}
};
......
This diff is collapsed.
Markdown is supported
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