diff --git a/src/Components/HOC/CartWithDrawer.tsx b/src/Components/HOC/CartWithDrawer.tsx index f413d51..e525c5a 100644 --- a/src/Components/HOC/CartWithDrawer.tsx +++ b/src/Components/HOC/CartWithDrawer.tsx @@ -103,8 +103,8 @@ const CartWithDrawer = () => { ) : (
- {/* -

{t('You have not placed any orders yet')}

*/} + +

{t('You have not placed any orders yet')}

)} diff --git a/src/Components/Home/ProductCard.tsx b/src/Components/Home/ProductCard.tsx index b3aba0e..8cdd963 100644 --- a/src/Components/Home/ProductCard.tsx +++ b/src/Components/Home/ProductCard.tsx @@ -1,7 +1,6 @@ import React, { useEffect } from "react"; -import { FaHeart, FaStar } from "react-icons/fa"; +import { FaHeart, FaStar, FaCartPlus } from "react-icons/fa"; import { Currency } from "../../Layout/app/Const"; -import { FaCartPlus } from "react-icons/fa6"; import { useTranslation } from "react-i18next"; import { useNavigate } from "react-router-dom"; import CustomImage from "../../ui/CustomImage"; @@ -17,9 +16,8 @@ const ProductCard = ({ item }: { item: Product }) => { const [t] = useTranslation(); const navigate = useNavigate(); const { isAuthenticated } = useAuthState(); - - const handel_click = (id: number) => { - + + const handle_click = (id: number) => { navigate(`/product/${id}`); }; @@ -34,82 +32,69 @@ const ProductCard = ({ item }: { item: Product }) => { const randomRate = (Math.random() * (max - min) + min)?.toFixed(1); const { Cart, setCart } = useCartState(); - const queryClient = useQueryClient(); - const handelChangeFavorite = (item: Product) => { - // if (!isAuthenticated) { - // toast.error("sorry you need to be authenticated"); - // return; - // } + const handleChangeFavorite = (item: Product) => { + if (!isAuthenticated) { + toast.error("Sorry, you need to be authenticated"); + return; + } if (item?.favorite) { - - deleteToFavorite({ - id: item?.id, - }); + deleteToFavorite({ id: item?.id }); } else { - addToFavorite({ - id: item?.id, - }); + addToFavorite({ id: item?.id }); } - queryClient.invalidateQueries('mainProduct'); - + queryClient.invalidateQueries("mainProduct"); }; useEffect(() => { if (Add) { - toast.success("added success"); + toast.success("Added successfully"); queryClient.invalidateQueries("mainProduct"); } }, [Add]); + useEffect(() => { if (Delete) { - toast.success("removed success"); + toast.success("Removed successfully"); queryClient.invalidateQueries("mainProduct"); } }, [Delete]); - const handelAddToCart = (item: Product) => { - // if (!isAuthenticated) { - - // toast.error("sorry you need to be authenticated"); - // return; - // } + const handleAddToCart = (item: Product) => { + if (!isAuthenticated) { + toast.error("Sorry, you need to be authenticated"); + return; + } setCart(item); - - - toast.success(`${languageObject(item?.name)}` + " added to cart"); + toast.success(`${languageObject(item?.name)} added to cart`); }; - - + const Desc :any = item?.description + const words = Desc.split(' '); + const firstThreeWord = words.slice(0, 2).join(' '); + const result = words.length > 2 ? firstThreeWord + '...' : firstThreeWord; return (
- handel_click(item?.base_product_id)} /> -

{languageObject(item?.name)}

-

- {" "} - {Currency} {oldPrice}{" "} -

+ handle_click(item?.base_product_id)} /> +

{languageObject(item?.name)}

+

Description: {result}

+ + {/*

{Currency} {oldPrice}

+

{price}

- {" "} - {Currency} {price} -

-

- {" "} {randomRate}

-
+
*/} {discountAmount}% -
- handelChangeFavorite(item)} + onClick={() => handleChangeFavorite(item)} className={item?.favorite ? "" : "not_favorite"} />
@@ -118,3 +103,4 @@ const ProductCard = ({ item }: { item: Product }) => { }; export default ProductCard; + diff --git a/src/Styles/Page/Cart.scss b/src/Styles/Page/Cart.scss index 734145f..835944e 100644 --- a/src/Styles/Page/Cart.scss +++ b/src/Styles/Page/Cart.scss @@ -70,7 +70,7 @@ } .Drawer_Body{ - height: 70vh; + // height: 70vh; display: flex; flex-direction: column; justify-content: space-between;align-items: center; } .ar{ @@ -110,8 +110,8 @@ flex-direction: column; align-items: center; justify-content: center; - margin-top: 5%; - gap: 20px; + margin-top: 10% !important; + // gap: 20px; img{ width: 40%; } diff --git a/src/Styles/Page/Product.scss b/src/Styles/Page/Product.scss index bd36bca..f64ff4d 100644 --- a/src/Styles/Page/Product.scss +++ b/src/Styles/Page/Product.scss @@ -110,7 +110,7 @@ .product_multi_image{ width: 60px !important; height: 50px; - object-fit: fill; + object-fit: contain; cursor: pointer; } } @@ -264,3 +264,15 @@ margin-left: 10px; border: 2px solid var(--primary); /* or any color that fits your design */ } +.truncate-text { + width: 90%; + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; + max-width: 100%; /* Adjust as needed */ + font-size: 14px !important; +} +.desc{ + font-size: 14px !important; + min-height: 60px; +} \ No newline at end of file diff --git a/src/Styles/components/ProductCard.scss b/src/Styles/components/ProductCard.scss index 7017c08..c9d1570 100644 --- a/src/Styles/components/ProductCard.scss +++ b/src/Styles/components/ProductCard.scss @@ -41,6 +41,8 @@ margin-bottom: 20px; cursor: pointer; margin-top: 30px; + aspect-ratio: 1; + object-fit: cover; } div { diff --git a/src/types/item.ts b/src/types/item.ts index 1a590c8..8a0b1de 100644 --- a/src/types/item.ts +++ b/src/types/item.ts @@ -1,4 +1,5 @@ export interface Translation { + split(arg0: string): unknown; en: string; ar: string; de: string;