From dca93b9e524157e4b701e2846a2b86af1f58e4f7 Mon Sep 17 00:00:00 2001 From: fdhhhdjd Date: Sun, 22 Oct 2023 11:28:53 +0700 Subject: [PATCH] #2 [ Frontend ] Header & Footer --- src/app/categories/[categoryId]/page.tsx | 5 ++--- src/app/products/[productId]/page.tsx | 8 ++------ src/components/CategorySection.tsx | 7 ++----- src/components/SearchSection/SearchProductSection.tsx | 9 +++------ src/components/sections/AllProductsSection.tsx | 8 ++------ src/components/sections/PopularProductsSection.tsx | 7 ++----- src/components/sections/ProductSuggestionSection.tsx | 7 ++----- src/hooks/useLocalStorage.tsx | 1 - 8 files changed, 15 insertions(+), 37 deletions(-) diff --git a/src/app/categories/[categoryId]/page.tsx b/src/app/categories/[categoryId]/page.tsx index ea8aeaf..e1e58c1 100644 --- a/src/app/categories/[categoryId]/page.tsx +++ b/src/app/categories/[categoryId]/page.tsx @@ -45,9 +45,8 @@ const CategoryIdPage = (props: PageProps) => { queryClient.removeQueries(['initDetailCategories']); }; }, [categoryId]); - if (isLoading) { - return ; - } + + if (isLoading) return ; if (isError) { return ( diff --git a/src/app/products/[productId]/page.tsx b/src/app/products/[productId]/page.tsx index 9105561..3c566af 100644 --- a/src/app/products/[productId]/page.tsx +++ b/src/app/products/[productId]/page.tsx @@ -34,13 +34,9 @@ const ProductIdPage = ({ params: { productId } }: PageProps) => { }; }, []); - if (isLoading) { - return ; - } + if (isLoading) return ; - if (!product) { - return notFound(); - } + if (!product) return notFound(); return ( <> diff --git a/src/components/CategorySection.tsx b/src/components/CategorySection.tsx index 1ecce89..4d73334 100644 --- a/src/components/CategorySection.tsx +++ b/src/components/CategorySection.tsx @@ -27,11 +27,9 @@ const CategorySection = ({ refetchOnWindowFocus: false, }); - if (isLoading) { - return ; - } + if (isLoading) return ; - if (isError) { + if (isError) return ( refetch()} /> ); - } return ( <> diff --git a/src/components/SearchSection/SearchProductSection.tsx b/src/components/SearchSection/SearchProductSection.tsx index d1674de..bdc1ca1 100644 --- a/src/components/SearchSection/SearchProductSection.tsx +++ b/src/components/SearchSection/SearchProductSection.tsx @@ -25,12 +25,9 @@ const SearchProductSection = ({ search, onClose }: SearchProductSectionProp) => refetchOnWindowFocus: false, }); - if (isLoading) { - return ; - } - if (!products || !products.length) { - return No Products Found.; - } + if (isLoading) return ; + + if (!products || !products.length) return No Products Found.; return ( <> diff --git a/src/components/sections/AllProductsSection.tsx b/src/components/sections/AllProductsSection.tsx index 2c16477..f61703b 100644 --- a/src/components/sections/AllProductsSection.tsx +++ b/src/components/sections/AllProductsSection.tsx @@ -29,11 +29,9 @@ const AllProductsSection = ({ page }: Props) => { refetchOnWindowFocus: false, }); - if (isLoading) { - return ; - } + if (isLoading) return ; - if (isError) { + if (isError) return ( { reset={() => refetch()} /> ); - } - return (

All Available Products:

diff --git a/src/components/sections/PopularProductsSection.tsx b/src/components/sections/PopularProductsSection.tsx index 26baa7e..74ca977 100644 --- a/src/components/sections/PopularProductsSection.tsx +++ b/src/components/sections/PopularProductsSection.tsx @@ -25,11 +25,9 @@ const ProductComponent = () => { refetchOnWindowFocus: false, }); - if (isLoading) { - return ; - } + if (isLoading) return ; - if (isError) { + if (isError) return ( { reset={() => refetch()} /> ); - } return ( <> diff --git a/src/components/sections/ProductSuggestionSection.tsx b/src/components/sections/ProductSuggestionSection.tsx index 89fbb34..24fd12b 100644 --- a/src/components/sections/ProductSuggestionSection.tsx +++ b/src/components/sections/ProductSuggestionSection.tsx @@ -32,11 +32,9 @@ const ProductSuggestionSection = ({ product }: ProductSuggestionSectionProps) => refetchOnWindowFocus: false, }); - if (isLoading) { - return ; - } + if (isLoading) return ; - if (isError) { + if (isError) return ( reset={() => refetch()} /> ); - } return ( <> diff --git a/src/hooks/useLocalStorage.tsx b/src/hooks/useLocalStorage.tsx index b2f3a21..8890e65 100644 --- a/src/hooks/useLocalStorage.tsx +++ b/src/hooks/useLocalStorage.tsx @@ -11,7 +11,6 @@ const useLocalStorage = (key: string, initialValue: T): [T, (value: T | ((pr if (item) { setStoredValue(JSON.parse(item) as T); } - // eslint-disable-next-line }, []); const setValue = (value: T | ((prop: T) => T)) => {