synapse-react-client
Version:
[](https://badge.fury.io/js/synapse-react-client) [](https://github.com/prettier/prettie
84 lines (83 loc) • 2.46 kB
JavaScript
import { jsxs as i, jsx as r } from "react/jsx-runtime";
import { validatePassword as y } from "../../utils/functions/StringUtils.js";
import { TextField as w, Button as T, Alert as b } from "@mui/material";
import { useState as a } from "react";
import { displayToast as l } from "../ToastMessage/ToastMessage.js";
import F from "./useChangePasswordFormState.js";
function q(u) {
const { passwordChangeToken: m, onSuccess: c } = u, [e, t] = a(""), [o, n] = a(""), [h, P] = a(
void 0
), {
promptForTwoFactorAuth: p,
TwoFactorAuthPrompt: f,
isPending: g,
handleChangePasswordWithResetToken: v,
error: d
} = F({
onChangePasswordSuccess: () => {
t(""), n(""), l("Password successfully changed.", "success"), c();
}
}), C = (s) => {
s.preventDefault(), e !== o ? l("Passwords do not match.", "danger") : v(e, m);
};
return /* @__PURE__ */ i("div", { children: [
p ? /* @__PURE__ */ r(f, {}) : /* @__PURE__ */ i(
"form",
{
onSubmit: (s) => {
C(s);
},
children: [
/* @__PURE__ */ r(
w,
{
fullWidth: !0,
required: !0,
helperText: h,
type: "password",
id: "newPassword",
name: "newPassword",
label: "New password",
onChange: (s) => {
const x = y(s.target.value);
P(x), t(s.target.value);
},
value: e || "",
sx: { mb: 2 }
}
),
/* @__PURE__ */ r(
w,
{
fullWidth: !0,
required: !0,
type: "password",
id: "confirmPassword",
name: "confirmPassword",
label: "Confirm password",
onChange: (s) => n(s.target.value),
value: o || "",
sx: { mb: 2 }
}
),
/* @__PURE__ */ r(
T,
{
variant: "contained",
type: "submit",
fullWidth: !0,
disabled: !e || !o || g,
sx: { mt: 3, py: 2 },
children: "Change Password"
}
)
]
}
),
d && /* @__PURE__ */ r(b, { severity: "error", sx: { my: 2 }, children: d.reason })
] });
}
export {
q as default
};
//# sourceMappingURL=ChangePasswordWithToken.js.map