mirror of
https://github.com/elyby/accounts-frontend.git
synced 2025-05-31 14:11:58 +05:30
Fixes by review
This commit is contained in:
@@ -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>
|
||||
|
||||
@@ -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} />;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user