From 445a0315caed56f37560bbd5f514d40ecb679237 Mon Sep 17 00:00:00 2001 From: Jakub Szymczak Date: Wed, 25 Sep 2024 08:53:47 +0200 Subject: [PATCH] fix linter --- .../Search/SearchRouter/SearchRouter.tsx | 35 +++++++++---------- .../Search/SearchRouter/SearchRouterInput.tsx | 12 +++---- .../Search/SearchRouter/SearchRouterList.tsx | 7 ++-- src/components/Search/types.ts | 3 +- 4 files changed, 26 insertions(+), 31 deletions(-) diff --git a/src/components/Search/SearchRouter/SearchRouter.tsx b/src/components/Search/SearchRouter/SearchRouter.tsx index 94b5c75a626c..da7998a265e9 100644 --- a/src/components/Search/SearchRouter/SearchRouter.tsx +++ b/src/components/Search/SearchRouter/SearchRouter.tsx @@ -61,26 +61,23 @@ function SearchRouter() { setUserSearchQuery(undefined); }; - const onSearchChange = useCallback( - debounce((userQuery: string) => { - if (!userQuery) { - clearUserQuery(); - return; - } + const onSearchChange = debounce((userQuery: string) => { + if (!userQuery) { + clearUserQuery(); + return; + } - const queryJSON = SearchUtils.buildSearchQueryJSON(userQuery); + const queryJSON = SearchUtils.buildSearchQueryJSON(userQuery); - if (queryJSON) { - // eslint-disable-next-line - console.log('parsedQuery', queryJSON); + if (queryJSON) { + // eslint-disable-next-line + console.log('parsedQuery', queryJSON); - setUserSearchQuery(queryJSON); - } else { - // Handle query parsing error - } - }, SEARCH_DEBOUNCE_DELAY), - [], - ); + setUserSearchQuery(queryJSON); + } else { + // Handle query parsing error + } + }, SEARCH_DEBOUNCE_DELAY); const updateUserSearchQuery = (newSearchQuery: string) => { setTextInputValue(newSearchQuery); @@ -124,8 +121,8 @@ function SearchRouter() { { onSearchSubmit(userSearchQuery); diff --git a/src/components/Search/SearchRouter/SearchRouterInput.tsx b/src/components/Search/SearchRouter/SearchRouterInput.tsx index 1a067d22f1d9..ee5924002a06 100644 --- a/src/components/Search/SearchRouter/SearchRouterInput.tsx +++ b/src/components/Search/SearchRouter/SearchRouterInput.tsx @@ -1,26 +1,26 @@ -import React, {useState} from 'react'; +import React from 'react'; import BaseTextInput from '@components/TextInput/BaseTextInput'; import useThemeStyles from '@hooks/useThemeStyles'; import CONST from '@src/CONST'; type SearchRouterInputProps = { - text: string; - setText: (searchTerm: string) => void; + value: string; + setValue: (searchTerm: string) => void; updateSearch: (searchTerm: string) => void; onSubmit: () => void; }; -function SearchRouterInput({text, setText, updateSearch, onSubmit}: SearchRouterInputProps) { +function SearchRouterInput({value, setValue, updateSearch, onSubmit}: SearchRouterInputProps) { const styles = useThemeStyles(); const onChangeText = (text: string) => { - setText(text); + setValue(text); updateSearch(text); }; return ( { + // eslint-disable-next-line default-case switch (item.itemType) { case CONST.SEARCH.ROUTER_LIST_ITEM_TYPE.SEARCH: // Handle selection of "Recent search" if (!('query' in item) || !item?.query) { return; } - const queryJSON = SearchUtils.buildSearchQueryJSON(item?.query); - onSearchSubmit(queryJSON); + onSearchSubmit(SearchUtils.buildSearchQueryJSON(item?.query)); return; case CONST.SEARCH.ROUTER_LIST_ITEM_TYPE.CONTEXTUAL_SUGGESTION: // Handle selection of "Contextual search suggestion" @@ -120,10 +120,9 @@ function SearchRouterList({currentQuery, reportForContextualSearch, recentSearch } else if ('login' in item) { Report.navigateToAndOpenReport(item?.login ? [item.login] : []); } - return; } }, - [closeAndClearRouter, onSearchSubmit, currentQuery], + [closeAndClearRouter, onSearchSubmit, currentQuery, updateUserSearchQuery], ); return ( diff --git a/src/components/Search/types.ts b/src/components/Search/types.ts index c76f8959533e..360d8e8fe902 100644 --- a/src/components/Search/types.ts +++ b/src/components/Search/types.ts @@ -1,6 +1,5 @@ import type {ValueOf} from 'react-native-gesture-handler/lib/typescript/typeUtils'; -import type {ListItemWithSingleIcon, SingleIconListItemProps} from '@components/SelectionList/Search/SingleIconListItem'; -import type {ListItemProps, UserListItemProps} from '@components/SelectionList/types'; +import type {ListItemWithSingleIcon} from '@components/SelectionList/Search/SingleIconListItem'; import type {OptionData} from '@libs/ReportUtils'; import type CONST from '@src/CONST'; import type {SearchDataTypes} from '@src/types/onyx/SearchResults';