Skip to content

Commit 14e7b6d

Browse files
committed
Я МОЛОДЕЦ! Я ЗАКОНЧИЛ КУРС! ЭТО УРОК №10.
1 parent 51fa3a3 commit 14e7b6d

File tree

9 files changed

+381
-395
lines changed

9 files changed

+381
-395
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@
7979
"eslintConfig": {
8080
"extends": "react-app"
8181
},
82+
"proxy": "http://localhost:3001",
8283
"browserslist": {
8384
"production": [
8485
">0.2%",

src/components/CartItem.jsx

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
import React from 'react';
2+
import Button from './Button';
3+
4+
const CartItem = ({ id, name, type, size, totalPrice, totalCount, onRemove, onMinus, onPlus }) => {
5+
const handleRemoveClick = () => {
6+
onRemove(id);
7+
};
8+
9+
const handlePlusItem = () => {
10+
onPlus(id);
11+
};
12+
13+
const handleMinusItem = () => {
14+
onMinus(id);
15+
};
16+
17+
return (
18+
<div className="cart__item">
19+
<div className="cart__item-img">
20+
<img
21+
className="pizza-block__image"
22+
src="https://dodopizza-a.akamaihd.net/static/Img/Products/Pizza/ru-RU/b750f576-4a83-48e6-a283-5a8efb68c35d.jpg"
23+
alt="Pizza"
24+
/>
25+
</div>
26+
<div className="cart__item-info">
27+
<h3>{name}</h3>
28+
<p>
29+
{type} тесто, {size} см.
30+
</p>
31+
</div>
32+
<div className="cart__item-count">
33+
<div
34+
onClick={handleMinusItem}
35+
className="button button--outline button--circle cart__item-count-minus">
36+
<svg
37+
width="10"
38+
height="10"
39+
viewBox="0 0 10 10"
40+
fill="none"
41+
xmlns="http://www.w3.org/2000/svg">
42+
<path
43+
d="M5.92001 3.84V5.76V8.64C5.92001 9.17016 5.49017 9.6 4.96001 9.6C4.42985 9.6 4.00001 9.17016 4.00001 8.64L4 5.76L4.00001 3.84V0.96C4.00001 0.42984 4.42985 0 4.96001 0C5.49017 0 5.92001 0.42984 5.92001 0.96V3.84Z"
44+
fill="#EB5A1E"
45+
/>
46+
<path
47+
d="M5.75998 5.92001L3.83998 5.92001L0.959977 5.92001C0.429817 5.92001 -2.29533e-05 5.49017 -2.29301e-05 4.96001C-2.2907e-05 4.42985 0.429817 4.00001 0.959977 4.00001L3.83998 4L5.75998 4.00001L8.63998 4.00001C9.17014 4.00001 9.59998 4.42985 9.59998 4.96001C9.59998 5.49017 9.17014 5.92001 8.63998 5.92001L5.75998 5.92001Z"
48+
fill="#EB5A1E"
49+
/>
50+
</svg>
51+
</div>
52+
<b>{totalCount}</b>
53+
<div
54+
onClick={handlePlusItem}
55+
className="button button--outline button--circle cart__item-count-plus">
56+
<svg
57+
width="10"
58+
height="10"
59+
viewBox="0 0 10 10"
60+
fill="none"
61+
xmlns="http://www.w3.org/2000/svg">
62+
<path
63+
d="M5.92001 3.84V5.76V8.64C5.92001 9.17016 5.49017 9.6 4.96001 9.6C4.42985 9.6 4.00001 9.17016 4.00001 8.64L4 5.76L4.00001 3.84V0.96C4.00001 0.42984 4.42985 0 4.96001 0C5.49017 0 5.92001 0.42984 5.92001 0.96V3.84Z"
64+
fill="#EB5A1E"
65+
/>
66+
<path
67+
d="M5.75998 5.92001L3.83998 5.92001L0.959977 5.92001C0.429817 5.92001 -2.29533e-05 5.49017 -2.29301e-05 4.96001C-2.2907e-05 4.42985 0.429817 4.00001 0.959977 4.00001L3.83998 4L5.75998 4.00001L8.63998 4.00001C9.17014 4.00001 9.59998 4.42985 9.59998 4.96001C9.59998 5.49017 9.17014 5.92001 8.63998 5.92001L5.75998 5.92001Z"
68+
fill="#EB5A1E"
69+
/>
70+
</svg>
71+
</div>
72+
</div>
73+
<div className="cart__item-price">
74+
<b>{totalPrice}</b>
75+
</div>
76+
<div className="cart__item-remove">
77+
<Button onClick={handleRemoveClick} className="button--circle" outline>
78+
<svg
79+
width="10"
80+
height="10"
81+
viewBox="0 0 10 10"
82+
fill="none"
83+
xmlns="http://www.w3.org/2000/svg">
84+
<path
85+
d="M5.92001 3.84V5.76V8.64C5.92001 9.17016 5.49017 9.6 4.96001 9.6C4.42985 9.6 4.00001 9.17016 4.00001 8.64L4 5.76L4.00001 3.84V0.96C4.00001 0.42984 4.42985 0 4.96001 0C5.49017 0 5.92001 0.42984 5.92001 0.96V3.84Z"
86+
fill="#EB5A1E"
87+
/>
88+
<path
89+
d="M5.75998 5.92001L3.83998 5.92001L0.959977 5.92001C0.429817 5.92001 -2.29533e-05 5.49017 -2.29301e-05 4.96001C-2.2907e-05 4.42985 0.429817 4.00001 0.959977 4.00001L3.83998 4L5.75998 4.00001L8.63998 4.00001C9.17014 4.00001 9.59998 4.42985 9.59998 4.96001C9.59998 5.49017 9.17014 5.92001 8.63998 5.92001L5.75998 5.92001Z"
90+
fill="#EB5A1E"
91+
/>
92+
</svg>
93+
</Button>
94+
</div>
95+
</div>
96+
);
97+
};
98+
99+
export default CartItem;

src/components/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@ export { default as Button } from './Button';
22
export { default as Header } from './Header';
33
export { default as Categories } from './Categories';
44
export { default as SortPopup } from './SortPopup';
5+
export { default as CartItem } from './CartItem';
56
export { default as PizzaBlock } from './PizzaBlock';
67
export { default as PizzaLoadingBlock } from './PizzaBlock/LoadingBlock';

0 commit comments

Comments
 (0)