users page and a function to populate table headers

This commit is contained in:
2025-01-16 16:06:34 -05:00
parent 4ca7c393ef
commit 9580f78ef5
9 changed files with 319 additions and 14 deletions

View File

@@ -5,7 +5,7 @@ import { db } from "@db/index";
import { users } from "@schemas/schema";
export const getData = async () => {
const data = await db.select().from(users).orderBy(asc(users.email));
const data = await db.select().from(users).orderBy(asc(users.last_name));
return data;
};
@@ -16,7 +16,7 @@ export const getUserByEmail = async (email:string) => {
export const addUser = async ( first_name: string, last_name: string, username: string, email: string, password_hash : string) => {
await db.insert(users).values({
first_name : first_name, last_name: last_name, username: username, email: email, password_hash : password_hash
first_name : first_name, last_name: last_name, username: email, email: email, password_hash : password_hash
});
};
@@ -37,4 +37,15 @@ export const editUser = async (id: string, first_name: string, last_name: string
})
.where(eq(users.id, id));
revalidatePath("/");
};
export const makeAdmin = async ( email : string) => {
await db
.update(users)
.set({
isAdmin : true
})
.where(eq(users.email, email));
revalidatePath("/");
};