diff --git a/app/components/ForceGraph.tsx b/app/components/ForceGraph.tsx index 26906e75..3a902e23 100644 --- a/app/components/ForceGraph.tsx +++ b/app/components/ForceGraph.tsx @@ -85,7 +85,7 @@ export default function ForceGraph({ if (result.ok) { const json = await result.json() const elements = graph.extend(json.result, true) - if (elements.length > 0) { + if (elements.length === 0) { toast({ title: `No neighbors found`, description: `No neighbors found`, diff --git a/app/settings/users/Users.tsx b/app/settings/users/Users.tsx index 2716b530..0d651c28 100644 --- a/app/settings/users/Users.tsx +++ b/app/settings/users/Users.tsx @@ -27,7 +27,7 @@ export default function Users() { const { data: session } = useSession() const handleSetRole = async (username: string, role: string, oldRole?: string) => { - const result = await securedFetch(`api/user/${prepareArg(username)}/?role=${role}`, { + const result = await securedFetch(`api/user/${prepareArg(username)}`, { method: 'PATCH' }, session?.user?.role, toast) diff --git a/lib/utils.ts b/lib/utils.ts index 9bf38d83..b19e03e3 100644 --- a/lib/utils.ts +++ b/lib/utils.ts @@ -18,7 +18,7 @@ export async function securedFetch( toast?: any, ): Promise { - const response = await fetch(`${url}${url.includes("?") ? "&" : "?"}role=${role}`, init) + const response = await fetch(`${url}${role && (url.includes("?") ? "&" : "?")}role=${role}`, init) const { status } = response if (status >= 300) { const err = await response.text()