diff --git a/build/1.51d47afc6e300b87b054.jpeg b/build/1.51d47afc6e300b87b054.jpeg
deleted file mode 100644
index 0ceffc6..0000000
Binary files a/build/1.51d47afc6e300b87b054.jpeg and /dev/null differ
diff --git a/src/components/MainPageProducts.jsx b/src/components/MainPageProducts.jsx
index c80ce91..4d4b42d 100644
--- a/src/components/MainPageProducts.jsx
+++ b/src/components/MainPageProducts.jsx
@@ -44,6 +44,7 @@ const MainPageProducts=()=>{
const [brands,setBrands]=useState([])
const [search,setSearch]=useState(false)
const [searchPage,setSearchPage]=useState(1)
+
@@ -221,10 +222,10 @@ const MainPageProducts=()=>{
onClick={() => navigate(`/productPage/${data._id}`)}
className="font-Lexend cursor-pointer sm:max-md:text-[12px] xs:max-sm:text-[10px] text-gray-800"
/>
-
-
${data.price}
- {carted ?
View in cart
:
dispatch(addItemToCartAsync({ product: data, quantity: 1 }))} className="text-md border-2 cursor-pointer rounded-md py-2 sm:max-md:text-xs xs:max-sm:text-xs font-Abel text-center border-gray-300">Add to cart
}
+
${data.options[0]?.price}
+ {carted ?
View in cart
:
dispatch(addItemToCartAsync({ product: { ...data, option:{id: data.options[0].id,price:data.options[0].price} }, quantity: 1 }))} className="text-md border-2 cursor-pointer rounded-md py-2 sm:max-md:text-xs xs:max-sm:text-xs font-Abel text-center border-gray-300">Add to cart
}
diff --git a/src/components/MainProductCarousal.jsx b/src/components/MainProductCarousal.jsx
index 21dab1a..8060f3a 100644
--- a/src/components/MainProductCarousal.jsx
+++ b/src/components/MainProductCarousal.jsx
@@ -159,10 +159,10 @@ const MainProductCarousal=()=>{
onClick={()=>{window.location.href=`/productPage/${data._id}`}}
className="font-Lexend cursor-pointer text-gray-800"
/>
-
-
${data.price}
- {carted ?
View in cart
:
dispatch(addItemToCartAsync({product:data,quantity:1}))} className="text-md border-2 cursor-pointer rounded-md py-2 sm:max-md:text-xs xs:max-sm:text-xs font-Abel text-center border-gray-300">Add to cart
}
+
${data.options[0]?.price}
+ {carted ?
View in cart
:
dispatch(addItemToCartAsync({ product: { ...data, option:{id: data.options[0].id,price:data.options[0].price}}}))} className="text-md border-2 cursor-pointer rounded-md py-2 sm:max-md:text-xs xs:max-sm:text-xs font-Abel text-center border-gray-300">Add to cart
}
diff --git a/src/components/SearchComponent.jsx b/src/components/SearchComponent.jsx
index 424dd7d..f70ca40 100644
--- a/src/components/SearchComponent.jsx
+++ b/src/components/SearchComponent.jsx
@@ -150,7 +150,7 @@ const SearchComponent = ({ isMobile }) => {
className="my-auto font-Abel cursor-pointer"
/>
-
-
{data.brand}
+
{data?.brand}
{ navigate(`/productPage/${data._id}`); }}
className="font-Lexend cursor-pointer xs:max-sm:text-[10px] text-gray-800"
>
{data.name}
-
150 Grams
+
{data?.options[0].option}
- ${data.price}
+ ${data.options[0].price}
{carted ? (
{
) : (
dispatch(addItemToCartAsync({ product: data, quantity: 1 }))}
+ onClick={() => dispatch(addItemToCartAsync({ product: { ...data, option:{id: data.options[0].id,price:data.options[0].price}}}))}
className="text-md border-2 cursor-pointer rounded-md py-2 sm:max-md:text-xs xs:max-sm:text-xs font-Abel text-center border-gray-300"
>
Add to cart
diff --git a/src/scenes/CategoryPage.jsx b/src/scenes/CategoryPage.jsx
index 9bbc153..b33ddbf 100644
--- a/src/scenes/CategoryPage.jsx
+++ b/src/scenes/CategoryPage.jsx
@@ -105,10 +105,10 @@ const CategoryPage = () => {
>
{data.name}
-
150 Grams
+
{data.options[0].option}
- ${data.price}
+ ${data.options[0].price}
{carted ? (
{
) : (
dispatch(addItemToCartAsync({ product: data, quantity: 1 }))}
+ onClick={() => dispatch(addItemToCartAsync({ product: { ...data, option:{id: data.options[0].id,price:data.options[0].price}}}))}
className="text-md border-2 cursor-pointer rounded-md py-2 sm:max-md:text-xs xs:max-sm:text-xs font-Abel text-center border-gray-300"
>
Add to cart
diff --git a/src/scenes/NavBar.jsx b/src/scenes/NavBar.jsx
index 177e8d7..694d026 100644
--- a/src/scenes/NavBar.jsx
+++ b/src/scenes/NavBar.jsx
@@ -298,10 +298,10 @@ const NavBar=()=>{
Children's Health
window.location.href='/category/Children-vitamins'} className="font-Livvic cursor-pointer hover:underline text-sm">Children's Multivitamins
-
window.location.href='/category/Childern-supplements'} className="font-Livvic cursor-pointer hover:underline text-sm">Children's Supplements
+
window.location.href='/category/Children-supplements'} className="font-Livvic cursor-pointer hover:underline text-sm">Children's Supplements
window.location.href='/category/Children-digestive-supplements'} className="font-Livvic cursor-pointer hover:underline text-sm">Children's Digestive Support
window.location.href='/category/Children-immune-supplements'} className="font-Livvic cursor-pointer hover:underline text-sm">Children's Immune Support
-
window.location.href='/category/Childern-supplements'} className="font-Livvic cursor-pointer hover:underline text-sm">Shop All
+
window.location.href='/category/Children-supplements'} className="font-Livvic cursor-pointer hover:underline text-sm">Shop All
@@ -337,7 +337,7 @@ const NavBar=()=>{
Probiotics
window.location.href='/category/Women-probiotics'} className="font-Livvic cursor-pointer hover:underline text-sm">Women's Probiotics
window.location.href='/category/Men-probiotics'} className="font-Livvic cursor-pointer hover:underline text-sm">Men's Probiotics
-
window.location.href='/category/Childern-probiotics'} className="font-Livvic cursor-pointer hover:underline text-sm">Children's Probiotics
+
window.location.href='/category/Children-probiotics'} className="font-Livvic cursor-pointer hover:underline text-sm">Children's Probiotics
window.location.href='/category/Probiotics'} className="font-Livvic cursor-pointer hover:underline text-sm">Shop All
diff --git a/src/scenes/Order.jsx b/src/scenes/Order.jsx
index 2888811..cd65b8c 100644
--- a/src/scenes/Order.jsx
+++ b/src/scenes/Order.jsx
@@ -488,7 +488,7 @@ const Order=()=>{
maxLength={15}
className="font-Poppins text-xs underline text-emerald-500"
/>
-
{data.options}
+
{data.option}
diff --git a/src/scenes/ProductPage.jsx b/src/scenes/ProductPage.jsx
index 6469d4d..26e5782 100644
--- a/src/scenes/ProductPage.jsx
+++ b/src/scenes/ProductPage.jsx
@@ -30,6 +30,7 @@ const ProductPage=()=>{
const [quantity,setQuantity]=useState(1)
const cartItems=useSelector((state)=>state.cartItems)
const {productId}=useParams();
+ const [selectedOption,setSelectedOption]=useState(null)
const [carted,setCarted] = useState(false);
@@ -37,7 +38,10 @@ const ProductPage=()=>{
const fetchProduct=async ()=>{
await fetch(`${process.env.REACT_APP_API_URL}/products/id/${productId}`,{
method:'GET'
- }).then((response)=>response.json()).then((data)=>{setProduct(data); })
+ }).then((response)=>response.json()).then((data)=>{setProduct(data);
+ setSelectedOption({id:0,...data.options[0]})
+
+ })
}
@@ -63,7 +67,7 @@ const ProductPage=()=>{
const handleAddToCart = () => {
const productToDispatch = {
name: product.name,
- price: product.price,
+ option:selectedOption,
productImage: product.productImage,
_id: product._id,
};
@@ -103,7 +107,7 @@ if (foundItem) {
-
+
{isLoading ?
@@ -111,7 +115,7 @@ if (foundItem) {
:
@@ -189,10 +193,18 @@ if (foundItem) {
:
-
-
{product.options}
+
+ {
+ Array.isArray(product.options)&& product.options.map((data,index)=>(
+
{setSelectedOption({id:index,...product.options[index]})}} className={`px-4 cursor-pointer py-2 border-2 border-black w-auto rounded-full ${Number(selectedOption.price)===Number(data.price)?'bg-gray-100':'bg-white'}`}>
+
{data.option}
+
+ ))
+ }
+
+
}
@@ -213,7 +225,7 @@ if (foundItem) {
:
-
+
}
diff --git a/src/state/index.js b/src/state/index.js
index 829f1cb..fbfb95e 100644
--- a/src/state/index.js
+++ b/src/state/index.js
@@ -16,7 +16,7 @@ const initialState = {
const state = getState();
if (state.accessToken) {
- api.get(`/cart/create/${product._id}/${quantity?quantity:1}`)
+ api.get(`/cart/create/${product._id}/${quantity?quantity:1}?option=${product.option.id}`)
.then((response)=>{
if (response.status === 201) {
diff --git a/src/widget/Cart.jsx b/src/widget/Cart.jsx
index bbfd264..d1d1e94 100644
--- a/src/widget/Cart.jsx
+++ b/src/widget/Cart.jsx
@@ -53,10 +53,10 @@ const Cart=()=>{
useEffect(() => {
-
+ console.log(cartItems)
// Calculate individual total prices when the cart changes
const individualTotals = cartItems.map((item) => {
- const individualTotal = item.price * item.quantity;
+ const individualTotal = item?.option?.price * item.quantity;
return individualTotal;
});
@@ -147,7 +147,7 @@ const Cart=()=>{
className="font-Poppins text-xs underline text-emerald-500"
/>
-
{data.options}
+
{data?.option?.option}
@@ -168,7 +168,7 @@ const Cart=()=>{
-
${data.price}
+
${data?.option?.price}
diff --git a/src/widget/CategoriesWidget.jsx b/src/widget/CategoriesWidget.jsx
index 8e9e7ca..0fffc96 100644
--- a/src/widget/CategoriesWidget.jsx
+++ b/src/widget/CategoriesWidget.jsx
@@ -118,10 +118,10 @@ const Categories=()=>{
Children's Health
window.location.href='/category/Children-vitamins'} className="font-Livvic cursor-pointer hover:underline text-sm">Children's Multivitamins
-
window.location.href='/category/Childern-supplements'} className="font-Livvic cursor-pointer hover:underline text-sm">Children's Supplements
+
window.location.href='/category/Children-supplements'} className="font-Livvic cursor-pointer hover:underline text-sm">Children's Supplements
window.location.href='/category/Children-digestive-supplements'} className="font-Livvic cursor-pointer hover:underline text-sm">Children's Digestive Support
window.location.href='/category/Children-immune-supplements'} className="font-Livvic cursor-pointer hover:underline text-sm">Children's Immune Support
-
window.location.href='/category/Childern-supplements'} className="font-Livvic cursor-pointer hover:underline text-sm">Shop All
+
window.location.href='/category/Children-supplements'} className="font-Livvic cursor-pointer hover:underline text-sm">Shop All
@@ -157,7 +157,7 @@ const Categories=()=>{
Probiotics
window.location.href='/category/Women-probiotics'} className="font-Livvic cursor-pointer hover:underline text-sm">Women's Probiotics
window.location.href='/category/Men-probiotics'} className="font-Livvic cursor-pointer hover:underline text-sm">Men's Probiotics
-
window.location.href='/category/Childern-probiotics'} className="font-Livvic cursor-pointer hover:underline text-sm">Children's Probiotics
+
window.location.href='/category/Children-probiotics'} className="font-Livvic cursor-pointer hover:underline text-sm">Children's Probiotics
window.location.href='/category/Probiotics'} className="font-Livvic cursor-pointer hover:underline text-sm">Shop All
diff --git a/src/widget/SimiliarProducts.jsx b/src/widget/SimiliarProducts.jsx
index 912367f..5b36423 100644
--- a/src/widget/SimiliarProducts.jsx
+++ b/src/widget/SimiliarProducts.jsx
@@ -62,9 +62,9 @@ const SimiliarProducts=()=>{
className="font-Lexend xs:max-sm:text-[10px] cursor-pointer text-gray-800"
/>
-