2020-07-27 12:58:37 +05:30
|
|
|
import React, { ComponentType, useCallback, useContext } from 'react';
|
|
|
|
|
|
|
|
import { useReduxDispatch } from 'app/functions';
|
|
|
|
import { restoreAccount } from 'app/services/api/accounts';
|
|
|
|
import { updateUser } from 'app/components/user/actions';
|
2020-10-27 04:16:57 +05:30
|
|
|
import { markAsDeleted } from 'app/components/accounts/actions/pure-actions';
|
2020-07-27 12:58:37 +05:30
|
|
|
import ProfileContext from 'app/components/profile/Context';
|
|
|
|
|
|
|
|
import AccountDeleted from 'app/components/profile/AccountDeleted';
|
|
|
|
|
|
|
|
const AccountDeletedPage: ComponentType = () => {
|
|
|
|
const dispatch = useReduxDispatch();
|
|
|
|
const context = useContext(ProfileContext);
|
|
|
|
const onRestore = useCallback(async () => {
|
|
|
|
await restoreAccount(context.userId);
|
|
|
|
dispatch(
|
|
|
|
updateUser({
|
|
|
|
isDeleted: false,
|
|
|
|
}),
|
|
|
|
);
|
2020-10-27 04:16:57 +05:30
|
|
|
dispatch(markAsDeleted(false));
|
2020-07-27 12:58:37 +05:30
|
|
|
context.goToProfile();
|
|
|
|
}, [dispatch, context]);
|
|
|
|
|
|
|
|
return <AccountDeleted onRestore={onRestore} />;
|
|
|
|
};
|
|
|
|
|
|
|
|
export default AccountDeletedPage;
|