2021-05-25 14:48:16 +02:00
|
|
|
import React from 'react';
|
|
|
|
|
import { connect, ConnectedProps } from 'react-redux';
|
2022-04-22 14:33:13 +01:00
|
|
|
import { useMount } from 'react-use';
|
2021-05-25 14:48:16 +02:00
|
|
|
|
2022-07-06 17:00:56 +02:00
|
|
|
import { Page } from 'app/core/components/Page/Page';
|
2022-04-22 14:33:13 +01:00
|
|
|
import { StoreState } from 'app/types';
|
|
|
|
|
|
2019-07-03 11:02:12 -04:00
|
|
|
import { ChangePasswordForm } from './ChangePasswordForm';
|
2021-05-25 14:48:16 +02:00
|
|
|
import { changePassword, loadUser } from './state/actions';
|
2019-07-03 11:02:12 -04:00
|
|
|
|
2022-07-11 14:35:30 +02:00
|
|
|
export interface OwnProps {}
|
2019-07-03 11:02:12 -04:00
|
|
|
|
|
|
|
|
function mapStateToProps(state: StoreState) {
|
2021-05-25 14:48:16 +02:00
|
|
|
const userState = state.user;
|
|
|
|
|
const { isUpdating, user } = userState;
|
2019-07-03 11:02:12 -04:00
|
|
|
return {
|
2021-05-25 14:48:16 +02:00
|
|
|
isUpdating,
|
|
|
|
|
user,
|
2019-07-03 11:02:12 -04:00
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2021-05-25 14:48:16 +02:00
|
|
|
const mapDispatchToProps = {
|
|
|
|
|
loadUser,
|
|
|
|
|
changePassword,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const connector = connect(mapStateToProps, mapDispatchToProps);
|
|
|
|
|
|
2021-07-01 19:31:09 +05:30
|
|
|
export type Props = OwnProps & ConnectedProps<typeof connector>;
|
2021-05-25 14:48:16 +02:00
|
|
|
|
2022-07-11 14:35:30 +02:00
|
|
|
export function ChangePasswordPage({ loadUser, isUpdating, user, changePassword }: Props) {
|
2021-05-25 14:48:16 +02:00
|
|
|
useMount(() => loadUser());
|
|
|
|
|
|
|
|
|
|
return (
|
2022-07-11 14:35:30 +02:00
|
|
|
<Page navId="profile/password">
|
2021-05-25 14:48:16 +02:00
|
|
|
<Page.Contents isLoading={!Boolean(user)}>
|
|
|
|
|
{user ? (
|
|
|
|
|
<>
|
2022-07-20 16:02:25 +02:00
|
|
|
<Page.OldNavOnly>
|
|
|
|
|
<h3 className="page-sub-heading">Change Your Password</h3>
|
|
|
|
|
</Page.OldNavOnly>
|
2021-05-25 14:48:16 +02:00
|
|
|
<ChangePasswordForm user={user} onChangePassword={changePassword} isSaving={isUpdating} />
|
|
|
|
|
</>
|
|
|
|
|
) : null}
|
|
|
|
|
</Page.Contents>
|
|
|
|
|
</Page>
|
|
|
|
|
);
|
|
|
|
|
}
|
2019-07-03 11:02:12 -04:00
|
|
|
|
2021-08-31 12:55:05 +02:00
|
|
|
export default connector(ChangePasswordPage);
|