diff --git a/src/Components/HOC/CartWithDrawer.tsx b/src/Components/HOC/CartWithDrawer.tsx
index 1676092..2cea1d0 100644
--- a/src/Components/HOC/CartWithDrawer.tsx
+++ b/src/Components/HOC/CartWithDrawer.tsx
@@ -19,14 +19,18 @@ const CartWithDrawer = () => {
const { t } = useTranslation();
const { Cart, calculateTotalPrice, calculateTotalQuantity, removeCart } =
useCartState();
- const { user } = useAuthState();
+ const { user ,isAuthenticated} = useAuthState();
const { mutate, isLoading, isSuccess } = useAddOrder();
const products = Cart?.map((item: any) => ({
quantity: item?.quantity,
id: item?.id,
}));
-
+
const addOrder = () => {
+ if (!isAuthenticated) {
+ toast.error("sorry you need to be authenticated");
+ return;
+ }
mutate({
email: user?.email,
products: products,
diff --git a/src/Components/Home/BestSale.tsx b/src/Components/Home/BestSale.tsx
index 9fab39d..d6e55e1 100644
--- a/src/Components/Home/BestSale.tsx
+++ b/src/Components/Home/BestSale.tsx
@@ -1,6 +1,7 @@
import { useNavigate } from "react-router-dom";
import { useTranslation } from "react-i18next";
import ProductSwiper from "./ProductSwiper";
+import { useGetBaseProduct } from "../../api/baseProduct";
const Products = () => {
const {t} = useTranslation();
@@ -9,6 +10,10 @@ const Products = () => {
const handelSeeAll = () => {
navigate(`/categories?type=best_sale`);
};
+
+ const { data,isLoading } = useGetBaseProduct({
+ mostOrderd: "asc",
+ })
return (
@@ -16,7 +21,7 @@ const Products = () => {
{t("View all")}
-
+
);
diff --git a/src/Components/Home/ProductCard.tsx b/src/Components/Home/ProductCard.tsx
index 40978e1..f57bd09 100644
--- a/src/Components/Home/ProductCard.tsx
+++ b/src/Components/Home/ProductCard.tsx
@@ -40,10 +40,10 @@ const ProductCard = ({ item }: { item: Product }) => {
const queryClient = useQueryClient();
const handelChangeFavorite = (item: Product) => {
- if (!isAuthenticated) {
- toast.error("sorry you need to be authenticated");
- return;
- }
+ // if (!isAuthenticated) {
+ // toast.error("sorry you need to be authenticated");
+ // return;
+ // }
if (item?.favorite) {
@@ -55,6 +55,8 @@ const ProductCard = ({ item }: { item: Product }) => {
id: item?.id,
});
}
+ queryClient.invalidateQueries('mainProduct');
+
};
useEffect(() => {
@@ -71,11 +73,11 @@ const ProductCard = ({ item }: { item: Product }) => {
}, [Delete]);
const handelAddToCart = (item: Product) => {
- if (!isAuthenticated) {
+ // if (!isAuthenticated) {
- toast.error("sorry you need to be authenticated");
- return;
- }
+ // toast.error("sorry you need to be authenticated");
+ // return;
+ // }
setCart(item);
diff --git a/src/Components/Home/ProductSwiper.tsx b/src/Components/Home/ProductSwiper.tsx
index 67d800c..8365734 100644
--- a/src/Components/Home/ProductSwiper.tsx
+++ b/src/Components/Home/ProductSwiper.tsx
@@ -11,16 +11,14 @@ import { Spin } from 'antd';
-const ProductSwiper = () => {
+const ProductSwiper = ({data,isLoading}:any) => {
const language = localStorage.getItem('language') ;
console.log(language);
const [swiperDirection, setSwiperDirection] = useState(language === "ar" ? "rtl" : "ltr");
const swiperRef = useRef(null);
- const { data, isLoading } = useGetBaseProduct({
- mostOrderd: "asc",
- });
+
const BaseProducts = (data?.products as Product[]) || ([] as []);
return (
diff --git a/src/Components/Home/Products.tsx b/src/Components/Home/Products.tsx
index 55fd389..c383618 100644
--- a/src/Components/Home/Products.tsx
+++ b/src/Components/Home/Products.tsx
@@ -1,6 +1,7 @@
import { useNavigate } from "react-router-dom";
import { useTranslation } from "react-i18next";
import ProductSwiper from "./ProductSwiper";
+import { useGetBaseProduct } from "../../api/baseProduct";
const Products = () => {
const {t} = useTranslation();
@@ -10,6 +11,11 @@ const Products = () => {
navigate(`/categories?type=new_product`);
};
+ const { data,isLoading } = useGetBaseProduct({
+ lastProducts:"asc"
+ });
+
+
return (
@@ -17,7 +23,7 @@ const Products = () => {
{t("View all")}
-
+
);
diff --git a/src/Pages/Product/Page.tsx b/src/Pages/Product/Page.tsx
index d6e63b9..3392f8c 100644
--- a/src/Pages/Product/Page.tsx
+++ b/src/Pages/Product/Page.tsx
@@ -94,7 +94,7 @@ const Page = () => {
-
+
);
};
diff --git a/src/Pages/Product/Similar.tsx b/src/Pages/Product/Similar.tsx
index 8269de3..20c0f58 100644
--- a/src/Pages/Product/Similar.tsx
+++ b/src/Pages/Product/Similar.tsx
@@ -1,8 +1,10 @@
import { useGetBaseProduct } from "../../api/baseProduct";
import ProductSwiper from "../../Components/Home/ProductSwiper";
-const Similar = () => {
- const { data } = useGetBaseProduct();
+const Similar = ({category_id}:any) => {
+ const { data,isLoading } = useGetBaseProduct({
+ category_id:category_id
+ });
return (
@@ -10,7 +12,7 @@ const Similar = () => {
Similar Products
-
+
);