mirror of
https://gitea.gofwd.group/dstrawsb/ballistic-builder.git
synced 2025-12-06 02:36:44 -05:00
added a products page and pulled psa data
This commit is contained in:
36
src/app/Products/lowers/page.tsx
Normal file
36
src/app/Products/lowers/page.tsx
Normal file
@@ -0,0 +1,36 @@
|
||||
import { Button } from "src/components/ui/button";
|
||||
import { getPSA } from "@/db/queries/PSA";
|
||||
|
||||
export default async function LowerReceiverPage() {
|
||||
const psa = await getPSA();
|
||||
|
||||
return (
|
||||
<div className="container mx-auto">
|
||||
<table className="table-auto border-separate border-spacing-2 border border-slate-500">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Component</th>
|
||||
<th>Manufacturer</th>
|
||||
<th>Color</th>
|
||||
<th>Price</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{psa.map((psa) => (
|
||||
<tr key={psa.upc}>
|
||||
<td>
|
||||
{psa.category}
|
||||
</td>
|
||||
<td>manufacturer</td>
|
||||
<td>color</td>
|
||||
<td className="flex items-center gap-2">
|
||||
${Number(psa.salePrice).toFixed(2)}
|
||||
<Button variant="outline">Buy</Button>
|
||||
</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
12
src/db/queries/PSA/index.ts
Normal file
12
src/db/queries/PSA/index.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
import { db } from '../../index';
|
||||
import { psa } from '../../../drizzle/schema';
|
||||
|
||||
export async function getPSA(page = 1) {
|
||||
const limit = 10;
|
||||
const offset = (page - 1) * limit;
|
||||
|
||||
return await db.select()
|
||||
.from(psa)
|
||||
.limit(limit)
|
||||
.offset(offset);
|
||||
}
|
||||
8
src/db/schema/Psa.ts
Normal file
8
src/db/schema/Psa.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
import { pgTable, text, decimal, serial, integer } from 'drizzle-orm/pg-core';
|
||||
|
||||
export const psa = pgTable('psa', {
|
||||
id: integer().primaryKey().generatedAlwaysAsIdentity({ name: "brands_id_seq", startWith: 1, increment: 1, minValue: 1, maxValue: 2147483647, cache: 1 }),
|
||||
category: text('category').notNull(),
|
||||
department: text('department').notNull(),
|
||||
saleprice: decimal('saleprice', { precision: 10, scale: 2 }).notNull(),
|
||||
});
|
||||
Reference in New Issue
Block a user