From db5f30a960f58a7c8afe7229c896fe2a82470fcd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1rio=20Nunes?= Date: Sun, 7 Jul 2024 10:05:40 +0100 Subject: [PATCH 1/2] chore: refactor categories --- src/pages/Howto/Category/CategoriesSelect.tsx | 50 ----------------- .../Howto/Content/Common/Howto.form.test.tsx | 3 -- src/pages/Howto/Content/Common/Howto.form.tsx | 3 +- .../Content/Common/HowtoFieldCategory.tsx | 46 ++++++++++------ .../Research/Content/Common/Research.form.tsx | 18 +------ .../Content/Common/ResearchCategorySelect.tsx | 42 +++++++++++++++ .../Research/Content/ResearchFilterHeader.tsx | 3 +- src/pages/Research/Content/ResearchList.tsx | 3 +- .../Research/Content/ResearchSearchParams.ts | 6 +++ src/pages/Research/research.routes.test.tsx | 12 +++-- src/pages/Research/research.service.ts | 7 --- src/stores/Categories/categories.store.tsx | 44 --------------- .../questionCategories.store.tsx | 54 ------------------- .../researchCategories.store.tsx | 54 ------------------- src/stores/RootStore.tsx | 9 ---- 15 files changed, 94 insertions(+), 260 deletions(-) delete mode 100644 src/pages/Howto/Category/CategoriesSelect.tsx create mode 100644 src/pages/Research/Content/Common/ResearchCategorySelect.tsx create mode 100644 src/pages/Research/Content/ResearchSearchParams.ts delete mode 100644 src/stores/Categories/categories.store.tsx delete mode 100644 src/stores/QuestionCategories/questionCategories.store.tsx delete mode 100644 src/stores/ResearchCategories/researchCategories.store.tsx diff --git a/src/pages/Howto/Category/CategoriesSelect.tsx b/src/pages/Howto/Category/CategoriesSelect.tsx deleted file mode 100644 index c007c69b51..0000000000 --- a/src/pages/Howto/Category/CategoriesSelect.tsx +++ /dev/null @@ -1,50 +0,0 @@ -import { observer } from 'mobx-react' -import { Select } from 'oa-components' -import { useCommonStores } from 'src/common/hooks/useCommonStores' - -import { FieldContainer } from '../../../common/Form/FieldContainer' - -import type { ICategory } from 'src/models/categories.model' - -/** - * @deprecated in favor of CategoriesSelectV2 - */ -export const CategoriesSelect = observer( - ({ value, onChange, placeholder, isForm, type }) => { - const { categoriesStore, researchCategoriesStore } = - useCommonStores().stores - - let categories: ICategory[] = [] - if (type === 'howto') { - categories = categoriesStore.allCategories - } else if (type === 'research') { - categories = researchCategoriesStore.allResearchCategories - } - - const selectOptions = categories - .map((category) => ({ - value: { ...category }, - label: category.label, - })) - .filter((option) => option?.value?.label !== value?.label) - - const handleChange = (changedValue) => { - onChange(changedValue?.value ?? null) - } - - return ( - -