minor fix

This commit is contained in:
Daniel 2023-07-19 11:30:11 -04:00
parent 742e17351e
commit 01a8579158
2 changed files with 14 additions and 13 deletions

View File

@ -1,7 +1,7 @@
import { Dispatch, SetStateAction, useEffect, useState } from "react"; import { Dispatch, SetStateAction, useEffect, useState } from "react";
import { AccountSettings } from "@/types/global"; import { AccountSettings } from "@/types/global";
import useAccountStore from "@/store/account"; import useAccountStore from "@/store/account";
import { useSession } from "next-auth/react"; import { signOut, useSession } from "next-auth/react";
import { faPenToSquare } from "@fortawesome/free-regular-svg-icons"; import { faPenToSquare } from "@fortawesome/free-regular-svg-icons";
import SubmitButton from "@/components/SubmitButton"; import SubmitButton from "@/components/SubmitButton";
import { toast } from "react-hot-toast"; import { toast } from "react-hot-toast";
@ -50,22 +50,24 @@ export default function ChangePassword({
if (response.ok) { if (response.ok) {
toast.success("Settings Applied!"); toast.success("Settings Applied!");
togglePasswordFormModal();
} else toast.error(response.data as string);
setSubmitLoader(false);
if ( if (
(user.username !== account.username || user.name !== account.name) && user.username !== account.username ||
user.username && user.name !== account.name ||
user.email user.email !== account.email
) ) {
update({ username: user.username, name: user.name }); update({
username: user.username,
email: user.username,
name: user.name,
});
signOut();
}
if (response.ok) {
setUser({ ...user, newPassword: undefined }); setUser({ ...user, newPassword: undefined });
togglePasswordFormModal(); togglePasswordFormModal();
} } else toast.error(response.data as string);
} else { } else {
toast.error("Passwords do not match."); toast.error("Passwords do not match.");
} }

View File

@ -77,7 +77,6 @@ export default function ProfileSettings({
if (response.ok) { if (response.ok) {
toast.success("Settings Applied!"); toast.success("Settings Applied!");
toggleSettingsModal();
if ( if (
user.username !== account.username || user.username !== account.username ||