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 { Button } from "@components/ui/button";
import { getPSA, getLowerBuildKits, getAKBarreledReceivers } from "@queries/PSA"; import { getPSA, getLowerBuildKits, getARCompleteLowers } from "@queries/PSA";
import { psa } from '@db/schema/Psa'; import { psa } from "@db/schema/Psa";
import styles from '../styles.module.css'; import styles from "../styles.module.css";
import PageHero from "@components/PageHero";
import Link from "next/link";
export default async function LowerReceiverPage() { export default async function LowerReceiverPage() {
const psa = await getLowerBuildKits(); const psa = await getARCompleteLowers();
return ( return (
<div>
<PageHero title="Lowers" />
<div className="container mx-auto py-5"> <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> <thead>
<tr className={styles.tr}> <tr className={styles.tr}>
<th>Component</th> <th>Component</th>
@@ -25,12 +33,16 @@ export default async function LowerReceiverPage() {
<td>{psa.modelnumber}</td> <td>{psa.modelnumber}</td>
<td className="flex items-center gap-2"> <td className="flex items-center gap-2">
${Number(psa.salePrice).toFixed(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> <Button variant="default">Buy</Button>
</Link>
</td> </td>
</tr> </tr>
))} ))}
</tbody> </tbody>
</table> </table>
</div> </div>
</div>
); );
} }

View File

@@ -24,19 +24,20 @@ export async function getLowerBuildKits(page = 1) {
.offset(offset); .offset(offset);
} }
export async function getAKBarreledReceivers(page = 1) { // DISABLING FOR NOW. NO NEED FOR AK. FOCUS ON AR15
const limit = 20; // export async function getAKBarreledReceivers(page = 1) {
const offset = (page - 1) * limit; // const limit = 20;
// const offset = (page - 1) * limit;
return await db.select() // return await db.select()
.from(psa) // .from(psa)
.limit(limit) // .limit(limit)
.where(eq(psa.fineline, "AK Barreled Receivers")) // .where(eq(psa.fineline, "AK Barreled Receivers"))
.offset(offset); // .offset(offset);
} // }
export async function getARCompleteLowers(page = 1) { export async function getARCompleteLowers(page = 1) {
const limit = 20; const limit = 40;
const offset = (page - 1) * limit; const offset = (page - 1) * limit;
return await db.select() return await db.select()