Skip to content

Commit

Permalink
feat: Implement search functionality to filter products based on sear…
Browse files Browse the repository at this point in the history
…ch text and product type

feat: Add sorting options to filter products by price (low to high and high to low)
feat: Add pagination to display a limited number of products per page
refactor: Use destructured import for product API query
style: Update the design and layout of the search results page
fix: Handle edge case when no products match the search criteria
  • Loading branch information
Hamed-Hasan committed Jul 29, 2023
1 parent 5084992 commit ce6410c
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/layout/headers/header-2.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const HeaderTwo = ({ style_2 = false }) => {
<a href="tel:402-763-282-46">
<span>
<PhoneTwo />
</span> +(402) 763 282 46
</span> +(966) 595 035 008
</a>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/layout/headers/header.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ const Header = () => {
<div className="tp-header-contact-content">
<h5>Hotline:</h5>
<p>
<a href="tel:402-763-282-46">+(402) 763 282 46</a>
<a href="tel:966-595-035-008">+(966) 595 035 008</a>
</p>
</div>
</div>
Expand Down
6 changes: 3 additions & 3 deletions src/pages/search.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,13 @@ export default function SearchPage({ query }) {

if (searchText && !productType) {
product_items = all_products.filter((prd) =>
prd.title.toLowerCase().includes(searchText.toLowerCase())
prd.title?.toLowerCase().includes(searchText?.toLowerCase())
);
}
if (searchText && productType) {
product_items = all_products.filter(
(prd) => prd.productType.toLowerCase() === productType.toLowerCase()
).filter(p => p.title.toLowerCase().includes(searchText.toLowerCase()));
(prd) => prd.productType?.toLowerCase() === productType?.toLowerCase()
).filter(p => p?.title?.toLowerCase().includes(searchText?.toLowerCase()));
}
// Price low to high
if (shortValue === "Price low to high") {
Expand Down

0 comments on commit ce6410c

Please sign in to comment.