17 lines
458 B
TypeScript
17 lines
458 B
TypeScript
import { IEditUserForm } from "@/app/features/UserRoles/User.interfaces";
|
|
|
|
export async function editUser(id: string, data: IEditUserForm) {
|
|
const res = await fetch(`/api/dashboard/admin/users/${id}`, {
|
|
method: "PUT",
|
|
headers: { "Content-Type": "application/json" },
|
|
body: JSON.stringify(data),
|
|
});
|
|
|
|
if (!res.ok) {
|
|
console.log("[editUser] - FAILING", id, data);
|
|
throw new Error("Failed to update user");
|
|
}
|
|
|
|
return res.json();
|
|
}
|