From a663aeff0b3bb3ba198469f59935282a0cb19980 Mon Sep 17 00:00:00 2001 From: Kevin McAnoy Date: Thu, 10 Mar 2022 15:36:38 -0800 Subject: [PATCH] allow for more categories to be returned from backend (#590) --- .../engagement_categories/category_typeahead.tsx | 1 + .../engagement_editable_categories.tsx | 2 +- src/context/category_context/category_context.tsx | 8 ++++---- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/components/engagement_categories/category_typeahead.tsx b/src/components/engagement_categories/category_typeahead.tsx index 1bd944b8..f92b6496 100644 --- a/src/components/engagement_categories/category_typeahead.tsx +++ b/src/components/engagement_categories/category_typeahead.tsx @@ -63,6 +63,7 @@ export function CategoryTypeahead({ aria-labelledby={'titleId'} placeholderText="Add new tag" isCreatable={true} + maxHeight={300} > {options} diff --git a/src/components/engagement_categories/engagement_editable_categories.tsx b/src/components/engagement_categories/engagement_editable_categories.tsx index 29f43934..8ba15b12 100644 --- a/src/components/engagement_categories/engagement_editable_categories.tsx +++ b/src/components/engagement_categories/engagement_editable_categories.tsx @@ -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]); diff --git a/src/context/category_context/category_context.tsx b/src/context/category_context/category_context.tsx index 042c2422..736cbe53 100644 --- a/src/context/category_context/category_context.tsx +++ b/src/context/category_context/category_context.tsx @@ -1,6 +1,6 @@ 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; @@ -8,7 +8,7 @@ export interface ICategoryContext { } export const CategoryContext = createContext({ - fetchCategories: () => {}, + fetchCategories: (filter?: CategoryFilter) => {}, categories: [], }); @@ -22,8 +22,8 @@ export const CategoryProvider = ({ categoryService, }: CategoryProviderProps) => { const [categories, setCategories] = useState([]); - const fetchCategories = async () => { - const fetched = await categoryService.fetchCategories(); + const fetchCategories = async (filter?: CategoryFilter) => { + const fetched = await categoryService.fetchCategories(filter); setCategories(fetched); }; return (