Skip to content
This repository has been archived by the owner on May 28, 2024. It is now read-only.

Commit

Permalink
Filter things by spanish name if not null
Browse files Browse the repository at this point in the history
  • Loading branch information
dillonfagan committed Aug 30, 2023
1 parent b3092fd commit 87f45eb
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/lib/utils/filters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,16 @@ export const filter = (things, { keyword, onlyWishList, category }) => {

if (category && category.toLowerCase() !== "all")
filtered = filtered.filter(thing => thing.categories.includes(category));

if (keyword.length > 0)
filtered = filtered.filter(thing => thing.name.toLowerCase().includes(keyword.toLowerCase()));
filtered = filtered.filter(thing => {
return thing.name.toLowerCase().includes(keyword.toLowerCase())
|| (thing.spanishName && thing.spanishName?.toLowerCase().includes(keyword.toLowerCase()));
});

if (onlyWishList)
filtered = filtered.filter(thing => thing.stock < 1);

if (!onlyWishList)
filtered = filtered.filter(thing => thing.stock !== 0);

Expand Down

0 comments on commit 87f45eb

Please sign in to comment.