cb0ff5feb7
2. Authentication Routes 3. Updated Data Store (`src/lib/db.ts`) 4. Updated API Routes 5. Updated Frontend Component (`src/components/BikeBuilderApp.tsx`)
39 lines
1.2 KiB
TypeScript
39 lines
1.2 KiB
TypeScript
import { PrismaClient } from "@prisma/client";
|
|
import { frames, forks, shocks, tires } from "../src/lib/catalog";
|
|
|
|
const prisma = new PrismaClient();
|
|
|
|
async function main() {
|
|
const products = [...frames, ...forks, ...shocks, ...tires];
|
|
for (const product of products) {
|
|
const { id, category, brand, model, imagePath, sources } = product;
|
|
const position = "position" in product ? product.position : null;
|
|
await prisma.product.upsert({
|
|
where: { id },
|
|
update: {
|
|
category,
|
|
position,
|
|
brand,
|
|
model,
|
|
imagePath,
|
|
specs: JSON.stringify(product),
|
|
setup: JSON.stringify(product),
|
|
sources: JSON.stringify(sources),
|
|
},
|
|
create: {
|
|
id,
|
|
category,
|
|
position,
|
|
brand,
|
|
model,
|
|
imagePath,
|
|
specs: JSON.stringify(product),
|
|
setup: JSON.stringify(product),
|
|
sources: JSON.stringify(sources),
|
|
},
|
|
});
|
|
}
|
|
}
|
|
|
|
main().finally(async () => prisma.$disconnect());
|