Skip to content

Commit

Permalink
Revert "order page form integration"
Browse files Browse the repository at this point in the history
This reverts commit 2f7eefe.
  • Loading branch information
vijay-murugeasan committed Jan 5, 2024
1 parent 2f7eefe commit a308f5e
Show file tree
Hide file tree
Showing 11 changed files with 67 additions and 19,468 deletions.
19,190 changes: 0 additions & 19,190 deletions package-lock.json

This file was deleted.

Binary file removed public/img/emptyCart.png
Binary file not shown.
18 changes: 5 additions & 13 deletions src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import Error from "./ui/Error";
import Order from "./features/order/Order";
import SpinnerFullPage from "./ui/SpinnerFullPage";
import ThankYou from "./features/order/ThankYou";
import EmptyCart from "./features/order/EmptyCart";

const Home = lazy(() => import("./pages/Home"));
const Contact = lazy(() => import("./pages/Contact"));
Expand All @@ -38,10 +37,6 @@ function App() {

const length = Object.keys(position).length;

const cart = useSelector((state) => state.cart.cart);

const isCart = cart.length;

const router = createBrowserRouter([
{
path: "/",
Expand Down Expand Up @@ -88,14 +83,11 @@ function App() {
},
{
path: "/order",
element:
isCart > 0 ? (
<Suspense fallback={<SpinnerFullPage />}>
<Order />
</Suspense>
) : (
<EmptyCart />
),
element: (
<Suspense fallback={<SpinnerFullPage />}>
<Order />
</Suspense>
),
},
{
path: "/thank-you",
Expand Down
10 changes: 3 additions & 7 deletions src/features/cart/Cart.jsx
Original file line number Diff line number Diff line change
@@ -1,22 +1,18 @@
import { useEffect, useState } from "react";
import { Link, useLocation } from "react-router-dom";

import StickyBox from "react-sticky-box";
import CartItems from "./CartItems";

function Cart({ height, isSubmitted = null, setIsSubmitted = null }) {
function Cart({ height }) {
const IsMobile = window.screen.width < 800;
const [isShow, setIsShow] = useState(false);
const style = isShow ? { zIndex: "99999" } : {};
return (
<div className="col-lg-4" id="sidebar_fixed" style={style}>
{!IsMobile && (
<StickyBox offsetTop={height} offsetBottom={20}>
<CartItems
isShow={isShow}
handleShow={setIsShow}
isSubmitted={isSubmitted}
setIsSubmitted={setIsSubmitted}
/>
<CartItems isShow={isShow} handleShow={setIsShow} />
</StickyBox>
)}
{IsMobile && <CartItems isShow={isShow} handleShow={setIsShow} />}
Expand Down
33 changes: 8 additions & 25 deletions src/features/cart/CartItems.jsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { useState } from "react";
import { Link, useLocation } from "react-router-dom";
import { useDispatch, useSelector } from "react-redux";

Expand All @@ -7,14 +8,8 @@ import {
getTotalCartPrice,
} from "../../services/redux/CartSlice";
import { formatCurrency } from "../../utils/helpers";
import "../../assets/css/detail-page.css";
function CartItems({
height,
isShow,
handleShow,
isSubmitted,
setIsSubmitted,
}) {

function CartItems({ height, isShow, handleShow }) {
const cart = useSelector(getCart);
const { pathname } = useLocation();

Expand All @@ -28,6 +23,7 @@ function CartItems({
e.preventDefault();
handleShow(!isShow);
}

return (
<>
<div
Expand Down Expand Up @@ -71,28 +67,15 @@ function CartItems({
Delivery fee <span>{formatCurrency(deliveryFee)}</span>
</li>
<li className="total">
Total
Total{" "}
<span>{formatCurrency(totalCartItemPrice + deliveryFee)} </span>
</li>
</ul>

<div className="btn_1_mobile">
{orderPath && (
<button
className="btn_1 gradient full-width mb_5"
onClick={() => {
setIsSubmitted(true);
}}
// disabled={!isSubmitted}
>
Order Now
</button>
)}
{!orderPath && (
<Link to={url} className="btn_1 gradient full-width mb_5">
{orderBtnText}
</Link>
)}
<Link to={url} className="btn_1 gradient full-width mb_5">
{orderBtnText}
</Link>
<div className="text-center">
<small>No money charged on this steps </small>
</div>
Expand Down
13 changes: 4 additions & 9 deletions src/features/cart/HeaderCartItems.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,21 +36,16 @@ function HeaderCartItems({ cart, setShowCart }) {
<strong>Total </strong>
<span>{formatCurrency(totalCartItemPrice)} </span>
</div>
{/* <Link
to="/order"
className="btn_1 outline"
onClick={() => setShowCart(false)}
>
View Cart
</Link> */}
<Link
to="/order"
className="btn_1"
className="btn_1 outline"
onClick={() => setShowCart(false)}
style={{ color: "#fff" }}
>
View Cart
</Link>
<Link to="/order" className="btn_1" onClick={() => setShowCart(false)}>
Checkout
</Link>
</div>
</>
);
Expand Down
32 changes: 0 additions & 32 deletions src/features/order/EmptyCart.jsx

This file was deleted.

14 changes: 2 additions & 12 deletions src/features/order/Order.jsx
Original file line number Diff line number Diff line change
@@ -1,26 +1,16 @@
import Cart from "../cart/Cart";
import "../../assets/css/order-sign_up.css";
import OrderForm from "./OrderForm";
import { useState } from "react";

function Order() {
const [isSubmitted, setIsSubmitted] = useState(false);
console.log("order", isSubmitted);
return (
<main className="bg_gray">
<div className="container margin_60_20">
<div className="row justify-content-center">
<div className="col-xl-6 col-lg-8">
<OrderForm
isSubmitted={isSubmitted}
setIsSubmitted={setIsSubmitted}
/>
<OrderForm />
</div>
<Cart
height="30"
isSubmitted={isSubmitted}
setIsSubmitted={setIsSubmitted}
/>
<Cart height="30" />
</div>
</div>
</main>
Expand Down
Loading

0 comments on commit a308f5e

Please sign in to comment.