Implement shopping cart functionality with UI components and API integration
- Added CartItem, CartSummary, CartEmpty, CartSidebar, and CartSheet components for managing cart display and interactions. - Integrated useCart and useCartUI composables for cart state management and UI control. - Implemented API endpoints for cart operations, including fetching, adding, updating, and removing items. - Enhanced user experience with loading states and notifications using vue-sonner for cart actions. - Configured session management for guest and authenticated users, ensuring cart persistence across sessions. This commit completes the shopping cart feature, enabling users to add items, view their cart, and proceed to checkout. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
This commit is contained in:
43
app/types/cart.ts
Normal file
43
app/types/cart.ts
Normal file
@@ -0,0 +1,43 @@
|
||||
/**
|
||||
* Shared cart types for client and server
|
||||
* These types mirror the server-side types from server/utils/cart-helpers.ts
|
||||
*/
|
||||
|
||||
/**
|
||||
* Cart item with product details and computed subtotal
|
||||
*/
|
||||
export interface CartItemWithProduct {
|
||||
id: string
|
||||
cartId: string
|
||||
productId: string
|
||||
quantity: number
|
||||
addedAt: Date
|
||||
product: {
|
||||
id: string
|
||||
name: string
|
||||
description: string | null
|
||||
price: string
|
||||
stockQuantity: number
|
||||
active: boolean
|
||||
category: string | null
|
||||
imageUrl: string | null
|
||||
}
|
||||
subtotal: number
|
||||
}
|
||||
|
||||
/**
|
||||
* Cart summary with items and totals
|
||||
*/
|
||||
export interface CartSummary {
|
||||
cart: {
|
||||
id: string
|
||||
userId: string | null
|
||||
sessionId: string
|
||||
createdAt: Date
|
||||
updatedAt: Date
|
||||
}
|
||||
items: CartItemWithProduct[]
|
||||
total: number
|
||||
itemCount: number
|
||||
removedItems?: string[] // Names of products that were removed due to unavailability
|
||||
}
|
||||
Reference in New Issue
Block a user