mirror of
https://gitea.gofwd.group/dstrawsb/ballistic-builder.git
synced 2025-12-06 02:36:44 -05:00
adding accouns screens
This commit is contained in:
27
src/actions/accountActions.ts
Normal file
27
src/actions/accountActions.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
"use server";
|
||||
import { eq, not , asc} from "drizzle-orm";
|
||||
import { revalidatePath } from "next/cache";
|
||||
import { db } from "../db";
|
||||
import { brand } from "../db/schema/Brand";
|
||||
export const getData = async () => {
|
||||
const data = await db.select().from(brand).orderBy(asc(brand.name));
|
||||
return data;
|
||||
};
|
||||
export const addBrand = async ( name: string) => {
|
||||
await db.insert(brand).values({
|
||||
name: name,
|
||||
});
|
||||
};
|
||||
export const deleteBrand = async (id: number) => {
|
||||
await db.delete(brand).where(eq(brand.id, id));
|
||||
revalidatePath("/");
|
||||
};
|
||||
export const editBrand = async (id: number, name: string) => {
|
||||
await db
|
||||
.update(brand)
|
||||
.set({
|
||||
name: name,
|
||||
})
|
||||
.where(eq(brand.id, id));
|
||||
revalidatePath("/");
|
||||
};
|
||||
12
src/app/Accounts/page.tsx
Normal file
12
src/app/Accounts/page.tsx
Normal file
@@ -0,0 +1,12 @@
|
||||
import { getData } from "../../actions/brandActions";
|
||||
import Brands from "../../components/Brand/brands";
|
||||
|
||||
export default async function BrandsPage() {
|
||||
const data = await getData();
|
||||
return (
|
||||
<div className="bg-gray-100 min-h-screen flex flex-col">
|
||||
<Brands brands={data} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user