Welcome to Cofiblocks marketplace: A Starknet web3 platform to innovate Costa Rica coffee industry. Cofiblocks connects small coffee farmers directly with coffee lovers, cutting out unnecessary intermediaries.
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.
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 aProducerInfo
component that displays producer's farm information, including farm name, rating, sales count, altitude, and coordinates. Uses aFarmModal
component to showcase farm specific information. Uses aSelectionTypeCard
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