Fixes by review

This commit is contained in:
ErickSkrauch
2020-08-04 13:48:16 +03:00
parent 00e74b1faf
commit 3b2fbb2cc4
4 changed files with 19 additions and 26 deletions

View File

@@ -9,10 +9,8 @@ import DeleteAccount from './DeleteAccount';
storiesOf('Components/Profile', module).add('DeleteAccount', () => (
<ProfileLayout>
<DeleteAccount
onSubmit={() => {
onSubmit={async () => {
action('onSubmit')();
return Promise.resolve();
}}
/>
</ProfileLayout>

View File

@@ -11,23 +11,18 @@ const DeleteAccountPage: ComponentType = () => {
const context = useContext(ProfileContext);
const dispatch = useReduxDispatch();
const { current: form } = useRef(new FormModel());
const onSubmit = useCallback(
() =>
context
.onSubmit({
form,
sendData: () => deleteAccount(context.userId, form.serialize()),
})
.then(() => {
dispatch(
updateUser({
isDeleted: true,
}),
);
context.goToProfile();
}),
[context],
);
const onSubmit = useCallback(async () => {
await context.onSubmit({
form,
sendData: () => deleteAccount(context.userId, form.serialize()),
});
dispatch(
updateUser({
isDeleted: true,
}),
);
context.goToProfile();
}, [context]);
return <DeleteAccount onSubmit={onSubmit} />;
};