diff --git a/kente-krafters/src/components/ProductCard.jsx b/kente-krafters/src/components/ProductCard.jsx
index 70f4375..69f609e 100644
--- a/kente-krafters/src/components/ProductCard.jsx
+++ b/kente-krafters/src/components/ProductCard.jsx
@@ -5,7 +5,7 @@
* content of the product card.
*/
export function ProductCard({
- id,
+ product_id,
product_name,
description,
price,
@@ -14,7 +14,10 @@ export function ProductCard({
seller_email,
}) {
return (
-
+
{product_name} by {seller_email}
-
- {description}
-
+
{description}
${price}
diff --git a/kente-krafters/src/pages/auth/login/Login.jsx b/kente-krafters/src/pages/auth/login/Login.jsx
index a3ac5c2..188f724 100644
--- a/kente-krafters/src/pages/auth/login/Login.jsx
+++ b/kente-krafters/src/pages/auth/login/Login.jsx
@@ -42,7 +42,7 @@ const Login = () => {
console.log(response);
if (response == true) {
// redirect to the homepage
- window.location.href = "/landing";
+ window.location.href = "/";
}
});
};
diff --git a/kente-krafters/src/pages/cart.jsx b/kente-krafters/src/pages/cart.jsx
new file mode 100644
index 0000000..ead0444
--- /dev/null
+++ b/kente-krafters/src/pages/cart.jsx
@@ -0,0 +1,148 @@
+import { useState } from "react";
+
+const Cart = () => {
+ const [quantity, setQuantity] = useState(1);
+ const [selectedSize, setSelectedSize] = useState("2-Yards"); // Default size
+ const [cart, setCart] = useState([]);
+
+ const handleSizeChange = (size) => {
+ setSelectedSize(size);
+ };
+
+ const handleQuantityChange = (amount) => {
+ setQuantity((prevQuantity) => Math.max(1, prevQuantity + amount));
+ };
+
+ const handleDeleteFromCart = (productId) => {
+ console.log("Deleting product with ID:", productId);
+
+ const updatedCart = cart.filter((product) => product.id !== productId);
+ console.log("Updated Cart:", updatedCart);
+
+ setCart(updatedCart);
+ };
+
+ const handleAddToCart = (product) => {
+ const updatedCart = [
+ ...cart,
+ {
+ id: product.id,
+ name: product.name,
+ price: product.price,
+ quantity,
+ size: selectedSize,
+ },
+ ];
+ setCart(updatedCart);
+ // Clear quantity for the next product
+ setQuantity(1);
+ };
+
+ const calculateTotal = () => {
+ return cart.reduce(
+ (total, product) => total + product.price * product.quantity,
+ 0
+ );
+ };
+
+ const products = [
+ {
+ id: 1,
+ name: "Woven Kente Graduation Stole",
+ price: 300,
+ imageSrc: "heroImage1", // Replace with your actual image source
+ },
+ {
+ id: 2,
+ name: "Product 2",
+ price: 150,
+ imageSrc: "heroImage2", // Replace with your actual image source
+ },
+ {
+ id: 3,
+ name: "Product 3",
+ price: 200,
+ imageSrc: "heroImage3", // Replace with your actual image source
+ },
+ ];
+
+ return (
+
+ {products.map((product) => (
+
+
+
+
+
+
+
+ {product.name}
+
+
+ Size: {selectedSize}
+
+
+
+
Quantity
+
+
+
+
+
+
+
+
+
+ ${product.price}
+
+
+
+
+ ))}
+ {/* Total Display */}
+
+
Total:
+
${calculateTotal()}
+
+ {/* Single "Pay Now" Button */}
+
+
+
+
+ );
+};
+
+export default Cart;
diff --git a/kente-krafters/src/pages/checkout.jsx b/kente-krafters/src/pages/checkout.jsx
index ea5d84f..0cf1af0 100644
--- a/kente-krafters/src/pages/checkout.jsx
+++ b/kente-krafters/src/pages/checkout.jsx
@@ -10,12 +10,32 @@ import { baseEndPoint } from "../../expressAPI/data";
const CheckOut = () => {
// get the product id from the header parameters from the url
const productId = window.location.pathname.split("/")[2];
+
// get the product data from the backend
const [product, setProduct] = useState({});
+ // useEffect(() => {
+ // // fetch the product data from the backend
+ // const fetchProduct = async () => {
+ // try {
+ // const response = await axios.get(
+ // `${baseEndPoint}product/${productId}`
+ // );
+ // const responseData =
+ // typeof response.data === "string"
+ // ? JSON.parse(response.data)
+ // : response.data;
+ // setProduct(responseData);
+ // } catch (error) {
+ // console.error("Error fetching product:", error);
+ // }
+ // };
+
+ // fetchProduct();
+ // },
useEffect(() => {
- // fetch the product data from the backend
const fetchProduct = async () => {
try {
+ console.log("Fetching product with ID:", productId);
const response = await axios.get(
`${baseEndPoint}product/${productId}`
);
@@ -35,7 +55,7 @@ const CheckOut = () => {
return (
- {product && (
+ {product && product[0] && (
{
- {product && product[0].product_name}
+ {product && product[0] && product[0].product_name}
Graduation Stoles, Gifts, and Decoration
@@ -54,10 +74,10 @@ const CheckOut = () => {
- $ {product && product[0].price}
+ $ {product && product[0] && product[0].price}
- {product && product[0].description}
+ {product && product[0] && product[0].description}
size
diff --git a/kente-krafters/src/pages/kente.jsx b/kente-krafters/src/pages/kente.jsx
index 5f0854b..ec9734b 100644
--- a/kente-krafters/src/pages/kente.jsx
+++ b/kente-krafters/src/pages/kente.jsx
@@ -2,6 +2,7 @@ import { useState, useEffect } from "react";
import { ProductCard } from "../components/ProductCard";
import { baseEndPoint } from "../../expressAPI/data";
import axios from "axios";
+import { NavLink } from "react-router-dom";
export default function KenteShopping() {
const handleButtonClick = () => {
@@ -27,7 +28,12 @@ export default function KenteShopping() {
<>
{products.map((product) => (
-
+
+
+
))}