diff --git a/src/Checkout.css b/src/Checkout.css index 0d17a97..acc2e0d 100644 --- a/src/Checkout.css +++ b/src/Checkout.css @@ -19,3 +19,13 @@ padding: 10px; border-bottom: 1px solid lightgray; } + +.checkout__right{ + position: fixed; + right: 0; + margin-right: 10px; +} + +.subtotal-calculate { + margin-left: 47rem; +} \ No newline at end of file diff --git a/src/Checkout.js b/src/Checkout.js index fc16274..a86d889 100644 --- a/src/Checkout.js +++ b/src/Checkout.js @@ -1,53 +1,70 @@ +/* eslint-disable no-unused-vars */ import React from 'react' import './Checkout.css' import Subtotal from "./Subtotal"; import CheckoutProduct from './CheckoutProduct'; -import{useStateValue} from './StateProvider'; +import { getBasketTotal } from "./reducer"; +import { useStateValue } from './StateProvider'; import FlipMove from 'react-flip-move'; +import CurrencyFormat from "react-currency-format"; -function Checkout() { - const[{basket,user},dispatch]=useStateValue(); +function Checkout({ price }) { + const [{ basket, user }, dispatch] = useStateValue(); - const Finalproducts=({basket})=>( + const Finalproducts = ({ basket }) => ( - {basket.map(article => ( -
- ))} - + {basket.map(article => ( +
+ ))} + ); - - return (
- +
- Checkout Add + {/*Checkout Add*/}

Hello, {user?.email}

Your Shopping Basket

- - {/*This will send all the products we are adding in our basket to the shopping list using the basket variable*/} - {basket.map((item)=>( + + {/*This will send all the products we are adding in our basket to the shopping list using the basket variable*/} + {basket.map((item) => ( - ))} - + ))}
+ +

+ + {/*The Subtotal that is printed below !*/} + ( + <> +

+ Subtotal ({basket.length} items) : {value} +

+ + )} + decimalScale={2} + value={getBasketTotal(basket)} + displayType={"text"} + thousandSeprator={true} + prefix={"Rs "} + />
+
- +
- -
) } -export default Checkout +export default Checkout \ No newline at end of file diff --git a/src/CheckoutProduct.css b/src/CheckoutProduct.css index 9926c28..f93d71f 100644 --- a/src/CheckoutProduct.css +++ b/src/CheckoutProduct.css @@ -29,4 +29,25 @@ .checkoutProduct__title { font-size: 17px; font-weight: 800; + float: left; + width: 600px; } + +.checkoutproduct__rating{ + position: relative; + right: 0; + margin-right: 10px; +} + +.checkout_Alignment{ + display: inline-block; + margin: auto; + margin: auto; +} + +.checkoutproduct__price{ + text-align: left; + float: left; + width: 200px; + margin-left: 5rem; +} \ No newline at end of file diff --git a/src/CheckoutProduct.js b/src/CheckoutProduct.js index da020d8..4172db1 100644 --- a/src/CheckoutProduct.js +++ b/src/CheckoutProduct.js @@ -1,49 +1,41 @@ +/* eslint-disable no-unused-vars */ import React from 'react' import "./CheckoutProduct.css"; -import {useStateValue} from './StateProvider'; +import { useStateValue } from './StateProvider'; - -function CheckoutProduct({id,image,title,price,rating,reviews}) { - const[{basket},dispatch]=useStateValue(); - - const removeFromBasket=()=>{ +function CheckoutProduct({ id, image, title, price, rating, reviews }) { + const [{ basket }, dispatch] = useStateValue(); + const removeFromBasket = () => { dispatch({ - type:'REMOVE_FROM_BASKET', - id:id, + type: 'REMOVE_FROM_BASKET', + id: id, }) } - - + return ( -
Checkout Product -
-

{title}

-

- Rs - {price} -

-
- - - - {Array(rating) - .fill() - .map((_,i)=>( -

- ))} - ({reviews}) -
- +
+
+
{title}
+
+ Rs + {price} +
+
-
- +
+ {Array(rating) + .fill() + .map((_, i) => ( +

+ ))} + ({reviews}) +
+ +
- ) } export default CheckoutProduct - - \ No newline at end of file diff --git a/src/Subtotal.js b/src/Subtotal.js index f2b0fd2..3f78648 100644 --- a/src/Subtotal.js +++ b/src/Subtotal.js @@ -1,39 +1,37 @@ +/* eslint-disable no-unused-vars */ import React from 'react' import './Subtotal.css' import CurrencyFormat from "react-currency-format"; -import {useStateValue} from './StateProvider'; -import {getBasketTotal} from "./reducer"; -import {useHistory} from "react-router-dom"; +import { useStateValue } from './StateProvider'; +import { getBasketTotal } from "./reducer"; +import { useHistory } from "react-router-dom"; + function Subtotal() { //provide browser history - const history=useHistory(); - const[{basket},dispatch]=useStateValue(); + const history = useHistory(); + const [{ basket }, dispatch] = useStateValue(); return (
{/*For rendering the money*/} - ( - <> -

- Subtotal({basket.length} items):{value} - -

- - This order contains a gift - - )} - decimalScale={2} - value={getBasketTotal(basket)} - displayType={"text"} - thousandSeprator={true} - prefix={"Rs"} - /> - - - + ( + <> +

+ Subtotal({basket.length} items) : {value} +

+ + This order contains a gift + + )} + decimalScale={2} + value={getBasketTotal(basket)} + displayType={"text"} + thousandSeprator={true} + prefix={"Rs "} + /> +
); } export default Subtotal; -