diff --git a/Tree-diagram.jpg b/Tree-diagram.jpg
new file mode 100644
index 0000000..14db809
Binary files /dev/null and b/Tree-diagram.jpg differ
diff --git a/src/App.jsx b/src/App.jsx
index 03e658b..11eccb4 100644
--- a/src/App.jsx
+++ b/src/App.jsx
@@ -1,44 +1,27 @@
import './styles/reset.css'
import './styles/index.css'
-import initialStoreItems from './store-items'
+import Header from './Header'
+import Footer from './Footer'
+import MainContent from './MainContent'
+import { useState } from 'react'
export default function App() {
+ const [cartList, setCartList] = useState([])
+
return (
<>
-
-
- Your Cart
-
-
-
-
Total
-
-
- £0.00
-
-
-
-
+
+
+
+
+
>
)
-}
+}
\ No newline at end of file
diff --git a/src/CartItem.jsx b/src/CartItem.jsx
new file mode 100644
index 0000000..cdc2fdf
--- /dev/null
+++ b/src/CartItem.jsx
@@ -0,0 +1,38 @@
+/* eslint-disable react/prop-types */
+export default function CartItem({ cartList, setCartList }) {
+ const increment = (item) => {
+ setCartList(prevCartList => prevCartList.map(cartItem =>
+ cartItem.id === item.id ? { ...cartItem, quantity: cartItem.quantity + 1 } : cartItem
+ ))
+ }
+
+ const decrement = (item) => {
+ if (item.quantity > 1) {
+ setCartList(prevCartList => prevCartList.map(cartItem =>
+ cartItem.id === item.id ? { ...cartItem, quantity: cartItem.quantity - 1 } : cartItem
+ ))
+ } else {
+ setCartList(prevCartList => prevCartList.filter(cartItem => cartItem.id !== item.id))
+ }
+ }
+
+ return (
+
+ {cartList.map((item) => (
+
+ -
+
+ {item.name}
+
+ {item.quantity}
+
+
+
+ ))}
+
+ )
+}
\ No newline at end of file
diff --git a/src/Footer.jsx b/src/Footer.jsx
new file mode 100644
index 0000000..81b740b
--- /dev/null
+++ b/src/Footer.jsx
@@ -0,0 +1,20 @@
+export default function Footer() {
+ return (
+
+ )
+}
\ No newline at end of file
diff --git a/src/Header.jsx b/src/Header.jsx
new file mode 100644
index 0000000..954a6d8
--- /dev/null
+++ b/src/Header.jsx
@@ -0,0 +1,15 @@
+import StoreItem from "./StoreItem";
+
+// eslint-disable-next-line react/prop-types
+export default function Header({ cartList, setCartList }) {
+ return (
+
+ )
+}
\ No newline at end of file
diff --git a/src/MainContent.jsx b/src/MainContent.jsx
new file mode 100644
index 0000000..37425ef
--- /dev/null
+++ b/src/MainContent.jsx
@@ -0,0 +1,18 @@
+/* eslint-disable react/prop-types */
+import CartItem from "./CartItem";
+import Price from "./Price";
+
+export default function MainContent({ cartList, setCartList }) {
+ return (
+
+ Your Cart
+
+
+
+
+
+ )
+}
\ No newline at end of file
diff --git a/src/Price.jsx b/src/Price.jsx
new file mode 100644
index 0000000..9cdf494
--- /dev/null
+++ b/src/Price.jsx
@@ -0,0 +1,16 @@
+/* eslint-disable react/prop-types */
+export default function Price({ cartList }) {
+ const totalPrice = cartList.reduce((total, item) => total + (item.quantity * item.price), 0)
+
+ return (
+
+
+
Total
+
+
+
+ {`£${totalPrice.toFixed(2)}`}
+
+
+ )
+}
\ No newline at end of file
diff --git a/src/StoreItem.jsx b/src/StoreItem.jsx
new file mode 100644
index 0000000..d250717
--- /dev/null
+++ b/src/StoreItem.jsx
@@ -0,0 +1,31 @@
+import initialStoreItems from './store-items'
+
+/* eslint-disable react/prop-types */
+export default function StoreItem({ cartList, setCartList }) {
+ const handleClick = (item) => {
+ if (cartList.find(cartItem => cartItem.id === item.id)) {
+ setCartList(prevCartList => prevCartList.map(cartItem =>
+ cartItem.id === item.id ? { ...cartItem, quantity: cartItem.quantity + 1 } : cartItem
+ ))
+ } else {
+ setCartList(prevCartList => [...prevCartList, { ...item, quantity: 1 }])
+ }
+ }
+
+ return (
+
+ {initialStoreItems.map((item) => (
+ -
+
+

+
+
+
+
+ ))}
+
+ )
+}
\ No newline at end of file