|
|
@ -1,6 +1,6 @@
|
|
|
|
import { useEffect, useState } from "react";
|
|
|
|
import { useEffect, useState } from "react";
|
|
|
|
import { toast } from "react-hot-toast";
|
|
|
|
import { toast } from "react-hot-toast";
|
|
|
|
import { useUserStore } from "@/store/module";
|
|
|
|
import { useUserV1Store, UserNamePrefix } from "@/store/v1";
|
|
|
|
import { useTranslate } from "@/utils/i18n";
|
|
|
|
import { useTranslate } from "@/utils/i18n";
|
|
|
|
import { generateDialog } from "./Dialog";
|
|
|
|
import { generateDialog } from "./Dialog";
|
|
|
|
import Icon from "./Icon";
|
|
|
|
import Icon from "./Icon";
|
|
|
@ -10,9 +10,9 @@ interface Props extends DialogProps {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const ChangeMemberPasswordDialog: React.FC<Props> = (props: Props) => {
|
|
|
|
const ChangeMemberPasswordDialog: React.FC<Props> = (props: Props) => {
|
|
|
|
const { user: propsUser, destroy } = props;
|
|
|
|
const { user, destroy } = props;
|
|
|
|
const t = useTranslate();
|
|
|
|
const t = useTranslate();
|
|
|
|
const userStore = useUserStore();
|
|
|
|
const userStore = useUserV1Store();
|
|
|
|
const [newPassword, setNewPassword] = useState("");
|
|
|
|
const [newPassword, setNewPassword] = useState("");
|
|
|
|
const [newPasswordAgain, setNewPasswordAgain] = useState("");
|
|
|
|
const [newPasswordAgain, setNewPasswordAgain] = useState("");
|
|
|
|
|
|
|
|
|
|
|
@ -47,10 +47,13 @@ const ChangeMemberPasswordDialog: React.FC<Props> = (props: Props) => {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
await userStore.patchUser({
|
|
|
|
await userStore.updateUser(
|
|
|
|
id: propsUser.id,
|
|
|
|
{
|
|
|
|
password: newPassword,
|
|
|
|
name: `${UserNamePrefix}${user.username}`,
|
|
|
|
});
|
|
|
|
password: newPassword,
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
["password"]
|
|
|
|
|
|
|
|
);
|
|
|
|
toast(t("message.password-changed"));
|
|
|
|
toast(t("message.password-changed"));
|
|
|
|
handleCloseBtnClick();
|
|
|
|
handleCloseBtnClick();
|
|
|
|
} catch (error: any) {
|
|
|
|
} catch (error: any) {
|
|
|
@ -63,7 +66,7 @@ const ChangeMemberPasswordDialog: React.FC<Props> = (props: Props) => {
|
|
|
|
<>
|
|
|
|
<>
|
|
|
|
<div className="dialog-header-container !w-64">
|
|
|
|
<div className="dialog-header-container !w-64">
|
|
|
|
<p className="title-text">
|
|
|
|
<p className="title-text">
|
|
|
|
{t("setting.account-section.change-password")} ({propsUser.username})
|
|
|
|
{t("setting.account-section.change-password")} ({user.username})
|
|
|
|
</p>
|
|
|
|
</p>
|
|
|
|
<button className="btn close-btn" onClick={handleCloseBtnClick}>
|
|
|
|
<button className="btn close-btn" onClick={handleCloseBtnClick}>
|
|
|
|
<Icon.X />
|
|
|
|
<Icon.X />
|
|
|
|