lots of work

This commit is contained in:
2024-12-13 00:31:17 -05:00
parent 63138c2e69
commit b2e2893b4b
12 changed files with 1344 additions and 176 deletions

View File

@@ -1,37 +1,41 @@
import { Button } from "@components/ui/button";
import { getPSA, getLowerBuildKits, getProductType} from "@queries/PSA";
import { getPSA, getLowerBuildKits, getProductType } from "@queries/PSA";
import { psa } from '@db/schema/Psa';
import partTypes from 'src/data/parts_cats.json';
import styles from '../styles.module.css';
import styles from '../styles.module.css';
import PageHero from "@src/components/PageHero";
export default async function GripsPage() {
const psa = await getProductType(partTypes["AR PARTS"]);
export default async function BarrelsPage() {
const psa = await getProductType('Barrels');
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>
<div>
<PageHero title="Barrels" />
<div className="container mx-auto">
<table className={"table-auto border-separate border-spacing-4 border border-slate-500"}>
<thead>
<tr className={styles.tr}>
<th className='bg-slate-700 pl-2 w-40'>Component</th>
<th className='bg-slate-700 w-40'>Manufacturer</th>
<th className='bg-slate-700 w-40'>Model #</th>
<th className='bg-slate-700 w-40'>Price</th>
</tr>
))}
</tbody>
</table>
</thead>
<tbody>
{psa.map((psa) => (
<tr key={psa.upc}>
<td className='text-slate-800'>{psa.category}</td>
<td className='text-slate-800'>{psa.brandName}</td>
<td className='text-slate-800'>{psa.modelnumber}</td>
<td className="text-slate-800 flex items-center gap-2">
${Number(psa.salePrice).toFixed(2)}
<Button variant="outline">Buy</Button>
</td>
</tr>
))}
</tbody>
</table>
</div>
</div>
);
}

View File

@@ -1,37 +1,41 @@
import { Button } from "@components/ui/button";
import { getPSA, getLowerBuildKits, getProductType} from "@queries/PSA";
import { getPSA, getLowerBuildKits, getGrips } from "@queries/PSA";
import { psa } from '@db/schema/Psa';
import partTypes from 'src/data/parts_cats.json';
import styles from '../styles.module.css';
import styles from '../styles.module.css';
import PageHero from "@src/components/PageHero";
export default async function GripsPage() {
const psa = await getProductType(partTypes["AR PARTS"]);
const psa = await getGrips();
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>
<div>
<PageHero title="AR Grips" />
<div className="container mx-auto">
<table className="table-auto border-collapse border-spacing-3 border border-slate-500">
<thead>
<tr className={styles.tr}>
<th className='bg-slate-700 pl-2 w-40'>Component</th>
<th className='bg-slate-700 w-40'>Manufacturer</th>
<th className='bg-slate-700 w-40'>Model #</th>
<th className='bg-slate-700 w-20'>Price</th>
</tr>
))}
</tbody>
</table>
</thead>
<tbody>
{psa.map((psa) => (
<tr key={psa.upc}>
<td className='text-slate-800 pl-2'>{psa.category}</td>
<td className='text-slate-800'>{psa.brandName}</td>
<td className='text-slate-800'>{psa.modelnumber}</td>
<td className="text-slate-800 flex items-center gap-2">
${Number(psa.salePrice).toFixed(2)}
<Button variant="outline">Buy</Button>
</td>
</tr>
))}
</tbody>
</table>
</div>
</div>
);
}

View File

@@ -1,37 +1,41 @@
import { Button } from "@components/ui/button";
import { getPSA, getLowerBuildKits, getProductType} from "@queries/PSA";
import { getPSA, getLowerBuildKits, getARHandGuards } from "@queries/PSA";
import { psa } from '@db/schema/Psa';
import partTypes from 'src/data/parts_cats.json';
import styles from '../styles.module.css';
import styles from '../styles.module.css';
import PageHero from "@src/components/PageHero";
export default async function GripsPage() {
const psa = await getProductType(partTypes["AR PARTS"]);
export default async function HamdGuardsPage() {
const psa = await getARHandGuards();
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>
<div>
<PageHero title="Hand Guards" />
<div className="container mx-auto">
<table className={"table-auto border-separate border-spacing-4 border border-slate-500"}>
<thead>
<tr className={styles.tr}>
<th className='bg-slate-700 pl-2 w-40'>Component</th>
<th className='bg-slate-700 w-40'>Manufacturer</th>
<th className='bg-slate-700 w-40'>Model #</th>
<th className='bg-slate-700 w-40'>Price</th>
</tr>
))}
</tbody>
</table>
</thead>
<tbody>
{psa.map((psa) => (
<tr key={psa.upc}>
<td className='text-slate-800'>{psa.category}</td>
<td className='text-slate-800'>{psa.brandName}</td>
<td className='text-slate-800'>{psa.modelnumber}</td>
<td className='text-slate-800 flex items-center gap-2'>
${Number(psa.salePrice).toFixed(2)}
<Button variant="outline">Buy</Button>
</td>
</tr>
))}
</tbody>
</table>
</div>
</div>
);
}

