Skip to content
16 changes: 16 additions & 0 deletions __tests__/__snapshots__/index.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,17 @@ Object {
"getSkillTagsDone": [Function],
"getSkillTagsInit": [Function],
},
"memberSearch": Object {
"checkIfSearchTermIsATag": [Function],
"clearMemberSearch": [Function],
"loadMoreUsernames": [Function],
"memberSearchSuccess": [Function],
"resetSearchTerm": [Function],
"setSearchTag": [Function],
"setSearchTerm": [Function],
"topMemberSearchSuccess": [Function],
"usernameSearchSuccess": [Function],
},
"memberTasks": Object {
"dropAll": [Function],
"getDone": [Function],
Expand Down Expand Up @@ -240,6 +251,7 @@ Object {
"groups": [Function],
"looker": [Function],
"lookup": [Function],
"memberSearch": [Function],
"memberTasks": [Function],
"members": [Function],
"mySubmissionsManagement": [Function],
Expand Down Expand Up @@ -292,6 +304,10 @@ Object {
"default": undefined,
"getService": [Function],
},
"memberSearch": Object {
"default": undefined,
"getService": [Function],
},
"members": Object {
"default": undefined,
"getService": [Function],
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"lint:js": "./node_modules/.bin/eslint --ext .js,.jsx .",
"test": "npm run lint && npm run jest"
},
"version": "0.11.1",
"version": "0.12.0",
"dependencies": {
"auth0-js": "^6.8.4",
"config": "^3.2.0",
Expand Down
2 changes: 2 additions & 0 deletions src/actions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import reviewOpportunityActions from './reviewOpportunity';
import lookupActions from './lookup';
import settingsActions from './settings';
import lookerActions from './looker';
import memberSearchActions from './member-search';

export const actions = {
auth: authActions.auth,
Expand All @@ -30,6 +31,7 @@ export const actions = {
lookup: lookupActions.lookup,
settings: settingsActions.settings,
looker: lookerActions.looker,
memberSearch: memberSearchActions.memberSearch,
};

export default undefined;
80 changes: 80 additions & 0 deletions src/actions/member-search.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
/**
* @module "actions.member-search"
* @desc Actions for management of members search.
*/
import _ from 'lodash';
import { createActions } from 'redux-actions';
import { getService } from '../services/member-search';

/**
* @desc Creates an action that fetchs the members data for a search term, and
* adds result to the store cumulatively.
* @param {String} searchTerm the search term
* @param {Number} offset the number of records to skip
* @param {Number} limit the maximum number of the return results
* @return {Action}
*/
function loadMemberSearch(searchTerm, offset = 0, limit = 10) {
return getService().getUsernameMatches(searchTerm, offset, limit);
}

/**
* @static
* @desc Creates an action that fetchs the members data for a search tag, and
* adds result to the store.
* @param {Object} tag the tag
* @return {Action}
*/
function loadMemberSearchForTag(tag) {
return getService().getTopMembers(tag);
}

/**
* @static
* @desc Creates an action that check if the term is a tag name. If it is unable to check,
* or invalid data returned then resets the members data and search terms data in the store
* to intial values.
* @param {String} searchTerm the search term
* @return {Action}
*/
function checkIfSearchTermIsATag(searchTerm) {
return getService().checkIfSearchTermIsATag(searchTerm);
}

/**
* @static
* @desc Creates an action that saves the current search term.
* @param {String} searchTerm the search term
* @return {Action}
*/
function setSearchTerm(searchTerm) {
return {
previousSearchTerm: searchTerm,
};
}

/**
* @static
* @desc Creates an action that saves the current search tag.
* @param {Object} searchTag the search tag
* @return {Action}
*/
function setSearchTag(searchTag) {
return {
searchTermTag: searchTag,
};
}

export default createActions({
MEMBER_SEARCH: {
USERNAME_SEARCH_SUCCESS: loadMemberSearch,
CHECK_IF_SEARCH_TERM_IS_A_TAG: checkIfSearchTermIsATag,
TOP_MEMBER_SEARCH_SUCCESS: loadMemberSearchForTag,
CLEAR_MEMBER_SEARCH: _.noop,
LOAD_MORE_USERNAMES: _.noop,
MEMBER_SEARCH_SUCCESS: _.noop,
SET_SEARCH_TERM: setSearchTerm,
SET_SEARCH_TAG: setSearchTag,
RESET_SEARCH_TERM: _.noop,
},
});
4 changes: 3 additions & 1 deletion src/reducers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import settings, { factory as settingsFactory }
from './settings';
import looker, { factory as lookerFactory }
from './looker';

import memberSearch, { factory as memberSearchFactory } from './member-search';

export function factory(options) {
return redux.resolveReducers({
Expand All @@ -41,6 +41,7 @@ export function factory(options) {
mySubmissionsManagement: mySubmissionsManagementFactory(options),
settings: settingsFactory(options),
looker: lookerFactory(options),
memberSearch: memberSearchFactory(options),
});
}

Expand All @@ -60,4 +61,5 @@ export default ({
mySubmissionsManagement,
settings,
looker,
memberSearch,
});
Loading
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy