Skip to content

Commit

Permalink
Merge branch 'development' into ft-stats-#187300236
Browse files Browse the repository at this point in the history
  • Loading branch information
Eli250 authored Jul 16, 2024
2 parents b6a1be0 + 8d1e55e commit 5169286
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 27 deletions.
29 changes: 22 additions & 7 deletions src/components/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ const Header = () => {
(state: RootState) => state.wishlist
)

const { isOrdersOverlayOpen, toggleOrdersSlider } = OrdersOverlay();
const { isOrdersOverlayOpen, setIsOrdersOverlayOpen, toggleOrdersSlider } = OrdersOverlay();
const [activelink, setActivelink] = useState('home');

const { isWishlistOverlayOpen, toggleWishlistSlider } = WishlistOverlay();
const { isWishlistOverlayOpen, setIsWishlistOverlayOpen, toggleWishlistSlider } = WishlistOverlay();
const [showlModal, setShowmodal] = useState(false);

const [showCart, setShowCart] = useState(false);
Expand All @@ -53,11 +53,25 @@ const Header = () => {
'cart' | 'notification' | null
>(null);

const handleShowWishlist=()=>{
setIsOrdersOverlayOpen(false);
setOverlayComponent(null);
toggleWishlistSlider();
}
const handleShowOrders=()=>{
setIsWishlistOverlayOpen(false);
setOverlayComponent(null);
toggleOrdersSlider();
}
const handleShowCart = () => {
setIsWishlistOverlayOpen(false);
setIsOrdersOverlayOpen(false);
setOverlayComponent('cart');
};

const handleShowNotification = () => {
setIsWishlistOverlayOpen(false);
setIsOrdersOverlayOpen(false);
setOverlayComponent('notification');
};

Expand Down Expand Up @@ -122,7 +136,7 @@ const Header = () => {
</i>
<MdOutlineShoppingCart className="hover:bg-black text-white cursor-pointer z-20" />
</span>
<span className='flex items-center mx-2 cursor-pointer' onClick={toggleWishlistSlider}>
<span className='flex items-center mx-2 cursor-pointer' onClick={handleShowWishlist}>
<i className=" bg-black border items-center border-slate-100 w-6 h-6 text-center rounded-[100%] relative top-[-10px] right-[-5px] text-[#ffff] text-[12px]">
{wishNumber}
</i>
Expand Down Expand Up @@ -173,7 +187,7 @@ const Header = () => {
<>
<li
className="text-black hover:text-blue-600"
onClick={toggleOrdersSlider}
onClick={handleShowOrders}
>
Order
</li>
Expand Down Expand Up @@ -223,7 +237,7 @@ const Header = () => {
</li>
<li
className={`${isOrdersOverlayOpen === true ? 'text-blue-600' : 'text-black'} font-normal hover:text-blue-600 cursor-pointer `}
onClick={toggleOrdersSlider}
onClick={handleShowOrders}
>
Order
</li>
Expand Down Expand Up @@ -326,15 +340,16 @@ const Header = () => {
) : (
''
)}
</div>
{isWishlistOverlayOpen ? (
{isWishlistOverlayOpen ? (
<WishlistContainer
isWishlistOverlayOpen={isWishlistOverlayOpen}
toggleWishlistSlider={toggleWishlistSlider}
/>
) : (
''
)}
</div>

{overlayComponent && (
<SideBarOverlay handleOpenOverlay={handleCloseOverlay}>
{overlayComponent === 'cart' && (
Expand Down
14 changes: 4 additions & 10 deletions src/components/ProductList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,8 @@ const ProductList: React.FC<ProdductProps> = ({ activeNav,searchResults }) => {
switch (nav) {
case 'All':
return `/products?page=${activeButton}&limit=10`;
case 'Electronics':
return '/products/electronics?page=1&limit=10';
case 'wishes':
return `/wishes?page=${activeButton}&limit=10`;
case 'Featured':
return '/products/Featured?page=1&limit=10';
case 'Featured':
return '/products/Featured?page=1&limit=10';
return `/wishes`;
default:
return `/products?page=${activeButton}&limit=10`;
}
Expand All @@ -49,10 +43,10 @@ const ProductList: React.FC<ProdductProps> = ({ activeNav,searchResults }) => {
data = response.products;
dispatch(storeAllProduct(data));
return data;
} else if (response.data) {
} else if (response.wishes) {
const allProduct: any = await request.get(`/products`);
const filterdeArray = allProduct.products.filter((el1: any) =>
response.data.some((el: any) => el1.id === el.product.id),
response.wishes.some((el: any) => el1.id === el.product.id),
);
data = filterdeArray;
}
Expand All @@ -62,7 +56,7 @@ const ProductList: React.FC<ProdductProps> = ({ activeNav,searchResults }) => {
return data;
},
});

console.log('this is fetched data', data);
if (isLoading) {
return (
<div data-testid="loading">
Expand Down
15 changes: 7 additions & 8 deletions src/components/allProducts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ export const ProductWithFilter = () => {
const router = useRouter();
const Options = [
{ laber: 'All', value: 1 },
{ laber: 'Rating', value: 2 },
{ laber: 'wishes', value: 3 },
{ laber: 'wishes', value: 3 }
];

useEffect(() => {
Expand Down Expand Up @@ -82,24 +81,24 @@ export const ProductWithFilter = () => {
<div className="flex sm:gap-5 mb-10 sm:ml-24 gap-1 ">
{locarstorage === 'buyer' && (
<>
<button
{/* <button
className={buttonClass('Featured')}
onClick={() => handleButtonClick('Featured')}
>
Featured
</button>
Shoes
</button> */}
<button
className={buttonClass('wishes')}
onClick={() => handleButtonClick('wishes')}
>
wishes
</button>
<button
{/* <button
className={buttonClass('Electronics')}
onClick={() => handleButtonClick('Electronics')}
>
Electronics
</button>
Cars
</button> */}
</>
)}
<button
Expand Down
6 changes: 4 additions & 2 deletions src/redux/slices/wishlistSlice.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
"use client"
import { checkUserLoggedIn } from '@/components/isLogged';
import request from '@/utils/axios';
import { createAsyncThunk, createSlice, PayloadAction } from '@reduxjs/toolkit';

const handleFetchUserWishes = async ():Promise<number>=>{
const token = localStorage.getItem('token');
if(token){
const check = checkUserLoggedIn();
if(check){
const response:any = await request.get('/wishes');
console.log('this is data from wishlist', response);
if(response.status == 200){
Expand Down

0 comments on commit 5169286

Please sign in to comment.