Skip to content

Commit

Permalink
fix linter
Browse files Browse the repository at this point in the history
  • Loading branch information
SzymczakJ committed Sep 25, 2024
1 parent 96e309a commit 445a031
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 31 deletions.
35 changes: 16 additions & 19 deletions src/components/Search/SearchRouter/SearchRouter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -124,8 +121,8 @@ function SearchRouter() {
<FocusTrapForModal active={isSearchRouterDisplayed}>
<View style={[styles.flex1, styles.p3, modalWidth, styles.mh100, !isSmallScreenWidth && styles.mh85vh]}>
<SearchRouterInput
text={textInputValue}
setText={setTextInputValue}
value={textInputValue}
setValue={setTextInputValue}
updateSearch={onSearchChange}
onSubmit={() => {
onSearchSubmit(userSearchQuery);
Expand Down
12 changes: 6 additions & 6 deletions src/components/Search/SearchRouter/SearchRouterInput.tsx
Original file line number Diff line number Diff line change
@@ -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 (
<BaseTextInput
value={text}
value={value}
onChangeText={onChangeText}
onSubmitEditing={onSubmit}
autoFocus
Expand Down
7 changes: 3 additions & 4 deletions src/components/Search/SearchRouter/SearchRouterList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,14 @@ function SearchRouterList({currentQuery, reportForContextualSearch, recentSearch

const onSelectRow = useCallback(
(item: SearchRouterListItem) => {
// eslint-disable-next-line default-case
switch (item.itemType) {

Check failure on line 100 in src/components/Search/SearchRouter/SearchRouterList.tsx

View workflow job for this annotation

GitHub Actions / ESLint check

Switch is not exhaustive. Cases not matched: undefined

Check failure on line 100 in src/components/Search/SearchRouter/SearchRouterList.tsx

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Switch is not exhaustive. Cases not matched: undefined
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"
Expand All @@ -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 (
Expand Down
3 changes: 1 addition & 2 deletions src/components/Search/types.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down

0 comments on commit 445a031

Please sign in to comment.