Adds delete user functionality in admin panel #86 (#110)

* #86 Adds delete user functionality in admin panel

* Removes unnecessary code

* Prevents current user from deleting itself
This commit is contained in:
Pacodastre
2025-06-08 05:49:11 +01:00
committed by GitHub
parent e32954ea7d
commit 60abc03091
13 changed files with 214 additions and 8 deletions

24
composables/users.ts Normal file
View File

@ -0,0 +1,24 @@
import type { SerializeObject } from "nitropack";
import type { User, AuthMec } from "~/prisma/client";
export const useUsers = () =>
useState<
| Array<
SerializeObject<
User & {
authMecs?: Array<{ id: string; mec: AuthMec }>;
}
>
>
| undefined
>("users", () => undefined);
export const fetchUsers = async () => {
const users = useUsers();
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore forget why this ignor exists
const newValue: User[] = await $dropFetch("/api/v1/admin/users");
users.value = newValue;
return newValue;
};