Skip to content

Commit

Permalink
feat(recipes/api): add fetch-tips-by-id.js to fetch tips by recipe id
Browse files Browse the repository at this point in the history
The new file fetch-tips-by-id.js is added to fetch tips related to a specific recipe by its id. This
feature enhances the user experience by providing relevant tips for each recipe. The function is
exported in the index.js file for easy access and use in other parts of the application.
  • Loading branch information
timDeHof committed Nov 5, 2023
1 parent da69610 commit de66f72
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/features/recipes/api/fetch-tips-by-id.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { fetchTips } from "@/api/tips";
import { useQuery } from "@tanstack/react-query";

export function FetchTipsById(id) {
const fetch = "tips for: " + id;
return useQuery(["tips", fetch], () => fetchTips(id), {
enabled: !!id,
});
}
1 change: 1 addition & 0 deletions src/features/recipes/api/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from "./use-recipes";
export * from "./fetch-recipes";
export * from "./fetch-recipe-by-id";
export * from "./fetch-tips-by-id";

0 comments on commit de66f72

Please sign in to comment.