2017-06-06 23:19:12 +02:00
|
|
|
import { createSelector } from "reselect";
|
2017-08-30 14:48:32 +02:00
|
|
|
import { selectPageTitle, selectCurrentPage } from "selectors/navigation";
|
2017-04-24 16:17:36 +02:00
|
|
|
|
2017-06-06 06:21:55 +02:00
|
|
|
export const _selectState = state => state.search || {};
|
2017-04-24 16:17:36 +02:00
|
|
|
|
2017-05-11 02:59:47 +02:00
|
|
|
export const selectSearchQuery = createSelector(
|
2017-05-12 01:28:43 +02:00
|
|
|
_selectState,
|
2017-06-06 23:19:12 +02:00
|
|
|
state => state.query
|
2017-06-06 06:21:55 +02:00
|
|
|
);
|
2017-05-11 02:59:47 +02:00
|
|
|
|
2017-04-24 16:17:36 +02:00
|
|
|
export const selectIsSearching = createSelector(
|
|
|
|
_selectState,
|
2017-06-06 23:19:12 +02:00
|
|
|
state => !!state.searching
|
2017-06-06 06:21:55 +02:00
|
|
|
);
|
2017-04-24 16:17:36 +02:00
|
|
|
|
|
|
|
export const selectSearchResults = createSelector(
|
|
|
|
_selectState,
|
2017-06-06 23:19:12 +02:00
|
|
|
state => state.results || {}
|
2017-06-06 06:21:55 +02:00
|
|
|
);
|
2017-04-24 16:17:36 +02:00
|
|
|
|
|
|
|
export const selectSearchResultsByQuery = createSelector(
|
|
|
|
selectSearchResults,
|
2017-06-06 23:19:12 +02:00
|
|
|
results => results.byQuery || {}
|
2017-06-06 06:21:55 +02:00
|
|
|
);
|
2017-04-24 16:17:36 +02:00
|
|
|
|
|
|
|
export const selectCurrentSearchResults = createSelector(
|
|
|
|
selectSearchQuery,
|
|
|
|
selectSearchResultsByQuery,
|
2017-05-11 02:59:47 +02:00
|
|
|
(query, byQuery) => byQuery[query]
|
2017-06-06 06:21:55 +02:00
|
|
|
);
|
2017-05-07 14:50:32 +02:00
|
|
|
|
2017-05-11 02:59:47 +02:00
|
|
|
export const selectWunderBarAddress = createSelector(
|
2017-05-12 01:28:43 +02:00
|
|
|
selectCurrentPage,
|
2017-05-11 02:59:47 +02:00
|
|
|
selectPageTitle,
|
2017-05-07 14:50:32 +02:00
|
|
|
selectSearchQuery,
|
2017-06-06 23:19:12 +02:00
|
|
|
(page, title, query) => (page != "search" ? title : query ? query : title)
|
2017-06-06 06:21:55 +02:00
|
|
|
);
|
2017-05-07 14:50:32 +02:00
|
|
|
|
2017-06-06 06:21:55 +02:00
|
|
|
export const selectWunderBarIcon = createSelector(selectCurrentPage, page => {
|
2017-06-06 23:19:12 +02:00
|
|
|
switch (page) {
|
2017-08-26 05:21:26 +02:00
|
|
|
case "auth":
|
|
|
|
return "icon-user";
|
2017-06-06 23:19:12 +02:00
|
|
|
case "search":
|
|
|
|
return "icon-search";
|
|
|
|
case "settings":
|
|
|
|
return "icon-gear";
|
|
|
|
case "help":
|
|
|
|
return "icon-question";
|
|
|
|
case "report":
|
|
|
|
return "icon-file";
|
|
|
|
case "downloaded":
|
|
|
|
return "icon-folder";
|
|
|
|
case "published":
|
|
|
|
return "icon-folder";
|
|
|
|
case "start":
|
|
|
|
return "icon-file";
|
2017-08-20 23:42:00 +02:00
|
|
|
case "history":
|
|
|
|
return "icon-history";
|
2017-06-06 23:19:12 +02:00
|
|
|
case "send":
|
2017-08-20 23:42:00 +02:00
|
|
|
return "icon-send";
|
|
|
|
case "rewards":
|
|
|
|
return "icon-rocket";
|
|
|
|
case "invite":
|
|
|
|
return "icon-envelope-open";
|
2017-08-22 23:19:33 +02:00
|
|
|
case "address":
|
2017-08-25 21:51:54 +02:00
|
|
|
case "receive":
|
2017-08-22 23:19:33 +02:00
|
|
|
return "icon-address-book";
|
2017-08-20 23:42:00 +02:00
|
|
|
case "wallet":
|
2017-08-09 21:12:02 +02:00
|
|
|
case "backup":
|
2017-06-06 23:19:12 +02:00
|
|
|
return "icon-bank";
|
|
|
|
case "show":
|
|
|
|
return "icon-file";
|
|
|
|
case "publish":
|
|
|
|
return "icon-upload";
|
|
|
|
case "developer":
|
|
|
|
return "icon-code";
|
|
|
|
case "discover":
|
|
|
|
return "icon-home";
|
2017-08-20 23:42:00 +02:00
|
|
|
default:
|
|
|
|
return "icon-file";
|
2017-05-07 14:50:32 +02:00
|
|
|
}
|
2017-06-06 06:21:55 +02:00
|
|
|
});
|