aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--thallium-frontend/src/components/CartStatus.tsx12
1 files changed, 12 insertions, 0 deletions
diff --git a/thallium-frontend/src/components/CartStatus.tsx b/thallium-frontend/src/components/CartStatus.tsx
new file mode 100644
index 0000000..338e2cb
--- /dev/null
+++ b/thallium-frontend/src/components/CartStatus.tsx
@@ -0,0 +1,12 @@
+import { useSelector } from "react-redux";
+import { RootState } from "../store";
+
+const CartStatus = () => {
+ const cart = useSelector((state: RootState) => state.cart);
+ const total = cart.cart.reduce((acc, item) => acc + item.quantity, 0);
+ const price = cart.cart.reduce((acc, item) => acc + (parseFloat(item.estPrice) * item.quantity), 0);
+
+ return <p>You currently have {total} items in your cart, totalling ${price.toFixed(2)} USD</p>;
+};
+
+export default CartStatus;