diff --git a/bun.lockb b/bun.lockb new file mode 100755 index 0000000..7444e2a Binary files /dev/null and b/bun.lockb differ diff --git a/package.json b/package.json index 60f0ab5..24a9bf8 100644 --- a/package.json +++ b/package.json @@ -40,6 +40,7 @@ "tailwindcss-animate": "^1.0.7" }, "devDependencies": { + "@types/bun": "^1.1.13", "@types/node": "^20.17.6", "@types/pg": "^8.11.10", "@types/react": "^18", diff --git a/src/actions/accountActions.ts b/src/actions/accountActions.ts index b10c83b..df5e63e 100644 --- a/src/actions/accountActions.ts +++ b/src/actions/accountActions.ts @@ -2,26 +2,30 @@ import { eq, not , asc} from "drizzle-orm"; import { revalidatePath } from "next/cache"; import { db } from "../db"; -import { brand } from "../db/schema/Brand"; +import { Account } from "../db/schema/Account"; export const getData = async () => { - const data = await db.select().from(brand).orderBy(asc(brand.name)); + const data = await db.select().from(Account).orderBy(asc(Account.last_name)); return data; }; -export const addBrand = async ( name: string) => { - await db.insert(brand).values({ - name: name, +export const addAccount = async ( first_name: string, last_name: string, username: string, email: string, password_hash : string) => { + await db.insert(Account).values({ + first_name : first_name, last_name: last_name, username: username, password_hash : password_hash }); }; -export const deleteBrand = async (id: number) => { - await db.delete(brand).where(eq(brand.id, id)); +export const deleteAccount = async (id: number) => { + await db.delete(Account).where(eq(Account.id, id)); revalidatePath("/"); }; -export const editBrand = async (id: number, name: string) => { +export const editAccount = async (id: number, first_name: string, last_name: string, username: string, email : string, password_hash: string) => { await db - .update(brand) + .update(Account) .set({ - name: name, + first_name : first_name, + last_name: last_name, + username: username, + email: email, + password_hash: password_hash }) - .where(eq(brand.id, id)); + .where(eq(Account.id, id)); revalidatePath("/"); }; \ No newline at end of file diff --git a/src/app/Accounts/page.tsx b/src/app/Accounts/page.tsx index e68f00e..0033302 100644 --- a/src/app/Accounts/page.tsx +++ b/src/app/Accounts/page.tsx @@ -1,11 +1,12 @@ -import { getData } from "../../actions/brandActions"; +import { Account } from "@/db/schema/Account"; +import { getData } from "../../actions/accountActions"; import Brands from "../../components/Brand/brands"; -export default async function BrandsPage() { +export default async function AccountsPage() { const data = await getData(); return (
- + {/* */}
); } diff --git a/src/db/queries/index.ts b/src/db/queries/index.ts index 6a3907e..2749d68 100644 --- a/src/db/queries/index.ts +++ b/src/db/queries/index.ts @@ -1,4 +1,6 @@ // db/queries.ts +"use server"; +import { eq, not , asc} from "drizzle-orm"; import { Account } from '../schema/Account' import { db } from '../index'; @@ -14,10 +16,10 @@ export async function addAcount(first_name: string, last_name : string, username // Update a account export async function updateAcount(id: number, first_name: string, last_name : string, username : string, password_hash: string ) { - return await db.update(Account).set({ first_name, last_name, username, password_hash }).where(Account.id.equals(id)); + return await db.update(Account).set({ first_name, last_name, username, password_hash }).where(eq(Account.id, id)); } // Delete a account export async function deleteAccount(id: number) { - return await db.delete(Account).where(Account.id.equals(id)); + return await db.delete(Account).where(eq(Account.id, id)); } \ No newline at end of file