-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: Memoized components, Split product listing page
- Loading branch information
1 parent
3629ad8
commit 6bec812
Showing
26 changed files
with
258 additions
and
259 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { CircularProgress } from '@mui/material' | ||
|
||
export default function Loader() { | ||
return ( | ||
<div | ||
style={{ | ||
display: 'flex', | ||
justifyContent: 'center', | ||
alignItems: 'center', | ||
minHeight: '100vh', | ||
maxWidth: '100vw', | ||
}} | ||
> | ||
<CircularProgress size="3rem" /> | ||
</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,40 @@ | ||
import { Box, FormControl, Typography } from '@mui/material' | ||
import { useSearchParams } from 'react-router-dom' | ||
import { memo } from 'react' | ||
|
||
import useHandleDispatch from '@/hooks/useHandleDispatch' | ||
import CategoryFilter from './components/CategoryFilter' | ||
import ClearFilter from './components/ClearFilter' | ||
import PriceSliderFilter from './components/PriceSliderFilter' | ||
import RatingFilter from './components/RatingFilter' | ||
import SortProductsFilter from './components/SortProductsFilter' | ||
|
||
export default function SidebarFilters() { | ||
const searchParams = useSearchParams()[0] | ||
const { | ||
handleFilterRating, | ||
handleSort, | ||
handlePriceRange, | ||
handleClearFilter, | ||
} = useHandleDispatch() | ||
|
||
function SidebarFilters() { | ||
console.log('SidebarFilters') | ||
return ( | ||
<> | ||
<Typography component="h1" variant="h5" fontWeight="bold"> | ||
Filters | ||
</Typography> | ||
<Box display="flex" justifyContent="center" flexDirection="column"> | ||
<h2>Filters</h2> | ||
<div | ||
style={{ | ||
display: 'flex', | ||
justifyContent: 'center', | ||
flexDirection: 'column', | ||
}} | ||
> | ||
{/* Clear Filters */} | ||
<button onClick={handleClearFilter}>Clear Filters</button> | ||
<br /> | ||
<ClearFilter /> | ||
|
||
{/* Price Filter */} | ||
<PriceSliderFilter | ||
searchParams={searchParams} | ||
handlePriceRange={handlePriceRange} | ||
/> | ||
<FormControl> | ||
{/* Sort products */} | ||
<SortProductsFilter | ||
searchParams={searchParams} | ||
handleSort={handleSort} | ||
/> | ||
<PriceSliderFilter /> | ||
{/* Sort products */} | ||
<SortProductsFilter /> | ||
|
||
{/* Ratings filter */} | ||
<RatingFilter | ||
searchParams={searchParams} | ||
handleFilterRating={handleFilterRating} | ||
/> | ||
</FormControl> | ||
{/* Ratings filter */} | ||
<RatingFilter /> | ||
|
||
{/* Category Filters */} | ||
<CategoryFilter searchParams={searchParams} /> | ||
</Box> | ||
<CategoryFilter /> | ||
</div> | ||
</> | ||
) | ||
} | ||
|
||
const MemoizedSidebarFilters = memo(SidebarFilters) | ||
export default MemoizedSidebarFilters |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import useHandleDispatch from '@/hooks/useHandleDispatch' | ||
|
||
export default function ClearFilter() { | ||
const { handleClearFilter } = useHandleDispatch() | ||
console.log('ClearFilter') | ||
return ( | ||
<section> | ||
<button onClick={handleClearFilter}>Clear Filters</button> | ||
</section> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.