diff --git a/src/app/Products/lowers/page.tsx b/src/app/Products/lowers/page.tsx index 9c5eac6..35a16d4 100644 --- a/src/app/Products/lowers/page.tsx +++ b/src/app/Products/lowers/page.tsx @@ -1,9 +1,10 @@ import { Button } from "@components/ui/button"; -import { getPSA } from "@/db/queries/PSA"; -import { psa } from '@/db/schema/Psa'; -import styles from '../styles.module.css' +import { getPSA, getLowerBuildKits, getAKBarreledReceivers } from "@queries/PSA"; +import { psa } from '@db/schema/Psa'; +import styles from '../styles.module.css'; + export default async function LowerReceiverPage() { - const psa = await getPSA(); + const psa = await getLowerBuildKits(); return (
@@ -19,9 +20,7 @@ export default async function LowerReceiverPage() { {psa.map((psa) => ( - - {psa.category} - + {psa.category} {psa.brandName} {psa.modelnumber} diff --git a/src/app/Products/uppers/page.tsx b/src/app/Products/uppers/page.tsx new file mode 100644 index 0000000..35a16d4 --- /dev/null +++ b/src/app/Products/uppers/page.tsx @@ -0,0 +1,36 @@ +import { Button } from "@components/ui/button"; +import { getPSA, getLowerBuildKits, getAKBarreledReceivers } from "@queries/PSA"; +import { psa } from '@db/schema/Psa'; +import styles from '../styles.module.css'; + +export default async function LowerReceiverPage() { + const psa = await getLowerBuildKits(); + + return ( +
+ + + + + + + + + + + {psa.map((psa) => ( + + + + + + + ))} + +
ComponentManufacturerModel #Price
{psa.category}{psa.brandName}{psa.modelnumber} + ${Number(psa.salePrice).toFixed(2)} + +
+
+ ); +} \ No newline at end of file diff --git a/src/db/queries/PSA/index.ts b/src/db/queries/PSA/index.ts index 115c918..939f96d 100644 --- a/src/db/queries/PSA/index.ts +++ b/src/db/queries/PSA/index.ts @@ -1,12 +1,47 @@ import { db } from '../../index'; import { psa } from '../../../drizzle/schema'; +import { eq, lt, gte, ne } from 'drizzle-orm'; export async function getPSA(page = 1) { - const limit = 10; + const limit = 20; const offset = (page - 1) * limit; return await db.select() .from(psa) .limit(limit) + .where(eq(psa.fineline, "Lower Build Kits")) .offset(offset); -} \ No newline at end of file +} + +export async function getLowerBuildKits(page = 1) { + const limit = 20; + const offset = (page - 1) * limit; + + return await db.select() + .from(psa) + .limit(limit) + .where(eq(psa.fineline, "Lower Build Kits")) + .offset(offset); +} + +export async function getAKBarreledReceivers(page = 1) { + const limit = 20; + const offset = (page - 1) * limit; + + return await db.select() + .from(psa) + .limit(limit) + .where(eq(psa.fineline, "AK Barreled Receivers")) + .offset(offset); +} + +export async function getARCompleteLowers(page = 1) { + const limit = 20; + const offset = (page - 1) * limit; + + return await db.select() + .from(psa) + .limit(limit) + .where(eq(psa.fineline, "AR Complete Lowers")) + .offset(offset); +} diff --git a/src/db/schema/Brand.ts b/src/db/schema/Brand.ts index 57b88aa..b18bcee 100644 --- a/src/db/schema/Brand.ts +++ b/src/db/schema/Brand.ts @@ -1,4 +1,4 @@ -import { pgTable, integer, varchar, uuid } from "drizzle-orm/pg-core"; +import { pgTable, integer, varchar, uuid } from "drizzle-orm/pg-core"; import { sql } from "drizzle-orm"; import { timestamps } from "./helpers/columns.helpers"; diff --git a/tsconfig.json b/tsconfig.json index de9fc8e..dc2f3e9 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -24,8 +24,12 @@ "./src/*"], "@/db/*": [ "./src/db/*"], + "@queries/*": [ + "./src/db/queries/*"], + "@schemas/*": [ + "./src/db/schema/*"], "@db/*": [ - "./src/db/*"], + "./src/db/*"], "@types/*": [ "./src/types/*"], "@components/*": [