changes and improvements

This commit is contained in:
daniel31x13
2024-08-14 15:22:28 -04:00
parent d15d965139
commit 9cc3a7206e
24 changed files with 292 additions and 203 deletions
+16
View File
@@ -80,6 +80,8 @@ export default function Account() {
const submit = async (password?: string) => {
setSubmitLoader(true);
const load = toast.loading(t("applying_settings"));
await updateUser.mutateAsync(
{
...user,
@@ -92,6 +94,20 @@ export default function Account() {
setEmailChangeVerificationModal(false);
}
},
onSettled: (data, error) => {
toast.dismiss(load);
if (error) {
toast.error(error.message);
} else {
if (data.response.email !== user.email) {
toast.success(t("email_change_request"));
setEmailChangeVerificationModal(false);
}
toast.success(t("settings_applied"));
}
},
}
);
+13 -3
View File
@@ -24,6 +24,8 @@ export default function Password() {
setSubmitLoader(true);
const load = toast.loading(t("applying_settings"));
await updateUser.mutateAsync(
{
...account,
@@ -31,9 +33,17 @@ export default function Password() {
oldPassword,
},
{
onSuccess: () => {
setNewPassword("");
setOldPassword("");
onSettled: (data, error) => {
toast.dismiss(load);
if (error) {
toast.error(error.message);
} else {
setNewPassword("");
setOldPassword("");
toast.success(t("settings_applied"));
}
},
}
);
+16 -1
View File
@@ -74,7 +74,22 @@ export default function Appearance() {
const submit = async () => {
setSubmitLoader(true);
await updateUser.mutateAsync({ ...user });
const load = toast.loading(t("applying_settings"));
await updateUser.mutateAsync(
{ ...user },
{
onSettled: (data, error) => {
toast.dismiss(load);
if (error) {
toast.error(error.message);
} else {
toast.success(t("settings_applied"));
}
},
}
);
setSubmitLoader(false);
};
+35 -8
View File
@@ -11,6 +11,7 @@ import getServerSideProps from "@/lib/client/getServerSideProps";
import LinkListOptions from "@/components/LinkListOptions";
import { useRemoveTag, useTags, useUpdateTag } from "@/hooks/store/tags";
import Links from "@/components/LinkViews/Links";
import toast from "react-hot-toast";
export default function Index() {
const { t } = useTranslation();
@@ -74,11 +75,27 @@ export default function Index() {
setSubmitLoader(true);
if (activeTag && newTagName)
await updateTag.mutateAsync({
...activeTag,
name: newTagName,
});
if (activeTag && newTagName) {
const load = toast.loading(t("applying_changes"));
await updateTag.mutateAsync(
{
...activeTag,
name: newTagName,
},
{
onSettled: (data, error) => {
toast.dismiss(load);
if (error) {
toast.error(error.message);
} else {
toast.success(t("tag_renamed"));
}
},
}
);
}
setSubmitLoader(false);
setRenameTag(false);
@@ -87,12 +104,22 @@ export default function Index() {
const remove = async () => {
setSubmitLoader(true);
if (activeTag?.id)
if (activeTag?.id) {
const load = toast.loading(t("applying_changes"));
await removeTag.mutateAsync(activeTag?.id, {
onSuccess: () => {
router.push("/links");
onSettled: (data, error) => {
toast.dismiss(load);
if (error) {
toast.error(error.message);
} else {
router.push("/links");
toast.success(t("tag_deleted"));
}
},
});
}
setSubmitLoader(false);
setRenameTag(false);