From 30be711dd0903319731d22f65bc736f42b9f8a5d Mon Sep 17 00:00:00 2001 From: Timur Ercan Date: Wed, 25 Jan 2023 12:24:18 +0100 Subject: [PATCH] update user as feature --- packages/features/updateUser.ts | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 packages/features/updateUser.ts diff --git a/packages/features/updateUser.ts b/packages/features/updateUser.ts new file mode 100644 index 000000000..a09793363 --- /dev/null +++ b/packages/features/updateUser.ts @@ -0,0 +1,19 @@ +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 :/", + } + ); +};