product with links

This commit is contained in:
2024-12-12 10:34:50 -05:00
parent 94772623cd
commit 6c7b7472fd
2 changed files with 51 additions and 38 deletions

View File

@@ -1,14 +1,22 @@
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';
import { getPSA, getLowerBuildKits, getARCompleteLowers } from "@queries/PSA";
import { psa } from "@db/schema/Psa";
import styles from "../styles.module.css";
import PageHero from "@components/PageHero";
import Link from "next/link";
export default async function LowerReceiverPage() {
const psa = await getLowerBuildKits();
const psa = await getARCompleteLowers();
return (
<div>
<PageHero title="Lowers" />
<div className="container mx-auto py-5">
<table className={"table-auto border-separate border-spacing-4 border border-slate-500 text-gray-900"}>
<table
className={
"table-auto border-separate border-spacing-4 border border-slate-500 text-gray-900"
}
>
<thead>
<tr className={styles.tr}>
<th>Component</th>
@@ -25,12 +33,16 @@ export default async function LowerReceiverPage() {
<td>{psa.modelnumber}</td>
<td className="flex items-center gap-2">
${Number(psa.salePrice).toFixed(2)}
{/* I dont think this is exactly correct but works for now? */}
<Link href={psa.buyLink} passHref={true}>
<Button variant="default">Buy</Button>
</Link>
</td>
</tr>
))}
</tbody>
</table>
</div>
</div>
);
}

View File

@@ -24,19 +24,20 @@ export async function getLowerBuildKits(page = 1) {
.offset(offset);
}
export async function getAKBarreledReceivers(page = 1) {
const limit = 20;
const offset = (page - 1) * limit;
// DISABLING FOR NOW. NO NEED FOR AK. FOCUS ON AR15
// 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);
}
// 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 limit = 40;
const offset = (page - 1) * limit;
return await db.select()