mirror of
https://gitea.gofwd.group/dstrawsb/ballistic-builder.git
synced 2025-12-05 18:26:45 -05:00
queries
This commit is contained in:
@@ -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 (
|
||||
<div className="container mx-auto">
|
||||
@@ -19,9 +20,7 @@ export default async function LowerReceiverPage() {
|
||||
<tbody>
|
||||
{psa.map((psa) => (
|
||||
<tr key={psa.upc}>
|
||||
<td>
|
||||
{psa.category}
|
||||
</td>
|
||||
<td>{psa.category}</td>
|
||||
<td>{psa.brandName}</td>
|
||||
<td>{psa.modelnumber}</td>
|
||||
<td className="flex items-center gap-2">
|
||||
|
||||
36
src/app/Products/uppers/page.tsx
Normal file
36
src/app/Products/uppers/page.tsx
Normal file
@@ -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 (
|
||||
<div className="container mx-auto">
|
||||
<table className={"table-auto border-separate border-spacing-4 border border-slate-500"}>
|
||||
<thead>
|
||||
<tr className={styles.tr}>
|
||||
<th>Component</th>
|
||||
<th>Manufacturer</th>
|
||||
<th>Model #</th>
|
||||
<th>Price</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{psa.map((psa) => (
|
||||
<tr key={psa.upc}>
|
||||
<td>{psa.category}</td>
|
||||
<td>{psa.brandName}</td>
|
||||
<td>{psa.modelnumber}</td>
|
||||
<td className="flex items-center gap-2">
|
||||
${Number(psa.salePrice).toFixed(2)}
|
||||
<Button variant="outline">Buy</Button>
|
||||
</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -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";
|
||||
|
||||
|
||||
@@ -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/*": [
|
||||
|
||||
Reference in New Issue
Block a user