Skip to content

Commit

Permalink
#2 [ Frontend ] Header & Footer
Browse files Browse the repository at this point in the history
  • Loading branch information
fdhhhdjd committed Oct 22, 2023
1 parent 33a6f65 commit dca93b9
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 37 deletions.
5 changes: 2 additions & 3 deletions src/app/categories/[categoryId]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,8 @@ const CategoryIdPage = (props: PageProps) => {
queryClient.removeQueries(['initDetailCategories']);
};
}, [categoryId]);
if (isLoading) {
return <Loader />;
}

if (isLoading) return <Loader />;

if (isError) {
return (
Expand Down
8 changes: 2 additions & 6 deletions src/app/products/[productId]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,9 @@ const ProductIdPage = ({ params: { productId } }: PageProps) => {
};
}, []);

if (isLoading) {
return <Loader />;
}
if (isLoading) return <Loader />;

if (!product) {
return notFound();
}
if (!product) return notFound();

return (
<>
Expand Down
7 changes: 2 additions & 5 deletions src/components/CategorySection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,9 @@ const CategorySection = ({
refetchOnWindowFocus: false,
});

if (isLoading) {
return <Loader />;
}
if (isLoading) return <Loader />;

if (isError) {
if (isError)
return (
<ErrorPage
error={{
Expand All @@ -40,7 +38,6 @@ const CategorySection = ({
reset={() => refetch()}
/>
);
}

return (
<>
Expand Down
9 changes: 3 additions & 6 deletions src/components/SearchSection/SearchProductSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,9 @@ const SearchProductSection = ({ search, onClose }: SearchProductSectionProp) =>
refetchOnWindowFocus: false,
});

if (isLoading) {
return <Loader />;
}
if (!products || !products.length) {
return <NotFoundText>No Products Found.</NotFoundText>;
}
if (isLoading) return <Loader />;

if (!products || !products.length) return <NotFoundText>No Products Found.</NotFoundText>;

return (
<>
Expand Down
8 changes: 2 additions & 6 deletions src/components/sections/AllProductsSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,9 @@ const AllProductsSection = ({ page }: Props) => {
refetchOnWindowFocus: false,
});

if (isLoading) {
return <Loader />;
}
if (isLoading) return <Loader />;

if (isError) {
if (isError)
return (
<ErrorPage
error={{
Expand All @@ -42,8 +40,6 @@ const AllProductsSection = ({ page }: Props) => {
reset={() => refetch()}
/>
);
}

return (
<div className="sm:mx-3 px-2 sm:py-10 py-5">
<h2 className="mx-auto max-w-6xl text-2xl font-black mb-4">All Available Products:</h2>
Expand Down
7 changes: 2 additions & 5 deletions src/components/sections/PopularProductsSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,9 @@ const ProductComponent = () => {
refetchOnWindowFocus: false,
});

if (isLoading) {
return <Loader />;
}
if (isLoading) return <Loader />;

if (isError) {
if (isError)
return (
<ErrorPage
error={{
Expand All @@ -38,7 +36,6 @@ const ProductComponent = () => {
reset={() => refetch()}
/>
);
}
return (
<>
<Border />
Expand Down
7 changes: 2 additions & 5 deletions src/components/sections/ProductSuggestionSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,9 @@ const ProductSuggestionSection = ({ product }: ProductSuggestionSectionProps) =>
refetchOnWindowFocus: false,
});

if (isLoading) {
return <Loader />;
}
if (isLoading) return <Loader />;

if (isError) {
if (isError)
return (
<ErrorPage
error={{
Expand All @@ -45,7 +43,6 @@ const ProductSuggestionSection = ({ product }: ProductSuggestionSectionProps) =>
reset={() => refetch()}
/>
);
}

return (
<>
Expand Down
1 change: 0 additions & 1 deletion src/hooks/useLocalStorage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ const useLocalStorage = <T,>(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)) => {
Expand Down

0 comments on commit dca93b9

Please sign in to comment.