aboutsummaryrefslogtreecommitdiff
path: root/src/client/react/reducers
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/react/reducers')
-rw-r--r--src/client/react/reducers/search.js (renamed from src/client/react/reducers/search.ts)23
-rw-r--r--src/client/react/reducers/search.test.js (renamed from src/client/react/reducers/search.test.ts)2
2 files changed, 8 insertions, 17 deletions
diff --git a/src/client/react/reducers/search.ts b/src/client/react/reducers/search.js
index 658d3ca..2a7e7a5 100644
--- a/src/client/react/reducers/search.ts
+++ b/src/client/react/reducers/search.js
@@ -1,16 +1,7 @@
-import * as fuzzy from 'fuzzy';
-import users, { User } from '../users';
-import { InputChangeAction, ChangeSelectedResultAction } from '../actions/search';
-
-export interface State {
- results: string[],
- selectedResult: string | null,
- isExactMatch: boolean,
-};
-
-export type Action = InputChangeAction | ChangeSelectedResultAction;
+import fuzzy from 'fuzzy';
+import users from '../users';
-const DEFAULT_STATE: State = {
+const DEFAULT_STATE = {
results: [
's/18562',
],
@@ -18,22 +9,22 @@ const DEFAULT_STATE: State = {
isExactMatch: false,
};
-function getSearchResults(allUsers: User[], query: string) {
+function getSearchResults(allUsers, query) {
if (query.trim() === '') {
return [];
}
const allResults = fuzzy.filter(query, allUsers, {
- extract: (user: User) => user.value,
+ extract: user => user.value,
});
const firstResults = allResults.splice(0, 4);
- const userIds = firstResults.map((result: { original: User }) => result.original.id);
+ const userIds = firstResults.map(result => result.original.id);
return userIds;
}
-const search = (state = DEFAULT_STATE, action: Action): State => {
+const search = (state = DEFAULT_STATE, action) => {
switch (action.type) {
case 'SEARCH/INPUT_CHANGE': {
const results = getSearchResults(users.allUsers, action.typedValue);
diff --git a/src/client/react/reducers/search.test.ts b/src/client/react/reducers/search.test.js
index 5869b81..e0ca18e 100644
--- a/src/client/react/reducers/search.test.ts
+++ b/src/client/react/reducers/search.test.js
@@ -1,4 +1,4 @@
-(<any>window).USERS = [
+window.USERS = [
{ type: 's', value: '18561' },
{ type: 's', value: '18562' },
{ type: 's', value: '18563' },