diff --git a/src/Components/CartProgress.js b/src/Components/CartProgress.js
new file mode 100644
index 00000000..740eb03b
--- /dev/null
+++ b/src/Components/CartProgress.js
@@ -0,0 +1,103 @@
+import React from "react";
+
+import LinearProgress from "@material-ui/core/LinearProgress";
+import Box from "@material-ui/core/Box";
+import Grid from "@material-ui/core/Grid";
+
+const totalPrice = (context, deliveryFee, discount) =>
+ (
+ Number(context.cartTotal.totalPrice) +
+ Number(deliveryFee) -
+ Number(discount)
+ ).toFixed(2);
+
+const LinearProgressWithLabel = (props) =>
+
+
+
+
+ ;
+
+const ProgressIndicator = ({ totalPrice, targetValue, name }) =>
+
+ {targetValue > totalPrice ? (
+
+
+ ${(targetValue - totalPrice).toFixed(2)} to {name.toLowerCase()}
+
+
+
+
+
+ ) : (
+
{name} Met!
+ )}
+
+
+export default ({context, deliveryFee, discount}) => <>
+ {context.channel === "delivery" ? <>
+ {context.pageData.minimum_order && context.pageData.minimum_order !== "0" ? (
+
+ ) : null}
+ {context.pageData.free_delivery && context.pageData.free_delivery !== "0" ? (
+
+ ) : null}
+
+ {(context.delivery_option === "none" ||
+ !context.delivery_option) && (
+
DELIVERY FEES NOT INCLUDED
+ )}
+ {(context.delivery_option === "fixed" ||
+ context.delivery_option === "distance") &&
+ context.delivery_fee !== undefined && (
+
+ DELIVERY FEES:
+
+
${deliveryFee.toFixed(2)}
+
+
+ )}
+
+ > : null}
+ {(context.all_promo || context.selfcollect_promo) && discount > 0 ? (
+
+ ) : null}
+
+
SUBTOTAL
+
+ {(context.delivery_option === "none" ||
+ context.channel === "collect" ||
+ (
+ (context.delivery_option === "fixed" || context.delivery_option === "distance") &&
+ context.channel === "delivery" &&
+ context.delivery_fee !== undefined
+ )) && (
+
${totalPrice(context, deliveryFee, discount)}
+ )}
+
+
+>
\ No newline at end of file
diff --git a/src/Components/PageCart.js b/src/Components/PageCart.js
index 88aac86e..a27bc0ce 100644
--- a/src/Components/PageCart.js
+++ b/src/Components/PageCart.js
@@ -2,13 +2,11 @@ import React from "react";
import PropTypes from "prop-types";
import CartProduct from "./PageCartProduct";
+import CartProgress from "./CartProgress";
import { CartContext } from "./themeContext";
import "./style.scss";
import Slide from "@material-ui/core/Slide";
import Component from "./index";
-import LinearProgress from "@material-ui/core/LinearProgress";
-import Box from "@material-ui/core/Box";
-import Grid from "@material-ui/core/Grid";
import Dialog from "@material-ui/core/Dialog";
import DialogContent from "@material-ui/core/DialogContent";
import DialogContentText from "@material-ui/core/DialogContentText";
@@ -23,16 +21,6 @@ const Transition = React.forwardRef(function Transition(props, ref) {
return ;
});
-function LinearProgressWithLabel(props) {
- return (
-
-
-
-
-
- );
-}
-
const PromoCodeDialog = (props) => {
const theme = useTheme();
const fullScreen = useMediaQuery(theme.breakpoints.down("sm"));
@@ -167,7 +155,7 @@ class PageCart extends React.Component {
classes.push("float-cart--open");
}
- const delivery_fee =
+ const deliveryFee =
(cartTotal.totalPrice <= this.context.pageData.free_delivery ||
this.context.pageData.free_delivery === "0") && this.context.delivery_fee
? Number(this.context.delivery_fee)
@@ -195,18 +183,6 @@ class PageCart extends React.Component {
discount = discount.toFixed(2);
- var totalPrice =
- Number(this.context.cartTotal.totalPrice) +
- Number(delivery_fee) -
- Number(discount);
-
- console.log(
- Number(this.context.cartTotal.totalPrice),
- Number(delivery_fee),
- Number(discount)
- );
- totalPrice = totalPrice.toFixed(2);
-
return (
{/* If cart open, show close (x) button */}
@@ -311,135 +287,7 @@ class PageCart extends React.Component {
)}
-
- {this.context.pageData.minimum_order &&
- this.context.pageData.minimum_order !== "0" &&
- this.context.channel === "delivery" ? (
-
- {this.context.pageData.minimum_order - cartTotal.totalPrice >
- 0 ? (
-
-
-
- $
- {this.context.pageData.minimum_order -
- cartTotal.totalPrice}{" "}
- to minimum amount
-
-
-
-
-
-
- ) : (
-
-
-
Minimum Amount Met!
-
-
- )}
-
- ) : null}
-
-
- {this.context.pageData.free_delivery &&
- this.context.pageData.free_delivery !== "0" &&
- this.context.channel === "delivery" ? (
-
- {this.context.pageData.free_delivery - cartTotal.totalPrice >
- 0 ? (
-
-
-
- $
- {this.context.pageData.free_delivery -
- cartTotal.totalPrice}{" "}
- to free delivery
-
-
-
-
-
-
- ) : (
-
-
-
Free Delivery Met!
-
-
- )}
-
- ) : null}
-
- {this.context.channel === "delivery" ? (
-
- {(this.context.delivery_option === "none" ||
- !this.context.delivery_option) && (
-
DELIVERY FEES NOT INCLUDED
- )}
- {(this.context.delivery_option === "fixed" ||
- this.context.delivery_option === "distance") &&
- this.context.delivery_option &&
- this.context.delivery_fee !== undefined && (
-
- DELIVERY FEES:
-
-
- )}
-
- ) : null}
- {(this.context.all_promo || this.context.selfcollect_promo) &&
- discount > 0 ? (
-
- ) : null}
-
-
SUBTOTAL
-
- {(this.context.delivery_option === "none" ||
- this.context.channel === "collect") && (
-
${totalPrice}
- )}
- {(this.context.delivery_option === "fixed" ||
- this.context.delivery_option === "distance") &&
- this.context.channel === "delivery" &&
- this.context.delivery_fee !== undefined && (
-
${totalPrice}
- )}
-
-
+
{this.context.promo_code ? (