View File

@@ -1,5 +1,5 @@
import { Button } from "@components/ui/button";
import { getPSA, getLowerBuildKits, getARCompleteLowers, getProductType } from "@queries/PSA";
import { getARCompleteLowers, getProductType } from "@queries/PSA";
import partTypes from 'src/data/parts_cats.json';
import { psa } from "@db/schema/Psa";
import styles from "../styles.module.css";

View File

@@ -1,37 +1,41 @@
import { Button } from "@components/ui/button";
import { getPSA, getLowerBuildKits, getProductType} from "@queries/PSA";
import { getMuzzleDevices } from "@queries/PSA";
import { psa } from '@db/schema/Psa';
import partTypes from 'src/data/parts_cats.json';
import styles from '../styles.module.css';
import styles from '../styles.module.css';
import PageHero from "@src/components/PageHero";
export default async function GripsPage() {
const psa = await getProductType(partTypes["AR PARTS"]);
export default async function MuzzleDevices() {
const psa = await getMuzzleDevices();
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>
<div>
<PageHero title="Muzzle Devices" />
<div className="container mx-auto">
<table className="table-auto border-separate border-spacing-4 border border-slate-500">
<thead>
<tr className={styles.tr}>
<th className='bg-slate-700 pl-2 w-40'>Component</th>
<th className='bg-slate-700 w-40'>Manufacturer</th>
<th className='bg-slate-700 w-40'>Model #</th>
<th className='bg-slate-700 w-20'>Price</th>
</tr>
))}
</tbody>
</table>
</thead>
<tbody>
{psa.map((psa) => (
<tr key={psa.upc}>
<td className='text-slate-800'>{psa.category}</td>
<td className='text-slate-800'>{psa.brandName}</td>
<td className='text-slate-800'>{psa.modelnumber}</td>
<td className='text-slate-800 flex items-center gap-2'>
${Number(psa.salePrice).toFixed(2)}
<Button variant="outline">Buy</Button>
</td>
</tr>
))}
</tbody>
</table>
</div>
</div>
);
}

View File

@@ -1,37 +1,41 @@
import { Button } from "@components/ui/button";
import { getPSA, getLowerBuildKits, getProductType} from "@queries/PSA";
import { getStocks } from "@queries/PSA";
import { psa } from '@db/schema/Psa';
import partTypes from 'src/data/parts_cats.json';
import styles from '../styles.module.css';
import styles from '../styles.module.css';
import PageHero from "@src/components/PageHero";
export default async function GripsPage() {
const psa = await getProductType(partTypes["AR PARTS"]);
export default async function StocksPage() {
const psa = await getStocks();
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>
<div>
<PageHero title="Stocks" />
<div className="container mx-auto">
<table className="table-auto border-separate border-spacing-4 border border-slate-500">
<thead>
<tr className={styles.tr}>
<th className='bg-slate-700 pl-2 w-40'>Component</th>
<th className='bg-slate-700 w-40'>Manufacturer</th>
<th className='bg-slate-700 w-40'>Model #</th>
<th className='bg-slate-700 w-20'>Price</th>
</tr>
))}
</tbody>
</table>
</thead>
<tbody>
{psa.map((psa) => (
<tr key={psa.upc}>
<td className='text-slate-800'>{psa.category}</td>
<td className='text-slate-800'>{psa.brandName}</td>
<td className='text-slate-800'>{psa.modelnumber}</td>
<td className='text-slate-800 flex items-center gap-2'>
${Number(psa.salePrice).toFixed(2)}
<Button variant="outline">Buy</Button>
</td>
</tr>
))}
</tbody>
</table>
</div>
</div>
);
}

View File

@@ -7,3 +7,6 @@
font-weight: bold;
background-color: cadetblue;
}
.td {
color : "stone-700";
}

View File

