chore: update function name

This commit is contained in:
Steven
2023-11-05 23:28:09 +08:00
parent e60e47f76f
commit 39a0e69b04
22 changed files with 42 additions and 51 deletions

View File

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