Cart rendering, bug fixes with cart adding/rming
This commit is contained in:
3
dto/__init__.py
Normal file
3
dto/__init__.py
Normal file
@@ -0,0 +1,3 @@
|
||||
from .cart import CartItemDTO
|
||||
|
||||
__all__ = ["CartItemDTO"]
|
||||
19
dto/cart.py
Normal file
19
dto/cart.py
Normal file
@@ -0,0 +1,19 @@
|
||||
from dataclasses import dataclass
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class CartItemDTO:
|
||||
product_id: int
|
||||
name: str
|
||||
quantity: int
|
||||
price: int
|
||||
|
||||
@property
|
||||
def total(self):
|
||||
return self.price * self.quantity
|
||||
|
||||
|
||||
@dataclass
|
||||
class CartDTO:
|
||||
items: list[CartItemDTO]
|
||||
total: int
|
||||
Reference in New Issue
Block a user