@@ -1,30 +1,33 @@
import { Button } from "@components/ui/button";
import { getPSA, getLowerBuildKits, getProductType} from "@queries/PSA";
import { getARTriggers} from "@queries/PSA";
import { psa } from '@db/schema/Psa';
import partTypes from 'src/data/parts_cats.json';
import styles from '../styles.module.css';
import PageHero from "@src/components/PageHero";
export default async function GripsPage() {
const psa = await getProductType(partTypes["AR PARTS"]);
export default async function TriggersPage() {
const psa = await getARTriggers();
return (
<div>
<PageHero title="AR Triggers" />
<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>
<th className='bg-slate-700 w-40 pl-2'>Component</th>
<th className='bg-slate-700 w-40'>Manufacturer</th>
<th className='bg-slate-700 w-40'>Model #</th>
<th className='bg-slate-700 w-40'>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">
<td className='text-slate-800'>{psa.category}</td>
<td className='text-slate-800'>{psa.brandName}</td>
<td className='text-slate-800'>{psa.modelnumber}</td>
<td className='text-slate-800 flex items-center gap-2'>
${Number(psa.salePrice).toFixed(2)}
<Button variant="outline">Buy</Button>
</td>
@@ -33,5 +36,6 @@ export default async function GripsPage() {
</tbody>
</table>
</div>
</div>
);
}

View File

@@ -1,36 +1,40 @@
import { Button } from "@components/ui/button";
import { getPSA, getLowerBuildKits, getAKBarreledReceivers } from "@queries/PSA";
import { getPSA, getUpperReciever } from "@queries/PSA";
import { psa } from '@db/schema/Psa';
import styles from '../styles.module.css';
import styles from '../styles.module.css';
import PageHero from "@src/components/PageHero";
export default async function LowerReceiverPage() {
const psa = await getLowerBuildKits();
export default async function UpperReceiverPage() {
const psa = await getUpperReciever();
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>
<div>
<PageHero title="Upper Recievers" />
<div className="container mx-auto">
<table className={"table-auto border-separate border-spacing-4 border border-slate-500"}>
<thead>
<tr className={styles.tr}>
<th className='bg-slate-700 w-40 pl-2'>Component</th>
<th className='bg-slate-700 w-40'>Manufacturer</th>
<th className='bg-slate-700 w-40'>Model #</th>
<th className='bg-slate-700 w-20'>Price</th>
</tr>
))}
</tbody>
</table>
</thead>
<tbody>
{psa.map((psa) => (
<tr key={psa.upc}>
<td className='text-slate-800'>{psa.category}</td>
<td className='text-slate-800'>{psa.brandName}</td>
<td className='text-slate-800'>{psa.modelnumber}</td>
<td className='text-slate-800 flex items-center gap-2'>
${Number(psa.salePrice).toFixed(2)}
<Button variant="outline">Buy</Button>
</td>
</tr>
))}
</tbody>
</table>
</div>
</div>
);
}

1050
src/data/fineline.json Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,6 @@
import { db } from '../../index';
import { psa } from '../../../drizzle/schema';
import { eq, lt, gte, ne } from 'drizzle-orm';
import { eq, lt, gte, ne, and, like } from 'drizzle-orm';
import CATEGORY from '@src/data/parts_cats.json';
export async function getPSA(page = 1) {
@@ -43,6 +43,93 @@ export async function getProductType(productType : any, page = 1) {
return await db.select()
.from(psa)
.limit(limit)
.where(eq(psa.fineline, productType.name))
.where(eq(psa.fineline, (typeof(productType) !== 'string' ? productType.name : productType)))
.offset(offset);
}
export async function getGrips(page = 1) {
const limit = 40;
const offset = (page - 1) * limit;
return await db.select()
.from(psa)
.limit(limit)
.where(eq(psa.fineline, "Grips"))
.offset(offset);
}
export async function getARHandGuards(page = 1) {
const limit = 40;
const offset = (page - 1) * limit;
return await db.select()
.from(psa)
.limit(limit)
.where(and(eq(psa.fineline, "Handguards & Rail Systems"), eq(psa.category, 'Ar Parts')))
.offset(offset);
}
export async function getAKHandGuards(page = 1) {
const limit = 40;
const offset = (page - 1) * limit;
return await db.select()
.from(psa)
.limit(limit)
.where(and(eq(psa.fineline, "Handguards & Rail Systems"), eq(psa.category, 'Ak Parts')))
.offset(offset);
}
export async function getMuzzleDevices(page = 1) {
const limit = 40;
const offset = (page - 1) * limit;
return await db.select()
.from(psa)
.limit(limit)
.where(eq(psa.fineline, "Muzzle Brakes"))
.offset(offset);
}
export async function getStocks(page = 1) {
const limit = 40;
const offset = (page - 1) * limit;
return await db.select()
.from(psa)
.limit(limit)
.where(eq(psa.fineline, "Stocks"))
.offset(offset);
}
export async function getStocksParts(page = 1) {
const limit = 40;
const offset = (page - 1) * limit;
return await db.select()
.from(psa)
.limit(limit)
.where(eq(psa.fineline, "Stocks"))
.offset(offset);
}
export async function getUpperReciever(page = 1) {
const limit = 40;
const offset = (page - 1) * limit;
return await db.select()
.from(psa)
.limit(limit)
.where(like(psa.fineline, "%Upper Receivers"))
.offset(offset);
}
export async function getARTriggers(page = 1) {
const limit = 40;
const offset = (page - 1) * limit;
return await db.select()
.from(psa)
.limit(limit)
.where(and(like(psa.fineline, "%Trigger%"), like(psa.category, "Ar Parts")))
.offset(offset);
}

View File

@@ -11,7 +11,7 @@ export async function getAllProducts() {
// Add a new product
export async function addProduct() {
return await db.insert(Product).values({}).returning();
return await db.insert(Product).values({ }).returning();
}
// Update a Product