Skip to content

added cart functionallity#1

Open
benimester wants to merge 2 commits into
mainfrom
db-cart
Open

added cart functionallity#1
benimester wants to merge 2 commits into
mainfrom
db-cart

Conversation

@benimester

Copy link
Copy Markdown
Owner

No description provided.

Copilot AI review requested due to automatic review settings October 14, 2025 08:13

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Implements shopping cart functionality across the full stack, enabling users to add products to cart, view cart contents, and remove items from cart while managing inventory stock.

  • Added cart data models and API endpoints for cart operations (add, get, remove)
  • Created shopping cart UI component with floating cart display and item management
  • Updated product cards to include "Add to Cart" functionality with stock validation

Reviewed Changes

Copilot reviewed 9 out of 10 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
04_market/src/types/cart.ts Defines TypeScript interfaces for cart items and cart creation requests
04_market/src/pages/ProductsPage.tsx Integrates shopping cart component and handles cart refresh state
04_market/src/components/ShoppingCart.tsx Implements floating shopping cart UI with item display and removal
04_market/src/components/ShoppingCart.css Styles for the floating shopping cart component
04_market/src/components/ProductCard.tsx Adds "Add to Cart" button with stock validation and error handling
04_market/src/api/cartRequests.ts API client functions for cart operations (add, get, remove)
03_python_fastapi_project/test_cart.py Test script for cart functionality (hardcoded path)
03_python_fastapi_project/main.py Backend cart API endpoints with inventory management
03_python_fastapi_project/database.py Database model for cart items with foreign key relationship

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

await removeFromCart(cartItemId);
await loadCart();
// Refresh the page to update product stock
window.location.reload();

Copilot AI Oct 14, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using window.location.reload() is a heavy-handed approach that causes a full page refresh. Consider using the existing cart refresh mechanism or state management instead.

Copilot uses AI. Check for mistakes.
if (onCartUpdate) {
onCartUpdate();
}
navigate(0); // Refresh to update stock

Copilot AI Oct 14, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using navigate(0) causes a full page refresh. Consider updating the product state locally or using a proper state management solution to avoid the jarring user experience.

Copilot uses AI. Check for mistakes.
Comment thread 03_python_fastapi_project/test_cart.py Outdated
Comment on lines +22 to +24
class CartItemCreate(BaseModel):
product_id: int
quantity: int = 1

Copilot AI Oct 14, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing input validation for quantity field. Should validate that quantity is positive and within reasonable limits.

Copilot uses AI. Check for mistakes.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants