ok, we are nearly done

This commit is contained in:
2024-12-14 00:43:45 -05:00
parent 94e5886d70
commit 62f95b16cd
10 changed files with 187 additions and 174 deletions

View File

@@ -1,11 +1,16 @@
import type { NextConfig } from "next"; import type { NextConfig } from "next";
const nextConfig: NextConfig = { module.exports = {
/* config options here */
/* module.exports = {
images: { images: {
remotePatterns: [ remotePatterns: [
{
protocol: 'https',
hostname: 'assets.example.com',
port: '',
pathname: '/**',
search: '',
},
{ {
protocol: 'https', protocol: 'https',
hostname: 'images.unsplash.com', hostname: 'images.unsplash.com',
@@ -17,10 +22,14 @@ const nextConfig: NextConfig = {
hostname: 'tailwindui.com', hostname: 'tailwindui.com',
port: '', port: '',
pathname: '/plus/img/logos/**', pathname: '/plus/img/logos/**',
},
{
protocol: 'http',
hostname: 'i1.avlws.com',
port: '',
pathname: '/**',
} }
], ],
}, }
},*/
}; };
export default nextConfig;

View File

@@ -1,18 +1,17 @@
import { getPSA, getLowerBuildKits, getProductType } from "@queries/PSA"; import { getProductType } from "@queries/PSA";
import { psa } from '@db/schema/Psa';
import partTypes from 'src/data/parts_cats.json'; 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"; import PageHero from "@src/components/PageHero";
import ProductTable from "@src/components/ProductTable"; import ProductTable from "@src/components/ProductTable";
export default async function BarrelsPage() { export default async function BarrelsPage() {
const psa = await getProductType('Barrels'); const data = await getProductType('Barrels');
return ( return (
<div> <div>
<PageHero title="Barrels" /> <PageHero title="Barrels" />
<div className="container mx-auto"> <div className="container mx-auto">
<ProductTable data={psa}></ProductTable> <ProductTable data={data}></ProductTable>
</div> </div>
</div> </div>
); );

View File

@@ -1,43 +1,17 @@
import { getPSA, getLowerBuildKits, getGrips } from "@queries/PSA"; import { getGrips } from "@queries/PSA";
import { psa } from '@db/schema/Psa';
import partTypes from 'src/data/parts_cats.json'; 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"; import PageHero from "@src/components/PageHero";
import ProductTable from "@src/components/ProductTable"; import ProductTable from "@src/components/ProductTable";
export default async function GripsPage() { export default async function GripsPage() {
const psa = await getGrips(); const data = await getGrips();
return ( return (
<div> <div>
<PageHero title="AR Grips" /> <PageHero title="AR Grips" />
<div className="container mx-auto"> <div className="container mx-auto">
<ProductTable data={psa}></ProductTable> <ProductTable data={data}></ProductTable>
<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'>Retail Price</th>
<th className='bg-slate-700 w-20'>Sale Price</th>
</tr>
</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'>{psa.retailPrice}</td>
<td className="text-slate-800 flex items-center gap-2">
${Number(psa.salePrice).toFixed(2)}
<button>Buy</button>
</td>
</tr>
))}
</tbody>
</table>
</div> </div>
</div> </div>
); );

View File

@@ -1,18 +1,16 @@
import { getPSA, getLowerBuildKits, getARHandGuards } from "@queries/PSA"; import { 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"; import PageHero from "@src/components/PageHero";
import ProductTable from "@src/components/ProductTable"; import ProductTable from "@src/components/ProductTable";
export default async function HamdGuardsPage() { export default async function HamdGuardsPage() {
const psa = await getARHandGuards(); const data = await getARHandGuards();
return ( return (
<div> <div>
<PageHero title="Hand Guards" /> <PageHero title="Hand Guards" />
<div className="container mx-auto"> <div className="container mx-auto">
<ProductTable data={psa}></ProductTable> <ProductTable data={data}></ProductTable>
</div> </div>
</div> </div>
); );

View File

@@ -4,47 +4,16 @@ import { psa } from "@db/schema/Psa";
import styles from "../styles.module.css"; import styles from "../styles.module.css";
import PageHero from "@components/PageHero"; import PageHero from "@components/PageHero";
import Link from "next/link"; import Link from "next/link";
import ProductTable from "@src/components/ProductTable";
export default async function LowerReceiverPage() { export default async function LowerReceiverPage() {
const psa = await getProductType(partTypes["AR COMPLETE LOWERS"]); const data = await getProductType(partTypes["AR COMPLETE LOWERS"]);
return ( return (
<div> <div>
<PageHero title="Lowers"/> <PageHero title="Lowers"/>
<div className="container mx-auto py-5"> <div className="container mx-auto py-5">
<table <ProductTable data={data}></ProductTable>
className={
"table-auto border-separate border-spacing-4 border border-slate-500 text-gray-900"
}
>
<thead>
<tr >
<th>Component</th>
<th>Manufacturer</th>
<th>Model #</th>
<th>Price</th>
<th>Sale 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>{psa.retailPrice}</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 >Buy</button>
</Link>
</td>
</tr>
))}
</tbody>
</table>
</div> </div>
</div> </div>
); );

View File

@@ -1,18 +1,17 @@
import { getMuzzleDevices } from "@queries/PSA"; import { getMuzzleDevices } from "@queries/PSA";
import { psa } from '@db/schema/Psa';
import partTypes from 'src/data/parts_cats.json'; 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"; import PageHero from "@src/components/PageHero";
import ProductTable from "@src/components/ProductTable"; import ProductTable from "@src/components/ProductTable";
export default async function MuzzleDevices() { export default async function MuzzleDevices() {
const psa = await getMuzzleDevices(); const data = await getMuzzleDevices();
return ( return (
<div> <div>
<PageHero title="Muzzle Devices" /> <PageHero title="Muzzle Devices" />
<div className="container mx-auto"> <div className="container mx-auto">
<ProductTable data={psa}></ProductTable> <ProductTable data={data}></ProductTable>
</div> </div>
</div> </div>
); );

View File

@@ -1,36 +1,14 @@
import { getPSA, getLowerBuildKits, getProductType} from "@queries/PSA"; import { getARParts } from "@queries/PSA";
import { psa } from '@db/schema/Psa';
import partTypes from 'src/data/parts_cats.json'; import partTypes from 'src/data/parts_cats.json';
import styles from '../styles.module.css'; import styles from '../styles.module.css';
import ProductTable from "@src/components/ProductTable";
export default async function PartsPage() { export default async function PartsPage() {
const psa = await getProductType(partTypes["AR PARTS"]); const data = await getARParts();
return ( return (
<div className="container mx-auto"> <div className="container mx-auto">
<table className={"table-auto border-separate border-spacing-4 border border-slate-500"}> <ProductTable data={data}></ProductTable>
<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 >Buy</button>
</td>
</tr>
))}
</tbody>
</table>
</div> </div>
); );
} }

View File

@@ -1,4 +1,6 @@
import { psa } from "@db/schema/Psa";
import Image from "next/image";
import Link from "next/link";
export default async function ProductTable(props: any) { export default async function ProductTable(props: any) {
return ( return (
@@ -10,19 +12,28 @@ export default async function ProductTable(props:any) {
<th className='bg-slate-700 text-white w-40 pl-1 text-left'>Model #</th> <th className='bg-slate-700 text-white w-40 pl-1 text-left'>Model #</th>
<th className='bg-slate-700 text-white w-40 pl-1 text-left'>Retail Price</th> <th className='bg-slate-700 text-white w-40 pl-1 text-left'>Retail Price</th>
<th className='bg-slate-700 text-white w-20 pl-1 text-left'>Sale Price</th> <th className='bg-slate-700 text-white w-20 pl-1 text-left'>Sale Price</th>
<th className='bg-slate-700 text-white w-20 pl-1 text-left'></th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
{props.data.map((item: any) => ( {props.data.map((item: any) => (
<tr key={item.uuid} > <tr className='text-white' key={item.uuid} >
<td className='text-white'>{item.category}</td> <td className='text-white text-left'>
<td className='text-white'>{item.brandName}</td> <a href={item.buyLink} target="_new">
<td className='text-white'>{item.modelnumber}</td> <Image src={item.imageUrl} alt="A image of the product" width="50" height="50"></Image>
<td className='text-white'>{item.retailPrice}</td> </a>
<td className="text-white flex items-center gap-2"> </td>
${Number(item.salePrice).toFixed(2)} <td className='text-white text-left'>{item.brandName}</td>
<button >Buy</button> <td className='text-white text-left'>{item.modelnumber}</td>
<td className='text-white text-left'>{item.retailPrice}</td>
<td className='text-white text-left flex items-center gap-2'>
${Number(item.salePrice).toFixed(2)}</td>
<td className='text-center'>
<a href={item.buyLink} target="_new">
<button className='bg-slate-700 hover:bg-slate-400 text-white font-bold py-2 px-4 border-b-4 border-blue-700 hover:border-blue-500 rounded align-middle'>Add</button>
</a>
</td> </td>
</tr> </tr>
))} ))}

View File

@@ -1,5 +1,5 @@
import { pgTable, integer, varchar, text, decimal, real } from "drizzle-orm/pg-core"; import { pgTable, integer, varchar, text, decimal, uuid, real } from "drizzle-orm/pg-core";
import { sql } from "drizzle-orm"; import { sql } from "drizzle-orm";
import { timestamps } from "./helpers/columns.helpers"; import { timestamps } from "./helpers/columns.helpers";
@@ -33,4 +33,6 @@ export const psa = pgTable("psa", {
productContentWidget: varchar("PRODUCT_CONTENT_WIDGET", { length: 256 }), productContentWidget: varchar("PRODUCT_CONTENT_WIDGET", { length: 256 }),
googleCategorization: varchar("GOOGLE_CATEGORIZATION", { length: 50 }), googleCategorization: varchar("GOOGLE_CATEGORIZATION", { length: 50 }),
itemBasedCommission: varchar("ITEM_BASED_COMMISSION", { length: 50 }), itemBasedCommission: varchar("ITEM_BASED_COMMISSION", { length: 50 }),
uuid: uuid().defaultRandom(),
}); });
export default psa;

View File

@@ -1,4 +1,4 @@
import { pgTable, integer, varchar, text, numeric, timestamp, uuid, unique, real, index, doublePrecision } from "drizzle-orm/pg-core" import { pgTable, integer, varchar, text, numeric, timestamp, uuid, unique, index, real, doublePrecision, pgView } from "drizzle-orm/pg-core"
import { sql } from "drizzle-orm" import { sql } from "drizzle-orm"
@@ -67,38 +67,6 @@ export const manufacturer = pgTable("manufacturer", {
} }
}); });
export const psa = pgTable("psa", {
sku: varchar("SKU", { length: 50 }),
manufacturerId: varchar("MANUFACTURER_ID", { length: 50 }),
brandName: varchar("BRAND_NAME", { length: 50 }),
productName: varchar("PRODUCT_NAME", { length: 255 }),
longDescription: text("LONG_DESCRIPTION"),
shortDescription: varchar("SHORT_DESCRIPTION", { length: 50 }),
department: varchar("DEPARTMENT", { length: 50 }),
category: varchar("CATEGORY", { length: 50 }),
subcategory: varchar("SUBCATEGORY", { length: 50 }),
thumbUrl: varchar("THUMB_URL", { length: 50 }),
imageUrl: varchar("IMAGE_URL", { length: 50 }),
buyLink: varchar("BUY_LINK", { length: 128 }),
keywords: varchar("KEYWORDS", { length: 50 }),
reviews: varchar("REVIEWS", { length: 50 }),
retailPrice: real("RETAIL_PRICE"),
salePrice: real("SALE_PRICE"),
brandPageLink: varchar("BRAND_PAGE_LINK", { length: 50 }),
brandLogoImage: varchar("BRAND_LOGO_IMAGE", { length: 50 }),
productPageViewTracking: varchar("PRODUCT_PAGE_VIEW_TRACKING", { length: 256 }),
parentGroupId: varchar("PARENT_GROUP_ID", { length: 50 }),
fineline: varchar("FINELINE", { length: 50 }),
superfineline: varchar("SUPERFINELINE", { length: 200 }),
modelnumber: varchar("MODELNUMBER", { length: 50 }),
caliber: varchar("CALIBER", { length: 200 }),
upc: varchar("UPC", { length: 100 }),
mediumImageUrl: varchar("MEDIUM_IMAGE_URL", { length: 50 }),
productContentWidget: varchar("PRODUCT_CONTENT_WIDGET", { length: 256 }),
googleCategorization: varchar("GOOGLE_CATEGORIZATION", { length: 50 }),
itemBasedCommission: varchar("ITEM_BASED_COMMISSION", { length: 50 }),
});
export const states = pgTable("states", { export const states = pgTable("states", {
id: integer().primaryKey().generatedByDefaultAsIdentity({ name: "states_id_seq", startWith: 1, increment: 1, minValue: 1, maxValue: 2147483647, cache: 1 }), id: integer().primaryKey().generatedByDefaultAsIdentity({ name: "states_id_seq", startWith: 1, increment: 1, minValue: 1, maxValue: 2147483647, cache: 1 }),
state: varchar({ length: 50 }), state: varchar({ length: 50 }),
@@ -118,6 +86,34 @@ export const componentType = pgTable("component_type", {
} }
}); });
export const aeroPrecision = pgTable("aero_precision", {
sku: text().primaryKey().notNull(),
manufacturerId: text("manufacturer_id"),
brandName: text("brand_name"),
productName: text("product_name"),
longDescription: text("long_description"),
shortDescription: text("short_description"),
department: text(),
category: text(),
subcategory: text(),
thumbUrl: text("thumb_url"),
imageUrl: text("image_url"),
buyLink: text("buy_link"),
keywords: text(),
reviews: text(),
retailPrice: numeric("retail_price"),
salePrice: numeric("sale_price"),
brandPageLink: text("brand_page_link"),
brandLogoImage: text("brand_logo_image"),
productPageViewTracking: text("product_page_view_tracking"),
variantsXml: text("variants_xml"),
mediumImageUrl: text("medium_image_url"),
productContentWidget: text("product_content_widget"),
googleCategorization: text("google_categorization"),
itemBasedCommission: text("item_based_commission"),
uuid: uuid().defaultRandom(),
});
export const compartment = pgTable("compartment", { export const compartment = pgTable("compartment", {
id: uuid().defaultRandom().primaryKey().notNull(), id: uuid().defaultRandom().primaryKey().notNull(),
name: varchar({ length: 100 }).notNull(), name: varchar({ length: 100 }).notNull(),
@@ -163,6 +159,80 @@ export const balAccounts = pgTable("bal_accounts", {
} }
}); });
export const brownells = pgTable("brownells", {
sku: text(),
manufacturerId: text("manufacturer_id"),
brandName: text("brand_name"),
productName: text("product_name"),
longDescription: text("long_description"),
shortDescription: text("short_description"),
department: text(),
category: text(),
subcategory: text(),
thumbUrl: text("thumb_url"),
imageUrl: text("image_url"),
buyLink: text("buy_link"),
keywords: text(),
reviews: text(),
retailPrice: numeric("retail_price"),
salePrice: numeric("sale_price"),
brandPageLink: text("brand_page_link"),
brandLogoImage: text("brand_logo_image"),
productPageViewTracking: text("product_page_view_tracking"),
parentGroupId: text("parent_group_id"),
color: text(),
size: text(),
pattern: text(),
material: text(),
ageGroup: text("age_group"),
gender: text(),
upc: text(),
availability: text(),
googleProductCategory: text("google_product_category"),
mediumImageUrl: text("medium_image_url"),
variantsXml: text("variants_xml"),
gtin: text(),
keyWords: text("key_words"),
productContentWidget: text("product_content_widget"),
googleCategorization: text("google_categorization"),
itemBasedCommission: text("item_based_commission"),
itemBasedCommissionRate: text("item_based_commission_rate"),
itemBasedCommissionRule: text("item_based_commission_rule"),
});
export const psa = pgTable("psa", {
sku: varchar("SKU", { length: 50 }),
manufacturerId: varchar("MANUFACTURER_ID", { length: 50 }),
brandName: varchar("BRAND_NAME", { length: 50 }),
productName: varchar("PRODUCT_NAME", { length: 255 }),
longDescription: text("LONG_DESCRIPTION"),
shortDescription: varchar("SHORT_DESCRIPTION", { length: 50 }),
department: varchar("DEPARTMENT", { length: 50 }),
category: varchar("CATEGORY", { length: 50 }),
subcategory: varchar("SUBCATEGORY", { length: 50 }),
thumbUrl: varchar("THUMB_URL", { length: 50 }),
imageUrl: varchar("IMAGE_URL", { length: 50 }),
buyLink: varchar("BUY_LINK", { length: 128 }),
keywords: varchar("KEYWORDS", { length: 50 }),
reviews: varchar("REVIEWS", { length: 50 }),
retailPrice: real("RETAIL_PRICE"),
salePrice: real("SALE_PRICE"),
brandPageLink: varchar("BRAND_PAGE_LINK", { length: 50 }),
brandLogoImage: varchar("BRAND_LOGO_IMAGE", { length: 50 }),
productPageViewTracking: varchar("PRODUCT_PAGE_VIEW_TRACKING", { length: 256 }),
parentGroupId: varchar("PARENT_GROUP_ID", { length: 50 }),
fineline: varchar("FINELINE", { length: 50 }),
superfineline: varchar("SUPERFINELINE", { length: 200 }),
modelnumber: varchar("MODELNUMBER", { length: 50 }),
caliber: varchar("CALIBER", { length: 200 }),
upc: varchar("UPC", { length: 100 }),
mediumImageUrl: varchar("MEDIUM_IMAGE_URL", { length: 50 }),
productContentWidget: varchar("PRODUCT_CONTENT_WIDGET", { length: 256 }),
googleCategorization: varchar("GOOGLE_CATEGORIZATION", { length: 50 }),
itemBasedCommission: varchar("ITEM_BASED_COMMISSION", { length: 50 }),
uuid: uuid().defaultRandom(),
});
export const lipseycatalog = pgTable("lipseycatalog", { export const lipseycatalog = pgTable("lipseycatalog", {
id: integer().primaryKey().generatedAlwaysAsIdentity({ name: "lipseycatalog_id_seq", startWith: 1, increment: 1, minValue: 1, maxValue: 2147483647, cache: 1 }), id: integer().primaryKey().generatedAlwaysAsIdentity({ name: "lipseycatalog_id_seq", startWith: 1, increment: 1, minValue: 1, maxValue: 2147483647, cache: 1 }),
itemno: varchar({ length: 20 }).notNull(), itemno: varchar({ length: 20 }).notNull(),
@@ -275,3 +345,7 @@ export const balResellers = pgTable("bal_resellers", {
balResellersUuidUnique: unique("bal_resellers_uuid_unique").on(table.uuid), balResellersUuidUnique: unique("bal_resellers_uuid_unique").on(table.uuid),
} }
}); });
export const vwProducts = pgView("vw_products", { aeroSku: text("aero_sku"),
aeroCategory: text("aero_category"),
aeroProductName: text("aero_product_name"),
}).as(sql`SELECT aero.sku AS aero_sku, aero.category AS aero_category, aero.product_name AS aero_product_name FROM aero_precision aero WHERE aero.department = 'Stripped Lowers'::text UNION ALL SELECT psa."SKU" AS aero_sku, psa."CATEGORY" AS aero_category, psa."PRODUCT_NAME" AS aero_product_name FROM psa psa WHERE psa."FINELINE"::text = 'AR Complete Lowers'::text`);