2017-06-06 23:19:12 +02:00
|
|
|
import { createSelector } from "reselect";
|
2017-09-17 03:50:44 +02:00
|
|
|
import {
|
|
|
|
selectPageTitle,
|
|
|
|
selectCurrentPage,
|
|
|
|
selectCurrentParams,
|
|
|
|
} 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-09-17 20:26:55 +02:00
|
|
|
selectCurrentPage,
|
|
|
|
selectCurrentParams,
|
|
|
|
(page, params) => (page === "search" ? params && params.query : null)
|
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-09-17 03:50:44 +02:00
|
|
|
export const selectWunderBarIcon = createSelector(
|
|
|
|
selectCurrentPage,
|
|
|
|
selectCurrentParams,
|
|
|
|
(page, params) => {
|
|
|
|
switch (page) {
|
|
|
|
case "auth":
|
|
|
|
return "icon-user";
|
|
|
|
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 "history":
|
|
|
|
return "icon-history";
|
|
|
|
case "send":
|
|
|
|
return "icon-send";
|
|
|
|
case "rewards":
|
|
|
|
return "icon-rocket";
|
|
|
|
case "invite":
|
|
|
|
return "icon-envelope-open";
|
|
|
|
case "address":
|
|
|
|
case "receive":
|
|
|
|
return "icon-address-book";
|
|
|
|
case "wallet":
|
|
|
|
case "backup":
|
|
|
|
return "icon-bank";
|
|
|
|
case "show":
|
|
|
|
return "icon-file";
|
|
|
|
case "publish":
|
|
|
|
return params.id ? __("icon-pencil") : __("icon-upload");
|
|
|
|
case "developer":
|
|
|
|
return "icon-code";
|
|
|
|
case "discover":
|
|
|
|
return "icon-home";
|
|
|
|
default:
|
|
|
|
return "icon-file";
|
|
|
|
}
|
2017-05-07 14:50:32 +02:00
|
|
|
}
|
2017-09-17 03:50:44 +02:00
|
|
|
);
|