Skip to content
This repository was archived by the owner on May 4, 2023. It is now read-only.

Commit 3cd602c

Browse files
feat: connect queries with filters
1 parent 3cc4a56 commit 3cd602c

File tree

6 files changed

+30
-7
lines changed

6 files changed

+30
-7
lines changed

src/renderer/pages/FavoriteCookbooks.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@ export default function FavoriteCookbooks() {
1616
const { data, loading, error } = useQuery<{
1717
user: { cookbooks: AssistantCookbook[] };
1818
}>(GET_USER_SUBSCRIBED_COOKBOOKS, {
19-
variables: GET_USER_SUBSCRIBED_COOKBOOKS_VARIABLES,
19+
variables: {
20+
...GET_USER_SUBSCRIBED_COOKBOOKS_VARIABLES,
21+
name: filters.searchTerm,
22+
},
2023
});
2124

2225
const userCookbooks = data?.user?.cookbooks || [];

src/renderer/pages/FavoriteSnippets.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@ export default function MySnippets() {
1616
const { data, loading, error } = useQuery<{
1717
user: { recipes: AssistantRecipeWithStats[] };
1818
}>(GET_USER_SUBSCRIBED_RECIPES, {
19-
variables: GET_USER_SUBSCRIBED_RECIPES_VARIABLES,
19+
variables: {
20+
...GET_USER_SUBSCRIBED_RECIPES_VARIABLES,
21+
name: filters.searchTerm,
22+
},
2023
});
2124

2225
const userFavoriteRecipes = data?.user?.recipes || [];

src/renderer/pages/MyCookbooks.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@ export default function MyCookbooks() {
1616
const { data, loading, error } = useQuery<{
1717
user: { cookbooks: AssistantCookbook[] };
1818
}>(GET_USER_COOKBOOKS, {
19-
variables: GET_USER_COOKBOOKS_VARIABLES,
19+
variables: {
20+
...GET_USER_COOKBOOKS_VARIABLES,
21+
name: filters.searchTerm,
22+
},
2023
});
2124

2225
const userCookbooks = data?.user?.cookbooks || [];

src/renderer/pages/MySnippets.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,12 @@ export default function MySnippets() {
1616
const { data, loading, error } = useQuery<{
1717
user: { recipes: AssistantRecipeWithStats[] };
1818
}>(GET_USER_RECIPES, {
19-
variables: GET_USER_RECIPES_VARIABLES,
19+
variables: {
20+
...GET_USER_RECIPES_VARIABLES,
21+
name: filters.searchTerm,
22+
language: filters.language,
23+
tag: filters.tags,
24+
},
2025
});
2126

2227
const userRecipes = data?.user?.recipes || [];

src/renderer/pages/TeamCookbooks.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,17 @@ export default function TeamCookbooks() {
1616
const { data, loading, error } = useQuery<{
1717
cookbooks: AssistantCookbook[];
1818
}>(GET_SHARED_COOKBOOKS, {
19-
variables: GET_SHARED_COOKBOOKS_VARIABLES,
19+
variables: {
20+
...GET_SHARED_COOKBOOKS_VARIABLES,
21+
name: filters.searchTerm,
22+
},
2023
});
2124

2225
const userCookbooks = data?.cookbooks || [];
2326

2427
// check the recipe against the search filters
2528
const filteredCookbooks = userCookbooks.filter((cookbook) => {
2629
if (!filterBy.name(filters, cookbook.name)) return false;
27-
// if (!filterBy.language(filters, cookbook.language)) return false;
2830
if (!filterBy.privacy(filters, cookbook.isPublic)) return false;
2931
if (!filterBy.isSubscribed(filters, cookbook.isSubscribed)) return false;
3032
return true;

src/renderer/pages/TeamSnippets.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,21 @@ import SnippetTableEmptyFiltereed from 'renderer/components/SnippetTable/Snippet
99
import SnippetTable from 'renderer/components/SnippetTable/SnippetTable';
1010
import filterBy from 'renderer/components/Filters/filterBy';
1111
import { useFilters } from 'renderer/components/FiltersContext';
12+
import { Language } from 'renderer/lib/constants';
1213

1314
export default function TeamSnippets() {
1415
const filters = useFilters();
1516

1617
const { data, loading, error } = useQuery<{
1718
recipes: AssistantRecipeWithStats[];
1819
}>(GET_SHARED_RECIPES, {
19-
variables: GET_SHARED_RECIPES_VARIABLES,
20+
variables: {
21+
...GET_SHARED_RECIPES_VARIABLES,
22+
name: filters.searchTerm,
23+
languages:
24+
filters.language !== Language.ALL_LANGUAGES ? [filters.language] : null,
25+
tag: filters.tags,
26+
},
2027
});
2128

2229
const teamRecipes = data?.recipes || [];

0 commit comments

Comments
 (0)