saving ux minus refactor

This commit is contained in:
Timur Ercan
2023-01-25 13:22:47 +01:00
parent 8f4b733eda
commit 0f9df1afc9
4 changed files with 104 additions and 22 deletions

View File

@ -2,18 +2,22 @@ import toast from "react-hot-toast";
export const updateUser = async (user: any) => {
if (!user) return;
toast.promise(
fetch("/api/users", {
method: "PATCH",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify(user),
}),
{
loading: "Saving Changes...",
success: `Saved!`,
error: "Changes could not save user :/",
}
);
toast
.promise(
fetch("/api/users", {
method: "PATCH",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify(user),
}),
{
loading: "Saving Changes...",
success: `Saved!`,
error: "Changes could not save user :/",
}
)
.then(() => {
// location.reload();
});
};