Feature update products#2
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR transforms a general product catalog into a heavy equipment marketplace by updating product data models and adding comprehensive seed data for construction equipment, parts, and components.
- Updates Product type to include heavy equipment specific fields (stockQty, specs with modelYear/warranty/compatibility)
- Changes price handling from string to number format with higher price ranges (thousands instead of tens)
- Adds extensive seed data with new categories (dump trucks, hydraulics, filters, undercarriage) and brands (Volvo, Hitachi, John Deere)
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| frontend/src/app/shop/page.tsx | Updates product type definitions, price formatting, stock-based availability logic, and UI text for heavy equipment marketplace |
| backend/prisma/seed.ts | Adds new categories, brands, and comprehensive product data for heavy equipment with detailed specifications |
| compatibleMakes: ['Caterpillar'], | ||
| modelYear: 2024, | ||
| condition: 'New', | ||
| availability: 'In stock' |
There was a problem hiding this comment.
The 'availability' field in specs appears to be redundant since availability is now calculated from stockQty in the frontend. Consider removing this field to avoid potential inconsistencies between the calculated availability and this hardcoded value.
| availability: 'In stock' | |
| // availability field removed |
| compatibleMakes?: string[]; | ||
| warranty?: string; | ||
| genuine?: boolean; | ||
| [key: string]: any; |
There was a problem hiding this comment.
Using 'any' type reduces type safety. Consider defining a more specific interface for the specs object or using a union type for known properties to maintain better type checking.
| [key: string]: any; | |
| [key: string]: string | number | boolean | string[] | undefined; |
|
|
||
| async function fetchProducts(): Promise<Product[]> { | ||
| const res = await fetch('http://localhost:5000/api/products', { | ||
| const res = await fetch('http://localhost:3000/api/products', { |
There was a problem hiding this comment.
Hardcoded localhost URL will fail in production. Consider using environment variables or relative URLs that work across different environments.
| {getUniqueValues('condition').map((condition, index) => ( | ||
| <option key={`condition-${index}`} value={condition.toLowerCase()}> |
There was a problem hiding this comment.
Using array index as part of the key is not optimal and could cause issues. Since conditions should be unique, use the condition value itself as the key: key={condition}
| {getUniqueValues('condition').map((condition, index) => ( | |
| <option key={`condition-${index}`} value={condition.toLowerCase()}> | |
| {getUniqueValues('condition').map((condition) => ( | |
| <option key={condition} value={condition.toLowerCase()}> |
added products in seed.ts and updated shop/page.tsx