diff --git a/src/components/Search/FreeSearchForm.tsx b/src/components/Search/FreeSearchForm.tsx index 8658b91c..8f815a21 100644 --- a/src/components/Search/FreeSearchForm.tsx +++ b/src/components/Search/FreeSearchForm.tsx @@ -162,8 +162,6 @@ const FreeSearchForm = ({ const handleSetSearchWord = useCallback( (value: string) => setSearchState((current) => { - // TODO: here user must be notified if selected value is duplicate - // TODO: searchWordDuplicates contains duplicates return { ...current, searchWord: value }; }), [], diff --git a/src/utils/buildSearchParams.ts b/src/utils/buildSearchParams.ts index b31aa75a..0af1d804 100644 --- a/src/utils/buildSearchParams.ts +++ b/src/utils/buildSearchParams.ts @@ -1,8 +1,13 @@ -import { FreeSearchFormObject, IOption } from '@/interfaces/common'; +import { FreeSearchFormItem, FreeSearchFormObject, IOption } from '@/interfaces/common'; import { ISearchForm } from '@/interfaces/formInterfaces'; // Build a search parameter with all the choices from the search form const buildSearchParams = (form: ISearchForm) => { + const typeToParam: {[key in FreeSearchFormItem['type']]?: string} = { + projects: 'projectName', + groups: 'group', + hashtags: 'hashtag' + }; const searchParams = []; for (const [key, value] of Object.entries(form)) { switch (key) { @@ -29,8 +34,14 @@ const buildSearchParams = (form: ISearchForm) => { break; case 'freeSearchParams': for (const [_, v] of Object.entries(value as FreeSearchFormObject)) { - const paramType = v.type.substring(0, v.type.length - 1); - searchParams.push(`${paramType}=${v.value}`); + const paramType = typeToParam[v.type]; + const paramValue = v.type === 'hashtags' ? v.value : v.label; + if (paramType === "hashtag") { + searchParams.push(`${paramType}=${paramValue}`); + } else { + searchParams.push(`projectName=${paramValue}`); + searchParams.push(`group=${paramValue}`); + } } break; default: