Skip to content

Commit 33d4751

Browse files
committed
fixed eslint errors
1 parent 11ff565 commit 33d4751

5 files changed

Lines changed: 41 additions & 39 deletions

File tree

app/(dashboard)/admin/products/[id]/page.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,7 @@ const DashboardProductDetails = ({
116116
});
117117
const images = await imagesData.json();
118118
setOtherImages((currentImages) => images);
119-
120-
}, [id])
119+
}, [id]);
121120

122121
// fetching all product categories. It will be used for displaying categories in select category input
123122
const fetchCategories = async () => {

components/AddToWishlistBtn.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,7 @@ const AddToWishlistBtn = ({ product, slug }: AddToWishlistBtnProps) => {
106106
}
107107
});
108108
}
109-
110-
}, [session?.user?.email, product?.id])
109+
}, [session?.user?.email, product?.id]);
111110

112111
useEffect(() => {
113112
isInWishlist();

components/Header.tsx

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -34,35 +34,36 @@ const Header = () => {
3434
};
3535

3636
// getting all wishlist items by user id
37-
const getWishlistByUserId = useCallback(async (id: string) => {
38-
39-
const response = await fetch(`http://localhost:3001/api/wishlist/${id}`, {
40-
cache: 'no-store',
41-
});
42-
const wishlist = await response.json();
43-
const productArray: {
44-
id: string;
45-
title: string;
46-
price: number;
47-
image: string;
48-
slug: string;
49-
stockAvailabillity: number;
50-
}[] = [];
51-
52-
wishlist.map((item: any) =>
53-
productArray.push({
54-
id: item?.product?.id,
55-
title: item?.product?.title,
56-
price: item?.product?.price,
57-
image: item?.product?.mainImage,
58-
slug: item?.product?.slug,
59-
stockAvailabillity: item?.product?.inStock,
60-
}),
61-
);
37+
const getWishlistByUserId = useCallback(
38+
async (id: string) => {
39+
const response = await fetch(`http://localhost:3001/api/wishlist/${id}`, {
40+
cache: 'no-store',
41+
});
42+
const wishlist = await response.json();
43+
const productArray: {
44+
id: string;
45+
title: string;
46+
price: number;
47+
image: string;
48+
slug: string;
49+
stockAvailabillity: number;
50+
}[] = [];
6251

63-
setWishlist(productArray);
52+
wishlist.map((item: any) =>
53+
productArray.push({
54+
id: item?.product?.id,
55+
title: item?.product?.title,
56+
price: item?.product?.price,
57+
image: item?.product?.mainImage,
58+
slug: item?.product?.slug,
59+
stockAvailabillity: item?.product?.inStock,
60+
}),
61+
);
6462

65-
}, [setWishlist])
63+
setWishlist(productArray);
64+
},
65+
[setWishlist],
66+
);
6667

6768
// getting user by email so I can get his user id
6869
const getUserByEmail = useCallback(() => {
@@ -75,8 +76,7 @@ const Header = () => {
7576
getWishlistByUserId(data?.id);
7677
});
7778
}
78-
79-
}, [session?.user?.email, getWishlistByUserId])
79+
}, [session?.user?.email, getWishlistByUserId]);
8080

8181
useEffect(() => {
8282
getUserByEmail();

components/SimpleSlider.tsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import Slider from 'react-slick';
1414
import 'slick-carousel/slick/slick.css';
1515
import 'slick-carousel/slick/slick-theme.css';
1616
import Link from 'next/link';
17-
import Image from "next/image"
17+
import Image from 'next/image';
1818

1919
function SimpleSlider() {
2020
const settings = {
@@ -49,7 +49,10 @@ function SimpleSlider() {
4949
<Image
5050
width={300}
5151
height={300}
52-
src="/slider image 1.webp" alt="slider 1" className="h-full" />
52+
src="/slider image 1.webp"
53+
alt="slider 1"
54+
className="h-full"
55+
/>
5356
</div>
5457
<div className="h-[500px] max-lg:h-[400px] max-md:h-[250px] max-[500px]:h-[200px] max-[400px]:h-[150px] relative">
5558
<div className="absolute left-[50%] translate-x-[-50%] translate-y-[30%] h-full text-center max-lg:translate-y-[25%] max-md:translate-y-[20%] max-sm:hidden">
@@ -73,7 +76,10 @@ function SimpleSlider() {
7376
<Image
7477
width={400}
7578
height={300}
76-
src="/slider image 2.webp" alt="slider 1" className="h-full" />
79+
src="/slider image 2.webp"
80+
alt="slider 1"
81+
className="h-full"
82+
/>
7783
</div>
7884
</Slider>
7985
</div>

components/WishItem.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,6 @@ const WishItem = ({
4141
router.push(`/product/${slug}`);
4242
};
4343

44-
45-
4644
const deleteItemFromWishlist = async (productId: string) => {
4745
if (userId) {
4846
fetch(`http://localhost:3001/api/wishlist/${userId}/${productId}`, {
@@ -66,7 +64,7 @@ const WishItem = ({
6664
setUserId(data?.id);
6765
});
6866
}
69-
}, [session?.user?.email])
67+
}, [session?.user?.email]);
7068

7169
useEffect(() => {
7270
getUserByEmail();

0 commit comments

Comments
 (0)