From 2574c90754d9c76d3499ca28c000f130334bbdef Mon Sep 17 00:00:00 2001 From: harshil Sharma Date: Sun, 22 Oct 2023 07:48:38 +0530 Subject: [PATCH] WIP --- app/components/no_results_with_term/index.tsx | 2 +- app/components/team_list/index.tsx | 3 +++ .../convert_gm_to_channel/team_selector.tsx | 16 ++++++++------ .../team_selector_list/team_selector_list.tsx | 22 +++++++++++++++---- 4 files changed, 31 insertions(+), 12 deletions(-) diff --git a/app/components/no_results_with_term/index.tsx b/app/components/no_results_with_term/index.tsx index c7887a983..afe466d5e 100644 --- a/app/components/no_results_with_term/index.tsx +++ b/app/components/no_results_with_term/index.tsx @@ -50,7 +50,7 @@ const NoResultsWithTerm = ({term, type}: Props) => { useEffect(() => { setTitleId(type === TabTypes.FILES ? t('mobile.no_results_with_term.files') : t('mobile.no_results_with_term.messages')); - setDefaultMessage(type === TabTypes.FILES ? 'No files matching “{term}”' : 'No matches found for “{term}”'); + setDefaultMessage(type === TabTypes.FILES ? 'No files matching “{term}”' : 'No matches fzxcxcound for “{term}”'); }, [type]); return ( diff --git a/app/components/team_list/index.tsx b/app/components/team_list/index.tsx index ff2e747ad..52e83e8ba 100644 --- a/app/components/team_list/index.tsx +++ b/app/components/team_list/index.tsx @@ -11,6 +11,7 @@ import Loading from '@components/loading'; import TeamListItem from './team_list_item'; import type TeamModel from '@typings/database/models/servers/team'; +import { logDebug } from '@app/utils/log'; type Props = { iconBackgroundColor?: string; @@ -68,6 +69,8 @@ export default function TeamList({ footer = (); } + logDebug(teams); + return ( { + const {formatMessage} = useIntl(); const theme = useTheme(); const styles = getStyleFromTheme(theme); - const {formatMessage} = useIntl(); - const label = formatMessage({id: 'channel_into.convert_gm_to_channel.team_selector.label', defaultMessage: 'Team'}); + const [selectedTeam, setSelectedTeam] = useState(); + const label = formatMessage({id: 'channel_into.convert_gm_to_channel.team_selector.label', defaultMessage: 'Team'}); const placeholder = formatMessage({id: 'channel_into.convert_gm_to_channel.team_selector.placeholder', defaultMessage: 'Select a Team'}); - const [selectedTeam, setSelectedTeam] = useState(''); - const selectTeam = useCallback((teamId: string) => { - setSelectedTeam(teamId); + const team = commonTeams.find((t) => t.id === teamId); + if (team) { + setSelectedTeam(team); + } }, []); const goToTeamSelectorList = preventDoubleTap(async () => { @@ -53,9 +55,9 @@ export const TeamSelector = ({commonTeams}: Props) => { ); }; diff --git a/app/screens/convert_gm_to_channel/team_selector_list/team_selector_list.tsx b/app/screens/convert_gm_to_channel/team_selector_list/team_selector_list.tsx index 51478fe30..9fc8eae22 100644 --- a/app/screens/convert_gm_to_channel/team_selector_list/team_selector_list.tsx +++ b/app/screens/convert_gm_to_channel/team_selector_list/team_selector_list.tsx @@ -1,13 +1,16 @@ // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. -import React, {useMemo} from 'react'; +import React, {useCallback, useMemo, useRef, useState} from 'react'; import {View} from 'react-native'; import TeamList from '@app/components/team_list'; import {useTheme} from '@app/context/theme'; import {changeOpacity, getKeyboardAppearanceFromTheme, makeStyleSheetFromTheme} from '@app/utils/theme'; import SearchBar from '@components/search'; +import { filter } from 'lodash'; +import { logDebug } from '@app/utils/log'; +import { loadDefs } from 'nock'; const getStyleSheet = makeStyleSheetFromTheme((theme: Theme) => ({ container: { @@ -29,6 +32,17 @@ const TeamSelectorList = ({teams, selectTeam}: Props) => { const color = useMemo(() => changeOpacity(theme.centerChannelColor, 0.72), [theme]); + const [filteredTeams, setFilteredTeam] = useState(teams); + + const handleOnChangeSearchText = useCallback((searchTerm: string) => { + logDebug(searchTerm); + if (searchTerm === '') { + setFilteredTeam(teams); + } else { + setFilteredTeam(teams.filter((team) => team.display_name.includes(searchTerm) || team.name.includes(searchTerm))); + } + }, [teams]); + return ( { placeholderTextColor={color} searchIconColor={color} testID='convert_gm_to_channel_team_search_bar' - onChangeText={selectTeam} + onChangeText={handleOnChangeSearchText} /> ''} + teams={filteredTeams} + onPress={selectTeam} />