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