fucking pos. data is working but tailwind is fucked

This commit is contained in:
2025-06-30 13:02:19 -04:00
parent 4798c1139e
commit c3151f380b
27 changed files with 2734 additions and 1792 deletions
+7
View File
@@ -0,0 +1,7 @@
import { db } from "@/db";
import { brands } from "@/db/schema";
export async function GET() {
const allBrands = await db.select().from(brands);
return Response.json({ success: true, data: allBrands });
}
+7
View File
@@ -0,0 +1,7 @@
import { db } from "@/db";
import { componentType } from "@/db/schema";
export async function GET() {
const allComponentTypes = await db.select().from(componentType);
return Response.json({ success: true, data: allComponentTypes });
}
+58
View File
@@ -0,0 +1,58 @@
import { db } from '@/db';
import { bb_products } from '@/db/schema';
function slugify(name: string): string {
return name
.toLowerCase()
.replace(/[^a-z0-9]+/g, '-')
.replace(/(^-|-$)+/g, '');
}
export async function GET(
req: Request,
{ params }: { params: { slug: string } }
) {
try {
const allProducts = await db.select().from(bb_products);
const mapped = allProducts.map((item: any) => ({
id: item.uuid,
name: item.productName,
slug: slugify(item.productName),
description: item.shortDescription || item.longDescription || '',
longDescription: item.longDescription,
image_url: item.imageUrl || item.thumbUrl || '/window.svg',
images: [item.imageUrl, item.thumbUrl].filter(Boolean),
brand: {
id: item.brandName || 'unknown',
name: item.brandName || 'Unknown',
logo: item.brandLogoImage || '',
},
category: {
id: item.category || 'unknown',
name: item.category || 'Unknown',
},
subcategory: item.subcategory,
offers: [
{
price: parseFloat(item.salePrice || item.retailPrice || '0'),
url: item.buyLink || '',
vendor: {
name: 'Brownells',
logo: '',
},
inStock: true,
shipping: '',
},
],
restrictions: {},
}));
const found = mapped.find((p: any) => p.slug === params.slug);
if (found) {
return Response.json({ success: true, product: found });
} else {
return Response.json({ success: false, error: 'Not found' }, { status: 404 });
}
} catch (error) {
return Response.json({ success: false, error: String(error) }, { status: 500 });
}
}
+24
View File
@@ -0,0 +1,24 @@
import { db } from "@/db";
import { bb_products } from "@/db/schema";
export async function GET() {
try {
const allProducts = await db.select().from(bb_products).limit(50);
const mapped = allProducts.map((item: any) => ({
id: item.uuid,
name: item.productName,
slug: slugify(item.productName),
...item
}));
return Response.json({ success: true, data: mapped });
} catch (error) {
return Response.json({ success: false, error: String(error) }, { status: 500 });
}
}
function slugify(name: string): string {
return name
.toLowerCase()
.replace(/[^a-z0-9]+/g, '-')
.replace(/(^-|-$)+/g, '');
}