feat: product details implementation #48
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Closes #32
This PR introduces the
ProductDetails
component to display detailed information about products.Key implementations include:
ProductDetails Component (
ProductDetails.tsx
):Display Features:
Shows product image, name, description, roast level, process method, price, and availability.
Uses
DataCard
components to present attributes like roast level, process, bags available, and unit price.Uses a
ProducerInfo
component that displays producer's farm information, including farm name, rating, sales count, altitude, and coordinates.Uses a
FarmModal
component to showcase farm specific information.Uses a
SelectionTypeCard
Component that:Allows users to select coffee type (bean or grounded) and adjust quantity.
Displays unit price and calculates total price based on quantity.
Includes increment and decrement buttons for quantity selection.
"Add to Cart" button to add the selected quantity to the cart.
Conditional Rendering:
Adjusts the UI based on product type ("Buyer", "Farmer", or "SoldOut").
Displays "Sold Out" status when applicable.
Product API Endpoint (
route.ts
):Adds a new API route at
/api/product/[id]
to fetch product data.Retrieves product details from mockedProducts based on the provided ID.
Returns a JSON response with product data or a 404 error if not found.
Product Page (
page.tsx
):Fetches the product ID from URL parameters.
Calls the new API endpoint to retrieve product data.
Manages loading and error states with appropriate user feedback.
Renders the
ProductDetails
component with the fetched product data.Checklist
Type of Change
Additional Notes
Check this video for the preview:
https://www.loom.com/share/22336caaaac94343a0699028aa3bcac6?sid=c93594da-51a0-4507-83b2-09c8a39a6af5