MCPcopy
hub / github.com/Peppermint-Lab/peppermint / updateUser

Function updateUser

apps/client/components/UpdateUserModal/index.tsx:15–44  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

13 const router = useRouter();
14
15 async function updateUser() {
16 await fetch(`/api/v1/auth/user/role`, {
17 method: "PUT",
18 headers: {
19 "Content-Type": "application/json",
20 Authorization: `Bearer ${getCookie("session")}`,
21 },
22 body: JSON.stringify({
23 role: admin,
24 id: user.id,
25 }),
26 })
27 .then((res) => res.json())
28 .then((res) => {
29 if (res.success === true) {
30 toast({
31 variant: "default",
32 title: "Success",
33 description: "User updated succesfully",
34 });
35 } else {
36 toast({
37 variant: "destructive",
38 title: "Error",
39 description: res.message,
40 });
41 }
42 });
43 // .then(() => router.reload());
44 }
45
46 return (
47 <div>

Callers 1

UpdateUserModalFunction · 0.85

Calls 1

toastFunction · 0.90

Tested by

no test coverage detected