Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

chore: handle res not ok (#953)

Ameer Al Ashhab12a6e25e9652
diff --git a/apps/web/app/(org)/dashboard/settings/account/Settings.tsx b/apps/web/app/(org)/dashboard/settings/account/Settings.tsx
index 0aff8d02c..e97793dfe 100644
--- a/apps/web/app/(org)/dashboard/settings/account/Settings.tsx
+++ b/apps/web/app/(org)/dashboard/settings/account/Settings.tsx
@@ -18,13 +18,17 @@ export const Settings = ({
const { mutate: updateName, isPending: updateNamePending } = useMutation({
mutationFn: async () => {
- await fetch("/api/settings/user/name", {
+ const res = await fetch("/api/settings/user/name", {
method: "POST",
- headers: {
- "Content-Type": "application/json",
- },
- body: JSON.stringify({ firstName, lastName }),
+ headers: { "Content-Type": "application/json" },
+ body: JSON.stringify({
+ firstName: firstName.trim(),
+ lastName: lastName.trim() ? lastName.trim() : null,
+ }),
});
+ if (!res.ok) {
+ throw new Error("Failed to update name");
+ }
},
onSuccess: () => {
toast.success("Name updated successfully");