drf-react-by-schema 0.28.14 → 0.28.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ForgotPasswordForm.d.ts","sourceRoot":"","sources":["../../../src/components/forms/ForgotPasswordForm.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"ForgotPasswordForm.d.ts","sourceRoot":"","sources":["../../../src/components/forms/ForgotPasswordForm.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAYxC,MAAM,WAAW,uBAAuB;IACtC,6EAA6E;IAC7E,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,0DAA0D;IAC1D,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;IACvB,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;CACrB;AAED,MAAM,CAAC,OAAO,UAAU,kBAAkB,CAAC,EACzC,KAAK,EACL,GAAG,EACH,SAAS,EACT,MAAM,GACP,EAAE,uBAAuB,qBAkIzB"}
|
|
@@ -52,8 +52,10 @@ const TextField_1 = __importDefault(require("@mui/material/TextField"));
|
|
|
52
52
|
const Button_1 = __importDefault(require("@mui/material/Button"));
|
|
53
53
|
const Alert_1 = __importDefault(require("@mui/material/Alert"));
|
|
54
54
|
const styles_1 = require("@mui/material/styles");
|
|
55
|
+
const axios_1 = __importDefault(require("axios"));
|
|
55
56
|
const APIWrapperContext_1 = require("../../context/APIWrapperContext");
|
|
56
57
|
const texts_1 = require("../../styles/texts");
|
|
58
|
+
const utils_1 = require("../../utils");
|
|
57
59
|
function ForgotPasswordForm({ token, uid, onSuccess, onBack, }) {
|
|
58
60
|
const { requestPasswordReset, confirmPasswordReset } = (0, APIWrapperContext_1.useAPIWrapper)();
|
|
59
61
|
const texts = (0, texts_1.getThemeTexts)((0, styles_1.useTheme)()).auth;
|
|
@@ -61,6 +63,7 @@ function ForgotPasswordForm({ token, uid, onSuccess, onBack, }) {
|
|
|
61
63
|
const [email, setEmail] = (0, react_1.useState)('');
|
|
62
64
|
const [newPassword, setNewPassword] = (0, react_1.useState)('');
|
|
63
65
|
const [confirmPassword, setConfirmPassword] = (0, react_1.useState)('');
|
|
66
|
+
const [newPasswordError, setNewPasswordError] = (0, react_1.useState)('');
|
|
64
67
|
const [message, setMessage] = (0, react_1.useState)('');
|
|
65
68
|
const [error, setError] = (0, react_1.useState)('');
|
|
66
69
|
const [loading, setLoading] = (0, react_1.useState)(false);
|
|
@@ -78,9 +81,11 @@ function ForgotPasswordForm({ token, uid, onSuccess, onBack, }) {
|
|
|
78
81
|
setMessage(texts.forgotRequestSuccess);
|
|
79
82
|
});
|
|
80
83
|
const handleConfirm = (e) => __awaiter(this, void 0, void 0, function* () {
|
|
84
|
+
var _a;
|
|
81
85
|
e.preventDefault();
|
|
82
86
|
setError('');
|
|
83
87
|
setMessage('');
|
|
88
|
+
setNewPasswordError('');
|
|
84
89
|
if (newPassword !== confirmPassword) {
|
|
85
90
|
setError(texts.passwordsDoNotMatch);
|
|
86
91
|
return;
|
|
@@ -92,7 +97,14 @@ function ForgotPasswordForm({ token, uid, onSuccess, onBack, }) {
|
|
|
92
97
|
new_password: newPassword,
|
|
93
98
|
});
|
|
94
99
|
setLoading(false);
|
|
95
|
-
if (
|
|
100
|
+
if (axios_1.default.isAxiosError(result)) {
|
|
101
|
+
if ((_a = result.response) === null || _a === void 0 ? void 0 : _a.data) {
|
|
102
|
+
const fieldErrors = (0, utils_1.getFieldErrorsFromResponse)(result.response.data);
|
|
103
|
+
if (fieldErrors.new_password) {
|
|
104
|
+
setNewPasswordError(fieldErrors.new_password.message);
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
96
108
|
setError(texts.forgotConfirmError);
|
|
97
109
|
return;
|
|
98
110
|
}
|
|
@@ -103,7 +115,10 @@ function ForgotPasswordForm({ token, uid, onSuccess, onBack, }) {
|
|
|
103
115
|
error && (react_1.default.createElement(Alert_1.default, { severity: "error", sx: { mb: 2 } }, error)),
|
|
104
116
|
message && (react_1.default.createElement(Alert_1.default, { severity: "success", sx: { mb: 2 } }, message)),
|
|
105
117
|
!isConfirm ? (react_1.default.createElement(TextField_1.default, { fullWidth: true, margin: "normal", type: "email", label: texts.email, value: email, onChange: (e) => setEmail(e.target.value), autoComplete: "email", required: true })) : (react_1.default.createElement(react_1.default.Fragment, null,
|
|
106
|
-
react_1.default.createElement(TextField_1.default, { fullWidth: true, margin: "normal", type: "password", label: texts.newPassword, value: newPassword, onChange: (e) =>
|
|
118
|
+
react_1.default.createElement(TextField_1.default, { fullWidth: true, margin: "normal", type: "password", label: texts.newPassword, value: newPassword, onChange: (e) => {
|
|
119
|
+
setNewPassword(e.target.value);
|
|
120
|
+
setNewPasswordError('');
|
|
121
|
+
}, autoComplete: "new-password", required: true, error: Boolean(newPasswordError), helperText: newPasswordError || undefined }),
|
|
107
122
|
react_1.default.createElement(TextField_1.default, { fullWidth: true, margin: "normal", type: "password", label: texts.confirmPassword, value: confirmPassword, onChange: (e) => setConfirmPassword(e.target.value), autoComplete: "new-password", required: true }))),
|
|
108
123
|
react_1.default.createElement(Button_1.default, { type: "submit", variant: "contained", fullWidth: true, sx: { mt: 2 }, disabled: loading || (isConfirm ? !newPassword || !confirmPassword : !email) }, loading
|
|
109
124
|
? texts.saving
|
package/package.json
CHANGED