Added sagas + pages for password reset. WIP BOD-165
This commit is contained in:
@@ -0,0 +1,85 @@
|
||||
import { LockOutlined } from "@ant-design/icons";
|
||||
import { Button, Form, Input } from "antd";
|
||||
import React from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { connect } from "react-redux";
|
||||
import { createStructuredSelector } from "reselect";
|
||||
import { validatePasswordResetStart } from "../../redux/user/user.actions";
|
||||
import { selectPasswordReset } from "../../redux/user/user.selectors";
|
||||
import AlertComponent from "../alert/alert.component";
|
||||
|
||||
const mapStateToProps = createStructuredSelector({
|
||||
passwordReset: selectPasswordReset,
|
||||
});
|
||||
const mapDispatchToProps = (dispatch) => ({
|
||||
validatePasswordReset: (emailAndPin) =>
|
||||
dispatch(validatePasswordResetStart(emailAndPin)),
|
||||
});
|
||||
|
||||
export function UserValidatePwReset({
|
||||
passwordReset,
|
||||
validatePasswordReset,
|
||||
oobCode,
|
||||
}) {
|
||||
console.log("UserValidatePwReset -> oobCode", oobCode);
|
||||
const { t } = useTranslation();
|
||||
|
||||
const handleFinish = (values) => {
|
||||
validatePasswordReset({ code: oobCode, password: values.password });
|
||||
};
|
||||
|
||||
return (
|
||||
<div>
|
||||
<Form onFinish={handleFinish}>
|
||||
<Form.Item
|
||||
label={t("general.labels.password")}
|
||||
name='password'
|
||||
rules={[
|
||||
{
|
||||
required: true,
|
||||
message: t("general.validation.required"),
|
||||
},
|
||||
]}>
|
||||
<Input
|
||||
prefix={<LockOutlined />}
|
||||
type='password'
|
||||
placeholder={t("general.labels.password")}
|
||||
/>
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
label={t("general.labels.confirmpassword")}
|
||||
name='password-confirm'
|
||||
dependencies={["password"]}
|
||||
rules={[
|
||||
{
|
||||
required: true,
|
||||
message: t("general.validation.required"),
|
||||
},
|
||||
({ getFieldValue }) => ({
|
||||
validator(rule, value) {
|
||||
if (!value || getFieldValue("password") === value) {
|
||||
return Promise.resolve();
|
||||
}
|
||||
return Promise.reject(t("general.labels.passwordsdonotmatch"));
|
||||
},
|
||||
}),
|
||||
]}>
|
||||
<Input
|
||||
prefix={<LockOutlined />}
|
||||
type='password'
|
||||
placeholder={t("general.labels.password")}
|
||||
/>
|
||||
</Form.Item>
|
||||
{passwordReset.error ? (
|
||||
<AlertComponent message={passwordReset.error} type='warning' />
|
||||
) : null}
|
||||
<Button htmlType='submit'>{t("general.actions.submit")}</Button>
|
||||
</Form>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default connect(
|
||||
mapStateToProps,
|
||||
mapDispatchToProps
|
||||
)(UserValidatePwReset);
|
||||
Reference in New Issue
Block a user