|
1 | 1 | import React, { useState, useEffect } from 'react';
|
2 | 2 | import CartProductNotFound from '../components/CartProductNotFound';
|
3 | 3 | import { Link } from 'react-router-dom';
|
4 |
| -import { BsCircleFill, BsChevronCompactRight, BsChevronCompactLeft } from "react-icons/bs"; |
| 4 | +import { BsChevronCompactRight, BsChevronCompactLeft } from "react-icons/bs"; |
5 | 5 | import '../css/Cart.css'
|
6 | 6 |
|
7 | 7 | export default function Cart() {
|
@@ -128,7 +128,13 @@ export default function Cart() {
|
128 | 128 | }
|
129 | 129 | }
|
130 | 130 | };
|
131 |
| - |
| 131 | + |
| 132 | + let totalPrice = 0; |
| 133 | + productDetails.map((product, index) => { |
| 134 | + totalPrice += product.price * product.quantity; |
| 135 | + }); |
| 136 | + |
| 137 | + |
132 | 138 |
|
133 | 139 |
|
134 | 140 | return (
|
@@ -166,7 +172,7 @@ export default function Cart() {
|
166 | 172 | </div>
|
167 | 173 | </div>
|
168 | 174 | <div className="d-flex flex-row align-items-center">
|
169 |
| - <span className="d-block ml-5 font-weight-bold">${product.price}</span> |
| 175 | + <span className="d-block ml-5 font-weight-bold">${product.price * product.quantity}</span> |
170 | 176 | <span className="d-block ml-5 font-weight-bold" id= "AddQuantity-RemoveQuantity">
|
171 | 177 | <BsChevronCompactLeft onClick={() => RemoveQuantity(product.id)} id="Leftİcon"/>
|
172 | 178 | {product.quantity}
|
@@ -211,15 +217,22 @@ export default function Cart() {
|
211 | 217 | <input type="text" className="form-control credit-inputs" placeholder="342" />
|
212 | 218 | </div>
|
213 | 219 | </div>
|
| 220 | + <div> |
214 | 221 | <hr className="line" />
|
215 |
| - <div className="d-flex justify-content-between information"><span>Subtotal</span><span>$3000.00</span></div> |
216 |
| - <div className="d-flex justify-content-between information"><span>Shipping</span><span>$20.00</span></div> |
217 |
| - <div className="d-flex justify-content-between information"><span>Total(Incl. taxes)</span><span>$3020.00</span></div> |
| 222 | + <div className="d-flex justify-content-between information"> |
| 223 | + <span>Subtotal</span> |
| 224 | + <span>{totalPrice }</span> |
| 225 | + </div> |
| 226 | + <div className="d-flex justify-content-between information"> |
| 227 | + <span>Total (Incl. taxes)</span> |
| 228 | + <span>{totalPrice}</span> |
| 229 | + </div> |
218 | 230 | <button className="btn btn-primary btn-block d-flex justify-content-between mt-3" type="button">
|
219 |
| - <span>$3020.00</span> |
220 |
| - <span>Checkout<i className="fa fa-long-arrow-right ml-1"></i></span> |
| 231 | + <span>{totalPrice}</span> |
| 232 | + <span>Checkout <i className="fa fa-long-arrow-right ml-1"></i></span> |
221 | 233 | </button>
|
222 | 234 | </div>
|
| 235 | + </div> |
223 | 236 | </div>
|
224 | 237 | </div>
|
225 | 238 | </div>
|
|
0 commit comments