Skip to content

Commit

Permalink
allow for more categories to be returned from backend (#590)
Browse files Browse the repository at this point in the history
  • Loading branch information
mcanoy authored Mar 10, 2022
1 parent d644fdf commit a663aef
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ export function CategoryTypeahead({
aria-labelledby={'titleId'}
placeholderText="Add new tag"
isCreatable={true}
maxHeight={300}
>
{options}
</Select>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export function EngagementEditableCategories() {
useEffect(() => {
if (!hasFetched && categories?.length === 0) {
setHasFetched(true);
fetchCategories();
fetchCategories({ page: 1, perPage: 1000});
}
}, [categories, hasFetched, setHasFetched, fetchCategories]);

Expand Down
8 changes: 4 additions & 4 deletions src/context/category_context/category_context.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import React, { createContext, useContext, useState } from 'react';
import { EngagementCategory } from '../../schemas/engagement_category';
import { CategoryService } from '../../services/category_service/category_service';
import { CategoryFilter, CategoryService } from '../../services/category_service/category_service';

export interface ICategoryContext {
fetchCategories: () => void;
categories: EngagementCategory[];
}

export const CategoryContext = createContext<ICategoryContext>({
fetchCategories: () => {},
fetchCategories: (filter?: CategoryFilter) => {},
categories: [],
});

Expand All @@ -22,8 +22,8 @@ export const CategoryProvider = ({
categoryService,
}: CategoryProviderProps) => {
const [categories, setCategories] = useState<EngagementCategory[]>([]);
const fetchCategories = async () => {
const fetched = await categoryService.fetchCategories();
const fetchCategories = async (filter?: CategoryFilter) => {
const fetched = await categoryService.fetchCategories(filter);
setCategories(fetched);
};
return (
Expand Down

0 comments on commit a663aef

Please sign in to comment.