Merge pull request '(FEAT): Added the view all button for Connor!' (#74) from feature/view-all into master
All checks were successful
Deploy application with Docker / build_and_deploy (push) Successful in 58s
All checks were successful
Deploy application with Docker / build_and_deploy (push) Successful in 58s
Reviewed-on: #74
This commit is contained in:
commit
e0d423f806
@ -7,10 +7,9 @@ import { isApiError } from "../../types/api/error";
|
|||||||
import type { Recipe } from "../../types/recipe";
|
import type { Recipe } from "../../types/recipe";
|
||||||
import { useNavigate } from "react-router-dom";
|
import { useNavigate } from "react-router-dom";
|
||||||
import { FilterContext } from "../../context/FilterContext";
|
import { FilterContext } from "../../context/FilterContext";
|
||||||
|
import ROUTE_CONSTANTS from "../../types/routes";
|
||||||
|
|
||||||
interface RecipeSearchBarProps {
|
interface RecipeSearchBarProps {
|
||||||
// filters: SearchFilters;
|
|
||||||
// setFilters: React.Dispatch<React.SetStateAction<SearchFilters>>;
|
|
||||||
redirect: boolean;
|
redirect: boolean;
|
||||||
searchOnLoad: boolean;
|
searchOnLoad: boolean;
|
||||||
favorites: boolean;
|
favorites: boolean;
|
||||||
@ -30,7 +29,7 @@ export default function RecipeSearchBar({ redirect, searchOnLoad, favorites, set
|
|||||||
// SERVER FUNCTIONS
|
// SERVER FUNCTIONS
|
||||||
const fetchSearchResults = async () => {
|
const fetchSearchResults = async () => {
|
||||||
if (redirect) {
|
if (redirect) {
|
||||||
await navigate("/v2/web/search");
|
await navigate(ROUTE_CONSTANTS.Search);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -39,7 +38,7 @@ export default function RecipeSearchBar({ redirect, searchOnLoad, favorites, set
|
|||||||
if (setLoading) setLoading(true);
|
if (setLoading) setLoading(true);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const result = await SearchRecipes(filters);
|
const result = await SearchRecipes({ ...filters, Favorites: favorites });
|
||||||
if (isApiError(result)) {
|
if (isApiError(result)) {
|
||||||
console.error(result.message);
|
console.error(result.message);
|
||||||
return;
|
return;
|
||||||
@ -76,14 +75,6 @@ export default function RecipeSearchBar({ redirect, searchOnLoad, favorites, set
|
|||||||
void fetchSearchResults();
|
void fetchSearchResults();
|
||||||
}, [searchOnLoad]);
|
}, [searchOnLoad]);
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
setFilters({
|
|
||||||
...filters,
|
|
||||||
Favorites: favorites
|
|
||||||
});
|
|
||||||
}, [favorites]);
|
|
||||||
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<form className="w-full px-4 my-8" onSubmit={(e) => void searchHandler(e)}>
|
<form className="w-full px-4 my-8" onSubmit={(e) => void searchHandler(e)}>
|
||||||
<div className="flex w-full gap-x-2">
|
<div className="flex w-full gap-x-2">
|
||||||
|
|||||||
@ -88,7 +88,12 @@ export default function Home() {
|
|||||||
<div className="w-full md:w-3/4">
|
<div className="w-full md:w-3/4">
|
||||||
<RecipeSearchBar redirect={true} favorites={false} searchOnLoad={false} setRecipes={null} />
|
<RecipeSearchBar redirect={true} favorites={false} searchOnLoad={false} setRecipes={null} />
|
||||||
</div>
|
</div>
|
||||||
<div className="hidden" id="result-list"></div>
|
<p className="leading-relaxed text-gray-800">
|
||||||
|
Not sure what you want? {" "}
|
||||||
|
<a href={ROUTE_CONSTANTS.Search} className="text-blue-500 underline hover:text-blue-700 duration-300">
|
||||||
|
View all recipes here
|
||||||
|
</a>
|
||||||
|
</p>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
{/* Highlight Section */}
|
{/* Highlight Section */}
|
||||||
|
|||||||
@ -1,4 +0,0 @@
|
|||||||
export interface SearchFilters {
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -8,6 +8,7 @@ const ROUTE_CONSTANTS: {
|
|||||||
ShoppingList: string;
|
ShoppingList: string;
|
||||||
Login: string;
|
Login: string;
|
||||||
History: string;
|
History: string;
|
||||||
|
Search: string;
|
||||||
Recipe: (id: number) => string;
|
Recipe: (id: number) => string;
|
||||||
} = {
|
} = {
|
||||||
Home: `${VERSION_FLAG}/web/home`,
|
Home: `${VERSION_FLAG}/web/home`,
|
||||||
@ -17,6 +18,7 @@ const ROUTE_CONSTANTS: {
|
|||||||
ShoppingList: `${VERSION_FLAG}/web/list`,
|
ShoppingList: `${VERSION_FLAG}/web/list`,
|
||||||
Login: `${VERSION_FLAG}/web/login`,
|
Login: `${VERSION_FLAG}/web/login`,
|
||||||
History: `${VERSION_FLAG}/web/history`,
|
History: `${VERSION_FLAG}/web/history`,
|
||||||
|
Search: `${VERSION_FLAG}/web/search`,
|
||||||
Recipe: (id: number) => `${VERSION_FLAG}/web/recipe/${id}`,
|
Recipe: (id: number) => `${VERSION_FLAG}/web/recipe/${id}`,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user