aboutsummaryrefslogtreecommitdiff
path: root/src/screens
diff options
context:
space:
mode:
authorankit-thanekar007 <ankit.thanekar007@gmail.com>2021-03-02 17:28:02 -0800
committerankit-thanekar007 <ankit.thanekar007@gmail.com>2021-03-03 12:44:59 -0800
commitaf349a745bb00b5260f84909320d511ae9d0af2b (patch)
tree933466f75f93f5a61162d6e30fd6529890d7bc90 /src/screens
parent7a5ae728ee96acdf6b52fefa6ebaf7640a8724a1 (diff)
updated formatting, minor changes and integration testing
Diffstat (limited to 'src/screens')
-rw-r--r--src/screens/search/SearchScreen.tsx100
-rw-r--r--src/screens/search/mock.ts4
2 files changed, 67 insertions, 37 deletions
diff --git a/src/screens/search/SearchScreen.tsx b/src/screens/search/SearchScreen.tsx
index c3bd9fec..39b0425d 100644
--- a/src/screens/search/SearchScreen.tsx
+++ b/src/screens/search/SearchScreen.tsx
@@ -21,7 +21,11 @@ import {
SearchResultList,
TabsGradient,
} from '../../components';
-import {SEARCH_ENDPOINT, TAGG_LIGHT_BLUE} from '../../constants';
+import {
+ SEARCH_ENDPOINT,
+ SEARCH_V2_ENDPOINT,
+ TAGG_LIGHT_BLUE,
+} from '../../constants';
import {loadRecentlySearched, resetScreenType} from '../../store/actions';
import {RootState} from '../../store/rootReducer';
import {ProfilePreviewType, ScreenType, UserType} from '../../types';
@@ -40,7 +44,7 @@ const NO_USER: UserType = {
const SearchScreen: React.FC = () => {
const {recentSearches} = useSelector((state: RootState) => state.taggUsers);
const [query, setQuery] = useState<string>('');
- const [results, setResults] = useState([]);
+ const [results, setResults] = useState(Array<any>());
const [recents, setRecents] = useState<Array<ProfilePreviewType>>(
recentSearches ?? [],
);
@@ -65,40 +69,62 @@ const SearchScreen: React.FC = () => {
setResults([]);
return;
}
- const loadResults = async (q: string) => {
- // try {
- // const token = await AsyncStorage.getItem('token');
- // const response = await fetch(`${SEARCH_ENDPOINT}?query=${q}`, {
- // method: 'GET',
- // headers: {
- // Authorization: 'Token ' + token,
- // },
- // });
- // const status = response.status;
- // if (status === 200) {
- // let searchResults = await response.json();
- // setResults(searchResults);
- // return;
- // }
- // setResults([]);
- // } catch (error) {
- // console.log(error);
- // setResults([]);
- // }
- const searchResults = MockResults();
- const sanitizedResult = [
- {
- title: 'categories',
- data: searchResults.categories,
- },
- {
- title: 'users',
- data: searchResults.users,
- },
- ];
- setResults(sanitizedResult);
- };
- loadResults(query);
+ // const loadResults = async (q: string) => {
+ // try {
+ // const token = await AsyncStorage.getItem('token');
+ // const response = await fetch(`${SEARCH_V2_ENDPOINT}?query=${q}`, {
+ // method: 'GET',
+ // headers: {
+ // Authorization: 'Token ' + token,
+ // },
+ // });
+ // const {status} = response;
+ // if (status === 200) {
+ // const searchResults = await response.json();
+ // const sanitizedResult = [
+ // {
+ // title: 'categories',
+ // data: searchResults.categories,
+ // },
+ // {
+ // title: 'users',
+ // data: searchResults.users,
+ // },
+ // ];
+ // setResults(sanitizedResult);
+ // } else {
+ // const searchResults = MockResults();
+ // const sanitizedResult = [
+ // {
+ // title: 'categories',
+ // data: searchResults.categories,
+ // },
+ // {
+ // title: 'users',
+ // data: searchResults.users,
+ // },
+ // ];
+ // setResults(sanitizedResult);
+ // }
+ // setResults([]);
+ // } catch (error) {
+ // console.log(error);
+ // setResults([]);
+ // }
+ // };
+ const searchResults = MockResults();
+ const sanitizedResult = [
+ {
+ title: 'categories',
+ data: searchResults.categories,
+ },
+ {
+ title: 'users',
+ data: searchResults.users,
+ },
+ ];
+ setResults(sanitizedResult);
+ // loadResults(query);
}, [query]);
/**
@@ -175,7 +201,7 @@ const SearchScreen: React.FC = () => {
/>
<Explore />
<SearchResultsBackground {...{top}}>
- {results && Object.keys(results).length === 0 ? (
+ {results && results.length === 0 ? (
<RecentSearches
sectionTitle="Recent"
sectionButtonTitle="Clear all"
diff --git a/src/screens/search/mock.ts b/src/screens/search/mock.ts
index fafa34c9..d9909b22 100644
--- a/src/screens/search/mock.ts
+++ b/src/screens/search/mock.ts
@@ -4,18 +4,22 @@ const MockResults = () => {
{
id: 11,
name: "Brown '21",
+ category: 'Brown',
},
{
id: 12,
name: "Brown '22",
+ category: 'Brown',
},
{
id: 13,
name: "Brown '23",
+ category: null,
},
{
id: 14,
name: "Brown '24",
+ category: null,
},
],
users: [