Compare commits
No commits in common. "master" and "dev" have entirely different histories.
@ -4,7 +4,6 @@ import type { SearchFilters } from "../types/search";
|
|||||||
interface FilterContextType {
|
interface FilterContextType {
|
||||||
filters: SearchFilters;
|
filters: SearchFilters;
|
||||||
setFilters: (filters: SearchFilters) => void;
|
setFilters: (filters: SearchFilters) => void;
|
||||||
resetFilters: () => void;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export const FilterContext = createContext<FilterContextType>({
|
export const FilterContext = createContext<FilterContextType>({
|
||||||
@ -17,5 +16,4 @@ export const FilterContext = createContext<FilterContextType>({
|
|||||||
Favorites: false,
|
Favorites: false,
|
||||||
},
|
},
|
||||||
setFilters: () => { return },
|
setFilters: () => { return },
|
||||||
resetFilters: () => { return },
|
|
||||||
});
|
});
|
||||||
|
|||||||
@ -36,7 +36,7 @@ export function FilterProvider({ children }: { children: ReactNode }) {
|
|||||||
}, [filters]);
|
}, [filters]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<FilterContext value={{ filters, setFilters, resetFilters: () => setFilters(DEFAULT_FILTERS) }}>
|
<FilterContext value={{ filters, setFilters }}>
|
||||||
{children}
|
{children}
|
||||||
</FilterContext>
|
</FilterContext>
|
||||||
)
|
)
|
||||||
|
|||||||
@ -12,13 +12,10 @@ import { GetRecipeOfTheWeek } from "../services/RecipeService";
|
|||||||
import { isApiError, type ApiError } from "../types/api/error";
|
import { isApiError, type ApiError } from "../types/api/error";
|
||||||
import { AuthContext } from "../context/AuthContext";
|
import { AuthContext } from "../context/AuthContext";
|
||||||
import { GetAuthenticatedUserMadeRecipes, GetAuthenticateUserViewedRecipes } from "../services/UserService";
|
import { GetAuthenticatedUserMadeRecipes, GetAuthenticateUserViewedRecipes } from "../services/UserService";
|
||||||
import { useNavigate } from "react-router-dom";
|
|
||||||
import { FilterContext } from "../context/FilterContext";
|
|
||||||
|
|
||||||
export default function Home() {
|
export default function Home() {
|
||||||
// Context
|
// Context
|
||||||
const { isLoggedIn } = use(AuthContext);
|
const { isLoggedIn } = use(AuthContext);
|
||||||
const { resetFilters } = use(FilterContext);
|
|
||||||
|
|
||||||
// Page state
|
// Page state
|
||||||
const [recipeOfTheWeek, setRecipeOfTheWeek] = useState<Recipe | null>(null);
|
const [recipeOfTheWeek, setRecipeOfTheWeek] = useState<Recipe | null>(null);
|
||||||
@ -27,7 +24,6 @@ export default function Home() {
|
|||||||
const [viewedRecipes, setViewedRecipes] = useState<Recipe[]>([]);
|
const [viewedRecipes, setViewedRecipes] = useState<Recipe[]>([]);
|
||||||
|
|
||||||
const [error, setError] = useState<string>("");
|
const [error, setError] = useState<string>("");
|
||||||
const navigate = useNavigate();
|
|
||||||
|
|
||||||
// Fetch the recipe of the week
|
// Fetch the recipe of the week
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@ -59,12 +55,6 @@ export default function Home() {
|
|||||||
void fetch();
|
void fetch();
|
||||||
}, [isLoggedIn]);
|
}, [isLoggedIn]);
|
||||||
|
|
||||||
const viewAllRecipesHandler = () => {
|
|
||||||
// Clear filters
|
|
||||||
resetFilters();
|
|
||||||
void navigate(ROUTE_CONSTANTS.Search);
|
|
||||||
}
|
|
||||||
|
|
||||||
// BUG: Prob remove
|
// BUG: Prob remove
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (error)
|
if (error)
|
||||||
@ -100,11 +90,8 @@ export default function Home() {
|
|||||||
</div>
|
</div>
|
||||||
<p className="leading-relaxed text-gray-800">
|
<p className="leading-relaxed text-gray-800">
|
||||||
Not sure what you want? {" "}
|
Not sure what you want? {" "}
|
||||||
<button onClick={viewAllRecipesHandler} className="text-blue-500 underline hover:text-blue-700 duration-300 cursor-pointer">
|
|
||||||
View all recipes here
|
|
||||||
</button>
|
|
||||||
|
|
||||||
<a href={ROUTE_CONSTANTS.Search} className="text-blue-500 underline hover:text-blue-700 duration-300">
|
<a href={ROUTE_CONSTANTS.Search} className="text-blue-500 underline hover:text-blue-700 duration-300">
|
||||||
|
View all recipes here
|
||||||
</a>
|
</a>
|
||||||
</p>
|
</p>
|
||||||
</section>
|
</section>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user