mirror of
https://gitea.gofwd.group/dstrawsb/ballistic-builder.git
synced 2025-12-06 02:36:44 -05:00
users page and a function to populate table headers
This commit is contained in:
@@ -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("/");
|
||||
};
|
||||
Reference in New Issue
Block a user