diff --git a/src/Components/Optional/CartItem.jsx b/src/Components/Optional/CartItem.jsx index cc09665..9762500 100644 --- a/src/Components/Optional/CartItem.jsx +++ b/src/Components/Optional/CartItem.jsx @@ -1,64 +1,115 @@ -import { CheckCircleIcon, SmallCloseIcon } from '@chakra-ui/icons' -import { Flex, Image, Text, Box, Circle, Heading, useToast } from '@chakra-ui/react' -import React from 'react' -import { useDispatch } from 'react-redux' -import { deleteToCart } from '../Redux/cart/cart.actions' - -const CartItem = ({ image_link, name, price, id, brand }) => { - const toast = useToast() - console.log(id) - const dispatch = useDispatch(); - const handleDelete = (id) => { - toast({ - position: 'top-left', - duration: 1200, - render: () => ( - - - {`${name} has been deleted!!!`} - - - ), - }) - - dispatch(deleteToCart(id)) - - } - return ( - - - - {name} - {`Brand: ${brand}`} - - {`$${price}`} - - - handleDelete(id)} - - > - - - +import { CheckCircleIcon, SmallCloseIcon } from "@chakra-ui/icons"; +import { + Flex, + Image, + Text, + Box, + Circle, + Heading, + useToast, + Button, +} from "@chakra-ui/react"; +import React from "react"; +import { useDispatch } from "react-redux"; +import { + decQuantity, + deleteToCart, + incQuantity, +} from "../Redux/cart/cart.actions"; +const CartItem = ({ image_link, name, price, id, brand, quantity }) => { + const toast = useToast(); + console.log(id); + const dispatch = useDispatch(); + const handleDelete = (id) => { + toast({ + position: "top-left", + duration: 1200, + render: () => ( + + + {`${name} has been deleted!!!`} + ), + }); + dispatch(deleteToCart(id)); + }; + return ( + + + + + {name} + + {`Brand: ${brand}`} + + + + + + {`$${price}`} + + + handleDelete(id)} + > + + + {`Subtotal: ${quantity * price}`} + + + ); +}; - - ) -} - -export default CartItem \ No newline at end of file +export default CartItem; diff --git a/src/Components/Pages/All_Products_Pages/Checkout.jsx b/src/Components/Pages/All_Products_Pages/Checkout.jsx index 67c924c..8b50be7 100644 --- a/src/Components/Pages/All_Products_Pages/Checkout.jsx +++ b/src/Components/Pages/All_Products_Pages/Checkout.jsx @@ -1,18 +1,20 @@ import { - Box, Image, Flex, Heading, Select, Input - , + Box, + Image, + Flex, + Heading, + Select, + Input, Text, - Center, Button, - useDisclosure - -} from '@chakra-ui/react'; + useDisclosure, +} from "@chakra-ui/react"; -import React from 'react'; -import { useDispatch, useSelector } from 'react-redux'; -import { Link, useNavigate } from 'react-router-dom'; -import Footer from '../Footer'; +import React from "react"; +import { useDispatch, useSelector } from "react-redux"; +import { Link, useNavigate } from "react-router-dom"; +import Footer from "../Footer"; import { Modal, ModalOverlay, @@ -21,46 +23,60 @@ import { ModalFooter, ModalBody, ModalCloseButton, -} from '@chakra-ui/react' -import { CheckCircleIcon } from '@chakra-ui/icons'; -import { resetCart } from '../../Redux/cart/cart.actions'; +} from "@chakra-ui/react"; +import { CheckCircleIcon } from "@chakra-ui/icons"; +import { resetCart } from "../../Redux/cart/cart.actions"; const Checkout = () => { const cartItems = useSelector((state) => state.cartManager.products); const { isOpen, onOpen, onClose } = useDisclosure(); - const dispatch = useDispatch() + const dispatch = useDispatch(); let cartTotal = cartItems.reduce((acc, p) => { - return acc + Number(p.price); + return acc + Number(p.price) * Number(p.quantity); }, 0); const handleProceed = () => { dispatch(resetCart()); onOpen(); - - - } - + }; return ( <> - - - - + +
- - 1. Shipping Address + + + {" "} + 1. Shipping Address +
- * Country /Region - + - + @@ -79,45 +95,271 @@ const Checkout = () => { - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
- * Full Name - - * Zip Code/Postcode - - * Address - - * Town/City - - * Contact Number - + + * Full Name + + + + * Zip Code/Postcode + + + + * Address + + + + * Town/City + + + + * Contact Number + +
-
{/* ********************************* Payement section****************** */}
- - 2. Pyement Selection - - 1 - 1 - 1 - 1 - 1 - 2 - 2 + + + {" "} + 2. Pyement Selection{" "} + + + 1 + 1 + 1 + 1 + 1 + 2 + 2 - * Card Number - - * Name on card - - * Expiry Date + + * Card Number + + + + * Name on card + + + + * Expiry Date + - - @@ -131,7 +373,7 @@ const Checkout = () => { - @@ -153,59 +395,111 @@ const Checkout = () => { - * Security Code (CV2) - - + + * Security Code (CV2) + + +
{/* ***********total item box*********** */} - - Order Summary + + + Order Summary + {`Total Items ${cartItems.length}`} {`$${cartTotal}`} {` Taxes and duties : $18.5`} - {` Amount To Pay : $${cartTotal == 0 ? 0 : cartTotal + 18.5}`} - + {` Amount To Pay : $${ + cartTotal == 0 ? 0 : cartTotal + 18.5 + }`} + - - + - - - - -