feat: update cart service and components to handle productVariantId, improve item removal and addition feedback
This commit is contained in:
@@ -54,6 +54,7 @@ export class StoreLayoutComponent implements OnInit {
|
||||
}
|
||||
|
||||
return {
|
||||
productVariantId: item.product_variant_id,
|
||||
imageUrl: item.product?.imagen ?? null,
|
||||
product,
|
||||
originalPrice: null,
|
||||
|
||||
@@ -75,8 +75,8 @@ describe('CartService', () => {
|
||||
});
|
||||
|
||||
it('should add item and update signal', () => {
|
||||
service.addItem(10, 2).subscribe((cart) => {
|
||||
expect(cart).toEqual(mockCart);
|
||||
service.addItem(10, 2).subscribe((res) => {
|
||||
expect(res.data).toEqual(mockCart);
|
||||
expect(service.cart()).toEqual(mockCart);
|
||||
});
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ export class CartService {
|
||||
);
|
||||
}
|
||||
|
||||
addItem(productVariantId: number, cantidad: number): Observable<Cart> {
|
||||
addItem(productVariantId: number, cantidad: number): Observable<ApiResponse<Cart>> {
|
||||
return this.http
|
||||
.post<ApiResponse<Cart>>(
|
||||
`${this.tenantApiUrl}/cart/items`,
|
||||
@@ -39,8 +39,7 @@ export class CartService {
|
||||
{ withCredentials: true }
|
||||
)
|
||||
.pipe(
|
||||
map((response) => response.data),
|
||||
tap((cart) => this.cartState.set(cart))
|
||||
tap((response) => this.cartState.set(response.data))
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user