Skip to content

Commit

Permalink
Fixed syntax using Prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
Hugo1307 committed Dec 2, 2023
1 parent fe9ea19 commit 2633e85
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 13 deletions.
7 changes: 5 additions & 2 deletions src/components/Recipes/Tags/RecipeEndingTag.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@ export default function RecipeEndingTag({ remainingTags }) {
className="flex justify-center mt-4 me-4 outline outline-blue-600 rounded-3xl"
aria-label="RecipeTag"
>
<p className="py-1 px-4 font-bold text-black dark:text-blue-600 transititext-primary text-primary transition duration-150 ease-in-out" data-te-toggle="tooltip"
title={remainingTags}>
<p
className="py-1 px-4 font-bold text-black dark:text-blue-600 transititext-primary text-primary transition duration-150 ease-in-out"
data-te-toggle="tooltip"
title={remainingTags}
>
+{remainingTags.length}
</p>
</div>
Expand Down
13 changes: 8 additions & 5 deletions src/components/Recipes/Tags/RecipeTagsGroup.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,31 @@ import PropTypes from "prop-types";
import RecipeEndingTag from "./RecipeEndingTag.jsx";

export default function RecipeTagsGroup({ tags, maxTags }) {

const maximumTags = maxTags ? maxTags : 3;

const tagsToPresent = useMemo(() => {

if (!tags) return [];

const tagsToPresent = tags.slice(0, maximumTags);

if (tags.length > maximumTags) tagsToPresent.push("...");

return tagsToPresent;
}, [tags, maxTags]);
}, [tags, maximumTags]);

return (
<>
<div className="flex flex-row flex-wrap">
{tagsToPresent.map((tag, index) => {
if (tag === "...") {
return <RecipeEndingTag key={"RecipeEndingTag_" + index} remainingTags={tags.slice(maximumTags, tags.length)} />
return (
<RecipeEndingTag
key={"RecipeEndingTag_" + index}
remainingTags={tags.slice(maximumTags, tags.length)}
/>
);
} else {
return <RecipeTag key={"RecipeTag_" + index} tag={tag} />
return <RecipeTag key={"RecipeTag_" + index} tag={tag} />;
}
})}
</div>
Expand Down
13 changes: 8 additions & 5 deletions src/components/Search/SearchBar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,13 @@ export default function SearchBar({ query }) {
);

useEffect(() => {

dispatch(setSearchResults(data));
setOutdatedResults(false);

if (data) {
dispatch(setNextPageUrl(data[0]?.nextPage));
setShouldReFetch(false); // Disable re-fetching
}

}, [data, dispatch]);

useEffect(() => {
Expand All @@ -47,7 +45,6 @@ export default function SearchBar({ query }) {
}, [selectedFilters]);

const handleSearch = (event) => {

if (event.type === "keydown" && event.key !== "Enter") return;

if (!localSearchQuery || localSearchQuery === "") {
Expand All @@ -57,7 +54,6 @@ export default function SearchBar({ query }) {

setShouldReFetch(true); // Re-render the component and program a re-fetch on next render
nav(`/search/${localSearchQuery}`);

};

return (
Expand All @@ -83,7 +79,14 @@ export default function SearchBar({ query }) {
/>
</div>
<div className="flex">
{outdatedResults && <p className="font-bold text-blue-600 text-lg mx-2 animate-pulse hover:cursor-pointer" onClick={handleSearch}>Search</p>}
{outdatedResults && (
<p
className="font-bold text-blue-600 text-lg mx-2 animate-pulse hover:cursor-pointer"
onClick={handleSearch}
>
Search
</p>
)}
</div>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/utils/searchFiltersOperations.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ export const transformFilters = (selectedFilters) => {
});

return filters;
};
};

0 comments on commit 2633e85

Please sign in to comment.