Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 83cf30c

Browse files
committed
Support for product in cart
1 parent 367862c commit 83cf30c

File tree

4 files changed

+33
-6
lines changed

4 files changed

+33
-6
lines changed

src/app/ui-components/molecules/product-default/product-default.component.html

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,16 @@
44
(resize)="onResize($event)"
55
>
66
<section actions>
7-
<p *ngIf="isLarge">Add to cart:</p>
8-
<ov-quantity-picker
9-
[quantity]="product.quantity"
10-
(selectQuantity)="selectQuantity($event)"
11-
></ov-quantity-picker>
7+
<ov-message type="ok" *ngIf="product.inCart; else notInCart">
8+
In cart
9+
</ov-message>
10+
<ng-template #notInCart>
11+
<p *ngIf="isLarge">Add to cart:</p>
12+
<ov-quantity-picker
13+
[quantity]="product.quantity"
14+
(selectQuantity)="selectQuantity($event)"
15+
></ov-quantity-picker>
16+
</ng-template>
1217
</section>
1318
<section footer>
1419
<ov-message type="ok" *ngIf="!product.isLimited; else limited">

src/app/ui-components/molecules/product-default/product-default.component.mocks.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,31 +2,47 @@ import { QuantityPickerMocks } from '../../molecules/quantity-picker/quantity-pi
22
import { ProductMock } from '../product/product.component.mocks';
33
import { ProductDefault } from './product-default.component';
44

5-
type MockKeys = 'PRIMARY' | 'MAX_CONTENT' | 'MIN_CONTENT' | 'LANDSCAPE';
5+
type MockKeys =
6+
| 'PRIMARY'
7+
| 'MAX_CONTENT'
8+
| 'MIN_CONTENT'
9+
| 'LANDSCAPE'
10+
| 'IN_CART';
611

712
export const ProductDefaultMock: Record<MockKeys, ProductDefault> = {
813
PRIMARY: {
914
...ProductMock.PRIMARY,
1015
type: 'product',
1116
quantity: QuantityPickerMocks.PRIMARY,
1217
isLimited: false,
18+
inCart: false,
19+
},
20+
IN_CART: {
21+
...ProductMock.PRIMARY,
22+
type: 'product',
23+
quantity: QuantityPickerMocks.PRIMARY,
24+
isLimited: false,
25+
inCart: true,
1326
},
1427
MAX_CONTENT: {
1528
...ProductMock.MAX_CONTENT,
1629
type: 'product',
1730
quantity: QuantityPickerMocks.WITH_STEPS,
1831
isLimited: false,
32+
inCart: false,
1933
},
2034
MIN_CONTENT: {
2135
...ProductMock.MIN_CONTENT,
2236
type: 'product',
2337
quantity: QuantityPickerMocks.MIN_QUANTITY,
2438
isLimited: true,
39+
inCart: false,
2540
},
2641
LANDSCAPE: {
2742
...ProductMock.LANDSCAPE,
2843
type: 'product',
2944
quantity: QuantityPickerMocks.PRIMARY,
3045
isLimited: false,
46+
inCart: false,
3147
},
3248
};

src/app/ui-components/molecules/product-default/product-default.component.stories.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,8 @@ export const MinContent = Template.bind({});
3131
MinContent.args = {
3232
product: ProductDefaultMock.MIN_CONTENT,
3333
};
34+
35+
export const InCart = Template.bind({});
36+
InCart.args = {
37+
product: ProductDefaultMock.IN_CART,
38+
};

src/app/ui-components/molecules/product-default/product-default.component.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export interface ProductDefault extends Product {
1717
type: 'product';
1818
quantity: Quantity;
1919
isLimited: boolean;
20+
inCart: boolean;
2021
}
2122

2223
@Component({

0 commit comments

Comments
 (0)