aboutsummaryrefslogtreecommitdiff
path: root/src/client/react/reducers
diff options
context:
space:
mode:
authorNoah Loomans <noahloomans@gmail.com>2018-01-06 12:11:19 +0100
committerNoah Loomans <noahloomans@gmail.com>2018-01-06 12:11:19 +0100
commit77dccd31b32ee0a9a53b2186bae231069c5ab152 (patch)
treef90c5c524f1d3536a1f6ab665a7350739f590b7a /src/client/react/reducers
parent95041dffbd23fe81802efd5fb25cffe492cdb551 (diff)
Revert "Move to typescript"
This reverts commit f0c8cf0e79f003514fd65a70def5820205955a77.
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' },