mirror of
https://gitea.gofwd.group/dstrawsb/ballistic-builder.git
synced 2025-12-06 02:36:44 -05:00
accounts stuff
This commit is contained in:
@@ -40,6 +40,7 @@
|
|||||||
"tailwindcss-animate": "^1.0.7"
|
"tailwindcss-animate": "^1.0.7"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@types/bun": "^1.1.13",
|
||||||
"@types/node": "^20.17.6",
|
"@types/node": "^20.17.6",
|
||||||
"@types/pg": "^8.11.10",
|
"@types/pg": "^8.11.10",
|
||||||
"@types/react": "^18",
|
"@types/react": "^18",
|
||||||
|
|||||||
@@ -2,26 +2,30 @@
|
|||||||
import { eq, not , asc} from "drizzle-orm";
|
import { eq, not , asc} from "drizzle-orm";
|
||||||
import { revalidatePath } from "next/cache";
|
import { revalidatePath } from "next/cache";
|
||||||
import { db } from "../db";
|
import { db } from "../db";
|
||||||
import { brand } from "../db/schema/Brand";
|
import { Account } from "../db/schema/Account";
|
||||||
export const getData = async () => {
|
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;
|
return data;
|
||||||
};
|
};
|
||||||
export const addBrand = async ( name: string) => {
|
export const addAccount = async ( first_name: string, last_name: string, username: string, email: string, password_hash : string) => {
|
||||||
await db.insert(brand).values({
|
await db.insert(Account).values({
|
||||||
name: name,
|
first_name : first_name, last_name: last_name, username: username, password_hash : password_hash
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
export const deleteBrand = async (id: number) => {
|
export const deleteAccount = async (id: number) => {
|
||||||
await db.delete(brand).where(eq(brand.id, id));
|
await db.delete(Account).where(eq(Account.id, id));
|
||||||
revalidatePath("/");
|
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
|
await db
|
||||||
.update(brand)
|
.update(Account)
|
||||||
.set({
|
.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("/");
|
revalidatePath("/");
|
||||||
};
|
};
|
||||||
@@ -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";
|
import Brands from "../../components/Brand/brands";
|
||||||
|
|
||||||
export default async function BrandsPage() {
|
export default async function AccountsPage() {
|
||||||
const data = await getData();
|
const data = await getData();
|
||||||
return (
|
return (
|
||||||
<div className="bg-gray-100 min-h-screen flex flex-col">
|
<div className="bg-gray-100 min-h-screen flex flex-col">
|
||||||
<Brands brands={data} />
|
{/* <Account account={data} /> */}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
// db/queries.ts
|
// db/queries.ts
|
||||||
|
"use server";
|
||||||
|
import { eq, not , asc} from "drizzle-orm";
|
||||||
import { Account } from '../schema/Account'
|
import { Account } from '../schema/Account'
|
||||||
import { db } from '../index';
|
import { db } from '../index';
|
||||||
|
|
||||||
@@ -14,10 +16,10 @@ export async function addAcount(first_name: string, last_name : string, username
|
|||||||
|
|
||||||
// Update a account
|
// Update a account
|
||||||
export async function updateAcount(id: number, first_name: string, last_name : string, username : string, password_hash: string ) {
|
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
|
// Delete a account
|
||||||
export async function deleteAccount(id: number) {
|
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));
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user