@@ -74,11 +72,9 @@ exports[`Matches shallow shapshot 2 shapshot 2 1`] = `
id="challengeFilterContainer"
>
@@ -134,7 +123,7 @@ exports[`Matches shallow shapshot 2 shapshot 2 1`] = `
top={20}
>
diff --git a/__tests__/shared/containers/challenge-listing/FilterPanel.jsx b/__tests__/shared/containers/challenge-listing/FilterPanel.jsx
index 2abd66ddf0..399355d7a7 100644
--- a/__tests__/shared/containers/challenge-listing/FilterPanel.jsx
+++ b/__tests__/shared/containers/challenge-listing/FilterPanel.jsx
@@ -1,10 +1,13 @@
-import { shallow, mount } from 'enzyme';
+// import { shallow, mount } from 'enzyme';
+import { shallow } from 'enzyme';
import React from 'react';
import configureStore from 'redux-mock-store';
-import Select from 'components/Select';
-import cActions from 'actions/challenge-listing';
-import sActions from 'actions/challenge-listing/sidebar';
-import ConnectedFilterPanel, { Container as FilterPanel } from 'containers/challenge-listing/FilterPanel';
+// import Select from 'components/Select';
+// import cActions from 'actions/challenge-listing';
+// import sActions from 'actions/challenge-listing/sidebar';
+// import ConnectedFilterPanel, { Container as FilterPanel }
+// from 'containers/challenge-listing/FilterPanel';
+import ConnectedFilterPanel from 'containers/challenge-listing/FilterPanel';
describe('shallow render connnected component', () => {
const initialState = {
@@ -15,8 +18,8 @@ describe('shallow render connnected component', () => {
trackModalShown: false,
},
sidebar: {
- activeBucket: 'ALL',
- savedFilters: [],
+ activeBucket: 'all',
+ // savedFilters: [],
},
communityFilters: [],
filter: {},
@@ -57,207 +60,206 @@ describe('shallow render connnected component', () => {
expect(instance).toBeDefined();
});
});
+// describe('full render pure component', () => {
+// const initialProps = {
+// expanded: false,
+// searchText: '',
+// trackModalShown: false,
+// activeBucket: 'all',
+// communityFilters: [],
+// filterState: {},
+// getAvailableFilterName: jest.fn(),
+// loadingKeywords: false,
+// loadingTypes: false,
+// validKeywords: [],
+// validTypes: [],
+// selectedCommunityId: '1',
+// tokenV2: 'tokenV2',
+// getTypes: jest.fn(),
+// getKeywords: jest.fn(),
+// saveFilter: jest.fn(),
+// selectBucket: jest.fn(),
+// selectCommunity: jest.fn(),
+// setFilterState: jest.fn(),
+// setExpanded: jest.fn(),
+// setSearchText: jest.fn(),
+// showTrackModal: jest.fn(),
+// setQuery: jest.fn(),
+// onSwitch: jest.fn(),
+// tcCommunities: {
+// list: {
+// data: [
+// {
+// communityId: '',
+// communityName: 'name',
+// },
+// {
+// communityId: '',
+// communityName: 'name',
+// },
+// ],
+// },
+// },
+// };
-describe('full render pure component', () => {
- const initialProps = {
- expanded: false,
- searchText: '',
- trackModalShown: false,
- activeBucket: 'ALL',
- communityFilters: [],
- filterState: {},
- getAvailableFilterName: jest.fn(),
- loadingKeywords: false,
- loadingTypes: false,
- validKeywords: [],
- validTypes: [],
- selectedCommunityId: '1',
- tokenV2: 'tokenV2',
- getTypes: jest.fn(),
- getKeywords: jest.fn(),
- saveFilter: jest.fn(),
- selectBucket: jest.fn(),
- selectCommunity: jest.fn(),
- setFilterState: jest.fn(),
- setExpanded: jest.fn(),
- setSearchText: jest.fn(),
- showTrackModal: jest.fn(),
- setQuery: jest.fn(),
- onSwitch: jest.fn(),
- tcCommunities: {
- list: {
- data: [
- {
- communityId: '',
- communityName: 'name',
- },
- {
- communityId: '',
- communityName: 'name',
- },
- ],
- },
- },
- };
+// let instance;
- let instance;
+// beforeEach(() => {
+// instance = mount(
);
+// jest.resetAllMocks();
+// });
- beforeEach(() => {
- instance = mount(
);
- jest.resetAllMocks();
- });
+// test('load data if not loading', () => {
+// instance = mount(
);
+// expect(initialProps.getTypes).toHaveBeenCalledTimes(1);
+// expect(initialProps.getKeywords).toHaveBeenCalledTimes(1);
+// });
- test('load data if not loading', () => {
- instance = mount(
);
- expect(initialProps.getTypes).toHaveBeenCalledTimes(1);
- expect(initialProps.getKeywords).toHaveBeenCalledTimes(1);
- });
+// test('do not load data if loading', () => {
+// instance = mount(
);
- test('do not load data if loading', () => {
- instance = mount(
);
+// expect(initialProps.getTypes).toHaveBeenCalledTimes(0);
+// expect(initialProps.getKeywords).toHaveBeenCalledTimes(0);
+// });
- expect(initialProps.getTypes).toHaveBeenCalledTimes(0);
- expect(initialProps.getKeywords).toHaveBeenCalledTimes(0);
- });
+// test.skip('saveFilter', () => {
+// const button = instance.find('button.tc-blue-btn');
+// expect(initialProps.saveFilter).toHaveBeenCalledTimes(0);
+// button.simulate('click');
+// expect(initialProps.saveFilter).toHaveBeenCalledTimes(0);
+// });
- test.skip('saveFilter', () => {
- const button = instance.find('button.tc-blue-btn');
- expect(initialProps.saveFilter).toHaveBeenCalledTimes(0);
- button.simulate('click');
- expect(initialProps.saveFilter).toHaveBeenCalledTimes(0);
- });
+// test('setFilterState and selectBucket', () => {
+// const select = instance.find(Select)
+// .filterWhere(wrapper => wrapper.prop('id') === 'keyword-select');
+// expect(select).toHaveLength(1);
+// expect(initialProps.setFilterState).toHaveBeenCalledTimes(0);
+// select.prop('onChange')('1');
+// expect(initialProps.setFilterState).toHaveBeenCalledTimes(1);
+// });
+// test('selectBucket', () => {
+// instance = mount(
);
- test('setFilterState and selectBucket', () => {
- const select = instance.find(Select)
- .filterWhere(wrapper => wrapper.prop('id') === 'keyword-select');
- expect(select).toHaveLength(1);
- expect(initialProps.setFilterState).toHaveBeenCalledTimes(0);
- select.prop('onChange')('1');
- expect(initialProps.setFilterState).toHaveBeenCalledTimes(1);
- });
- test('selectBucket', () => {
- instance = mount(
);
+// const select = instance.find(Select)
+// .filterWhere(wrapper => wrapper.prop('id') === 'keyword-select');
+// expect(select).toHaveLength(1);
+// expect(initialProps.selectBucket).toHaveBeenCalledTimes(0);
+// select.prop('onChange')('1');
+// expect(initialProps.selectBucket).toHaveBeenCalledTimes(1);
+// });
+// });
- const select = instance.find(Select)
- .filterWhere(wrapper => wrapper.prop('id') === 'keyword-select');
- expect(select).toHaveLength(1);
- expect(initialProps.selectBucket).toHaveBeenCalledTimes(0);
- select.prop('onChange')('1');
- expect(initialProps.selectBucket).toHaveBeenCalledTimes(1);
- });
-});
+// describe('full render connnected component and dispatch actions', () => {
+// let originalFetch;
-describe('full render connnected component and dispatch actions', () => {
- let originalFetch;
+// beforeAll(() => {
+// originalFetch = global.fetch;
+// });
- beforeAll(() => {
- originalFetch = global.fetch;
- });
+// afterAll(() => {
+// global.fetch = originalFetch;
+// });
- afterAll(() => {
- global.fetch = originalFetch;
- });
+// const initialState = {
+// challengeListing: {
+// filterPanel: {
+// expanded: false,
+// searchText: '',
+// trackModalShown: false,
+// },
+// sidebar: {
+// activeBucket: 'all',
+// // savedFilters: [{ name: 'My Filter' }],
+// },
+// communityFilters: [],
+// filter: {},
+// loadingChallengeTags: true,
+// loadingChallengeTypes: true,
+// challengeTags: [],
+// challengeTypes: [],
+// selectedCommunityId: '1',
+// },
+// auth: {
+// tokenV2: 'tokenV2',
+// },
+// tcCommunities: {
+// list: {
+// data: [
+// {
+// communityId: '',
+// communityName: 'name',
+// },
+// {
+// communityId: '',
+// communityName: 'name',
+// },
+// ],
+// },
+// },
+// };
+// const mockStore = configureStore();
+// let store;
+// let instance;
+// let filterPanel;
- const initialState = {
- challengeListing: {
- filterPanel: {
- expanded: false,
- searchText: '',
- trackModalShown: false,
- },
- sidebar: {
- activeBucket: 'ALL',
- savedFilters: [{ name: 'My Filter' }],
- },
- communityFilters: [],
- filter: {},
- loadingChallengeTags: true,
- loadingChallengeTypes: true,
- challengeTags: [],
- challengeTypes: [],
- selectedCommunityId: '1',
- },
- auth: {
- tokenV2: 'tokenV2',
- },
- tcCommunities: {
- list: {
- data: [
- {
- communityId: '',
- communityName: 'name',
- },
- {
- communityId: '',
- communityName: 'name',
- },
- ],
- },
- },
- };
- const mockStore = configureStore();
- let store;
- let instance;
- let filterPanel;
-
- beforeEach(() => {
- global.fetch = () => Promise.resolve({
- ok: true,
- json: () => ({ result: { status: 200, metadata: {}, content: [] } }),
- });
- store = mockStore(initialState);
- instance = mount(
);
- filterPanel = instance.find(FilterPanel);
- });
+// beforeEach(() => {
+// global.fetch = () => Promise.resolve({
+// ok: true,
+// json: () => ({ result: { status: 200, metadata: {}, content: [] } }),
+// });
+// store = mockStore(initialState);
+// instance = mount(
);
+// filterPanel = instance.find(FilterPanel);
+// });
- test('getTypes', () => {
- global.fetch = () => Promise.resolve({
- ok: true,
- json: () => ([]),
- });
- filterPanel.prop('getTypes')();
- const actions = store.getActions();
- expect(actions[0].type).toEqual(cActions.challengeListing.getChallengeTypesInit.toString());
- expect(actions[1].type).toEqual(cActions.challengeListing.getChallengeTypesDone.toString());
- });
+// test('getTypes', () => {
+// global.fetch = () => Promise.resolve({
+// ok: true,
+// json: () => ([]),
+// });
+// filterPanel.prop('getTypes')();
+// const actions = store.getActions();
+// expect(actions[0].type).toEqual(cActions.challengeListing.getChallengeTypesInit.toString());
+// expect(actions[1].type).toEqual(cActions.challengeListing.getChallengeTypesDone.toString());
+// });
- test('getKeywords', () => {
- filterPanel.prop('getKeywords')();
- const actions = store.getActions();
- expect(actions[0].type).toEqual(cActions.challengeListing.getChallengeTagsInit.toString());
- expect(actions[1].type).toEqual(cActions.challengeListing.getChallengeTagsDone.toString());
- });
+// test('getKeywords', () => {
+// filterPanel.prop('getKeywords')();
+// const actions = store.getActions();
+// expect(actions[0].type).toEqual(cActions.challengeListing.getChallengeTagsInit.toString());
+// expect(actions[1].type).toEqual(cActions.challengeListing.getChallengeTagsDone.toString());
+// });
- test.skip('saveFilter', () => {
- filterPanel.prop('saveFilter')();
- const actions = store.getActions();
- expect(actions[0].type).toEqual(sActions.challengeListing.sidebar.saveFilterInit.toString());
- });
+// test.skip('saveFilter', () => {
+// filterPanel.prop('saveFilter')();
+// const actions = store.getActions();
+// expect(actions[0].type).toEqual(sActions.challengeListing.sidebar.saveFilterInit.toString());
+// });
- test('selectBucket', () => {
- filterPanel.prop('selectBucket')();
- const actions = store.getActions();
- expect(actions[0].type).toEqual(sActions.challengeListing.sidebar.selectBucket.toString());
- });
+// test('selectBucket', () => {
+// filterPanel.prop('selectBucket')();
+// const actions = store.getActions();
+// expect(actions[0].type).toEqual(sActions.challengeListing.sidebar.selectBucket.toString());
+// });
- test('selectCommunity', () => {
- filterPanel.prop('selectCommunity')();
- const actions = store.getActions();
- expect(actions[0].type).toEqual(cActions.challengeListing.selectCommunity.toString());
- });
+// test('selectCommunity', () => {
+// filterPanel.prop('selectCommunity')();
+// const actions = store.getActions();
+// expect(actions[0].type).toEqual(cActions.challengeListing.selectCommunity.toString());
+// });
- test('setFilterState', () => {
- filterPanel.prop('setFilterState')();
- const actions = store.getActions();
- expect(actions[0].type).toEqual(cActions.challengeListing.setFilter.toString());
- });
-});
+// test('setFilterState', () => {
+// filterPanel.prop('setFilterState')();
+// const actions = store.getActions();
+// expect(actions[0].type).toEqual(cActions.challengeListing.setFilter.toString());
+// });
+// });
diff --git a/__tests__/shared/reducers/challenge-listing/sidebar.js b/__tests__/shared/reducers/challenge-listing/sidebar.js
index 970d241b6a..f305b30aa7 100644
--- a/__tests__/shared/reducers/challenge-listing/sidebar.js
+++ b/__tests__/shared/reducers/challenge-listing/sidebar.js
@@ -1,222 +1,12 @@
-import { mock } from 'topcoder-react-lib';
-
-const { mockAction } = mock;
-
-jest.mock('utils/url', () => ({
- updateQuery: () => {},
-}));
const defaultReducer = require('reducers/challenge-listing/sidebar').default;
-const mockActions = {
- changeFilterName: (payload, error) => mockAction(
- 'CHALLENGE_LISTING/SIDEBAR/CHANGE_FILTER_NAME',
- payload,
- error,
- ),
- deleteSavedFilter: (payload, error) => mockAction(
- 'CHALLENGE_LISTING/SIDEBAR/DELETE_SAVED_FILTER',
- payload,
- error,
- ),
- dragSavedFilterMove: (payload, error) => mockAction(
- 'CHALLENGE_LISTING/SIDEBAR/DRAG_SAVED_FILTER_MOVE',
- payload,
- error,
- ),
- dragSavedFilterStart: (payload, error) => mockAction(
- 'CHALLENGE_LISTING/SIDEBAR/DRAG_SAVED_FILTER_START',
- payload,
- error,
- ),
- getSavedFilters: (payload, error) => mockAction(
- 'CHALLENGE_LISTING/SIDEBAR/GET_SAVED_FILTERS',
- payload,
- error,
- ),
- resetFilterName: (payload, error) => mockAction(
- 'CHALLENGE_LISTING/SIDEBAR/RESET_FILTER_NAME',
- payload,
- error,
- ),
- saveFilterDone: (payload, error) => mockAction(
- 'CHALLENGE_LISTING/SIDEBAR/SAVE_FILTER_DONE',
- payload,
- error,
- ),
- selectBucket: (payload, error) => mockAction(
- 'CHALLENGE_LISTING/SIDEBAR/SELECT_BUCKET',
- payload,
- error,
- ),
- selectSavedFilter: (payload, error) => mockAction(
- 'CHALLENGE_LISTING/SIDEBAR/SELECT_SAVED_FILTER',
- payload,
- error,
- ),
- setEditSavedFiltersMode: (payload, error) => mockAction(
- 'CHALLENGE_LISTING/SIDEBAR/SET_EDIT_SAVED_FILTERS_MODE',
- payload,
- error,
- ),
- updateSavedFilter: (payload, error) => mockAction(
- 'CHALLENGE_LISTING/SIDEBAR/UPDATE_SAVED_FILTER',
- payload,
- error,
- ),
-};
-
-let expectedState = {
+const expectedState = {
activeBucket: 'all',
- activeSavedFilter: 0,
- editSavedFiltersMode: false,
- isSavingFilter: false,
- savedFilters: [],
};
function testReducer(reducer) {
- let state;
-
test('creates expected initial state', () => {
- state = reducer(undefined, {});
- expect(state).toEqual(expectedState);
- });
-
- test('properly handles saveFilter', () => {
- state = reducer(state, mockActions.saveFilterDone({ name: 'name', filter: '"filter"' })());
- expectedState = {
- ...expectedState,
- activeBucket: 'saved-filter',
- activeSavedFilter: 0,
- savedFilters: [{ name: 'name', filter: 'filter' }],
- };
- expect(state).toEqual(expectedState);
- });
-
- test('properly handles changeFilterName', () => {
- state = reducer(state, mockActions.changeFilterName({ index: 0, name: 'other' })());
- expectedState = {
- ...expectedState,
- savedFilters: [{
- error: '',
- name: 'other',
- savedName: 'name',
- filter: 'filter',
- }],
- };
- expect(state).toEqual(expectedState);
- });
-
- test('properly handles deleteSavedFilter', () => {
- state = reducer(state, mockActions.deleteSavedFilter('id')());
- expect(state).toEqual(expectedState);
- });
-
- test('properly handles dragSavedFilterStart', () => {
- state = reducer(state, mockActions.dragSavedFilterStart('payload')());
- expectedState = {
- ...expectedState,
- dragState: 'payload',
- };
- expect(state).toEqual(expectedState);
- });
-
- test('properly handles dragSavedFilterMove', () => {
- state = reducer(state, mockActions.dragSavedFilterMove({ currentIndex: -1 })());
- expectedState = {
- ...expectedState,
- dragState: { currentIndex: 0 },
- };
- expect(state).toEqual(expectedState);
-
- state = reducer(state, mockActions.dragSavedFilterMove({ currentIndex: 2 })());
- expect(state).toEqual(expectedState);
-
- state = reducer(state, mockActions.dragSavedFilterMove({ currentIndex: 0 })());
- expect(state).toEqual(expectedState);
- });
-
- test('properly handles getSavedFilters', () => {
- const savedFilters = [{
- name: 'name', filter: 'filter', savedName: 'savedName', id: '1',
- }, { name: 'name2', filter: 'filter2' }];
- state = reducer(state, mockActions.getSavedFilters(savedFilters)());
- expectedState = {
- ...expectedState,
- savedFilters,
- };
- expect(state).toEqual(expectedState);
- });
-
- test('properly handles resetFilterName', () => {
- state = reducer(state, mockActions.resetFilterName(1)());
- expect(state).toEqual(expectedState);
-
- state = reducer(state, mockActions.resetFilterName(0)());
- expectedState = {
- ...expectedState,
- savedFilters: [{
- error: '',
- filter: 'filter',
- name: 'savedName',
- id: '1',
- }, { name: 'name2', filter: 'filter2' }],
- };
- expect(state).toEqual(expectedState);
- });
-
- test('properly handles selectBucket', () => {
- state = reducer(state, mockActions.selectBucket('all')());
- expectedState = {
- ...expectedState,
- activeBucket: 'all',
- isBucketSwitching: true,
- };
- expect(state).toEqual(expectedState);
-
- state = reducer(state, mockActions.selectBucket('saved-filter')());
- expectedState = {
- ...expectedState,
- activeBucket: 'saved-filter',
- isBucketSwitching: true,
- };
- expect(state).toEqual(expectedState);
-
- state = reducer(state, mockActions.selectBucket('upcoming')());
- expectedState = {
- ...expectedState,
- activeBucket: 'upcoming',
- isBucketSwitching: true,
- };
- expect(state).toEqual(expectedState);
- });
-
- test('properly handles selectSavedFilter', () => {
- state = reducer(state, mockActions.selectSavedFilter(1)());
- expectedState = {
- ...expectedState,
- activeBucket: 'saved-filter',
- activeSavedFilter: 1,
- isBucketSwitching: true,
- };
- expect(state).toEqual(expectedState);
- });
-
- test('properly handles setEditSavedFiltersMode', () => {
- state = reducer(state, mockActions.setEditSavedFiltersMode(true)());
- expectedState = {
- ...expectedState,
- editSavedFiltersMode: true,
- };
- expect(state).toEqual(expectedState);
- });
-
- test('properly handles updateSavedFilter', () => {
- state = reducer(state, mockActions.updateSavedFilter({ id: '1', filter: '"another filter"' })());
- expectedState = {
- ...expectedState,
- editSavedFiltersMode: true,
- savedFilters: [{ filter: 'another filter', id: '1' }, { name: 'name2', filter: 'filter2' }],
- };
+ const state = reducer(undefined, {});
expect(state).toEqual(expectedState);
});
}
diff --git a/config/jest/default.js b/config/jest/default.js
index bcf9b8d5af..8af45e1d4c 100644
--- a/config/jest/default.js
+++ b/config/jest/default.js
@@ -2,6 +2,7 @@ const config = require('topcoder-react-utils/config/jest/default');
const nodeConfig = require('config');
config.transformIgnorePatterns[0] = '/node_modules/(?!appirio-tech|topcoder|tc-)';
+// config.testMatch[0] = '**/__tests__/shared/containers/challenge-listing/FilterPanel.jsx';
// Include the directories whose tests has been written to minimize coverage time
config.collectCoverageFrom = ['src/client/*.{js,jsx}', 'src/server/*.{js,jsx}', 'src/shared/*.{js,jsx}'];
diff --git a/package-lock.json b/package-lock.json
index 3c35321344..7582e19cfd 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -3656,6 +3656,16 @@
"integrity": "sha1-aN/1++YMUes3cl6p4+0xDcwed24=",
"dev": true
},
+ "bourbon": {
+ "version": "4.3.4",
+ "resolved": "https://registry.npmjs.org/bourbon/-/bourbon-4.3.4.tgz",
+ "integrity": "sha1-TaOAAp6SwMj5dkx3lFGhNLEefMM="
+ },
+ "bourbon-neat": {
+ "version": "1.7.2",
+ "resolved": "https://registry.npmjs.org/bourbon-neat/-/bourbon-neat-1.7.2.tgz",
+ "integrity": "sha1-oiixJ0R53iR20yszFTEHylBTzz0="
+ },
"bowser": {
"version": "2.9.0",
"resolved": "https://registry.npmjs.org/bowser/-/bowser-2.9.0.tgz",
@@ -14673,7 +14683,7 @@
"dev": true
},
"navigation-component": {
- "version": "github:topcoder-platform/navigation-component#4938269d5610f3f8bff65f23459a37d01121e6f6",
+ "version": "github:topcoder-platform/navigation-component#0843a97144494ff06b21b7dc0ab2cb8412ef05eb",
"from": "github:topcoder-platform/navigation-component#develop",
"requires": {
"classnames": "^2.2.6",
@@ -14681,9 +14691,39 @@
"moment": "^2.24.0",
"prop-types": "^15.7.2",
"react-resize-detector": "^4.1.3",
+ "topcoder-react-lib": "v0.17.0",
"topcoder-react-utils": "^0.7.9"
},
"dependencies": {
+ "auth0-js": {
+ "version": "6.8.4",
+ "resolved": "https://registry.npmjs.org/auth0-js/-/auth0-js-6.8.4.tgz",
+ "integrity": "sha1-Qw3Uystk2NFdabHmIRhPmipkCmE=",
+ "requires": {
+ "Base64": "~0.1.3",
+ "json-fallback": "0.0.1",
+ "jsonp": "~0.0.4",
+ "qs": "git+https://github.com/jfromaniello/node-querystring.git#5d96513991635e3e22d7aa54a8584d6ce97cace8",
+ "reqwest": "^1.1.4",
+ "trim": "~0.0.1",
+ "winchan": "^0.1.1",
+ "xtend": "~2.1.1"
+ },
+ "dependencies": {
+ "qs": {
+ "version": "git+https://github.com/jfromaniello/node-querystring.git#5d96513991635e3e22d7aa54a8584d6ce97cace8",
+ "from": "git+https://github.com/jfromaniello/node-querystring.git#fix_ie7_bug_with_arrays"
+ }
+ }
+ },
+ "axios": {
+ "version": "0.12.0",
+ "resolved": "https://registry.npmjs.org/axios/-/axios-0.12.0.tgz",
+ "integrity": "sha1-uQewIhzDTsHJ+sGOx/B935V4W6Q=",
+ "requires": {
+ "follow-redirects": "0.0.7"
+ }
+ },
"config": {
"version": "3.3.1",
"resolved": "https://registry.npmjs.org/config/-/config-3.3.1.tgz",
@@ -14692,6 +14732,15 @@
"json5": "^2.1.1"
}
},
+ "follow-redirects": {
+ "version": "0.0.7",
+ "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-0.0.7.tgz",
+ "integrity": "sha1-NLkLqyqRGqNHVx2pDyK9NuzYqRk=",
+ "requires": {
+ "debug": "^2.2.0",
+ "stream-consume": "^0.1.0"
+ }
+ },
"hoist-non-react-statics": {
"version": "3.3.2",
"resolved": "https://registry.npmjs.org/hoist-non-react-statics/-/hoist-non-react-statics-3.3.2.tgz",
@@ -14708,6 +14757,11 @@
"minimist": "^1.2.5"
}
},
+ "object-keys": {
+ "version": "0.4.0",
+ "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-0.4.0.tgz",
+ "integrity": "sha1-KKaq50KN0sOpLz2V8hM13SBOAzY="
+ },
"react-redux": {
"version": "6.0.1",
"resolved": "https://registry.npmjs.org/react-redux/-/react-redux-6.0.1.tgz",
@@ -14735,6 +14789,152 @@
"resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-1.9.1.tgz",
"integrity": "sha512-0Vb/54WJ6k5v8sSWN09S0ora+Hnr+cX40r9F170nT+mSkaxltoE/7R3OrIdBSUv1OoiobH1QoWQbCnAO+e8J1A=="
},
+ "tc-core-library-js": {
+ "version": "github:appirio-tech/tc-core-library-js#d16413db30b1eed21c0cf426e185bedb2329ddab",
+ "from": "github:appirio-tech/tc-core-library-js#v2.6",
+ "requires": {
+ "auth0-js": "^9.4.2",
+ "axios": "^0.12.0",
+ "bunyan": "^1.8.12",
+ "jsonwebtoken": "^8.3.0",
+ "jwks-rsa": "^1.3.0",
+ "le_node": "^1.3.1",
+ "lodash": "^4.17.10",
+ "millisecond": "^0.1.2",
+ "request": "^2.88.0"
+ },
+ "dependencies": {
+ "auth0-js": {
+ "version": "9.13.4",
+ "resolved": "https://registry.npmjs.org/auth0-js/-/auth0-js-9.13.4.tgz",
+ "integrity": "sha512-G7wXTtEUe8OG5UMdcFPoS47odorEZ3WerNyWLLhoGlLqYcPgv0t+B0ECHv/rVLULbpctbSBrRFFYa43/bJV4+Q==",
+ "requires": {
+ "base64-js": "^1.3.0",
+ "idtoken-verifier": "^2.0.3",
+ "js-cookie": "^2.2.0",
+ "qs": "^6.7.0",
+ "superagent": "^3.8.3",
+ "url-join": "^4.0.1",
+ "winchan": "^0.2.2"
+ }
+ },
+ "winchan": {
+ "version": "0.2.2",
+ "resolved": "https://registry.npmjs.org/winchan/-/winchan-0.2.2.tgz",
+ "integrity": "sha512-pvN+IFAbRP74n/6mc6phNyCH8oVkzXsto4KCHPJ2AScniAnA1AmeLI03I2BzjePpaClGSI4GUMowzsD3qz5PRQ=="
+ }
+ }
+ },
+ "topcoder-react-lib": {
+ "version": "0.17.0",
+ "resolved": "https://registry.npmjs.org/topcoder-react-lib/-/topcoder-react-lib-0.17.0.tgz",
+ "integrity": "sha512-XxLAMdEHPCmKqIIKTPKajbKzkz0lWW+tQJ6leG33d0xF5Quo1eiefd8SpQ+pBbQ8yEJ8aA2z2SQuZVruJzKDzQ==",
+ "requires": {
+ "auth0-js": "^6.8.4",
+ "config": "^3.2.0",
+ "isomorphic-fetch": "^2.2.1",
+ "le_node": "^1.7.0",
+ "lodash": "^4.17.10",
+ "moment": "^2.22.2",
+ "moment-duration-format": "^2.2.2",
+ "moment-timezone": "^0.5.21",
+ "qs": "^6.5.2",
+ "react": "^16.4.1",
+ "react-dom": "^16.4.1",
+ "react-ga": "^2.7.0",
+ "react-redux": "^6.0.1",
+ "redux": "^3.7.2",
+ "redux-actions": "^2.4.0",
+ "tc-accounts": "git+https://github.com/appirio-tech/accounts-app.git#9d0daa189dbf5127ad6ca470ed1683eeb2495ac7",
+ "tc-core-library-js": "github:appirio-tech/tc-core-library-js#d16413db30b1eed21c0cf426e185bedb2329ddab",
+ "to-capital-case": "^1.0.0",
+ "topcoder-react-utils": "0.7.5"
+ },
+ "dependencies": {
+ "json5": {
+ "version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/json5/-/json5-1.0.1.tgz",
+ "integrity": "sha512-aKS4WQjPenRxiQsC93MNfjx+nbF4PAdYzmd/1JIj8HYzqfbu86beTuNgXDzPknWk0n0uARlyewZo4s++ES36Ow==",
+ "requires": {
+ "minimist": "^1.2.0"
+ }
+ },
+ "redux": {
+ "version": "3.7.2",
+ "resolved": "https://registry.npmjs.org/redux/-/redux-3.7.2.tgz",
+ "integrity": "sha512-pNqnf9q1hI5HHZRBkj3bAngGZW/JMCmexDlOxw4XagXY2o1327nHH54LoTjiPJ0gizoqPDRqWyX/00g0hD6w+A==",
+ "requires": {
+ "lodash": "^4.2.1",
+ "lodash-es": "^4.2.1",
+ "loose-envify": "^1.1.0",
+ "symbol-observable": "^1.0.3"
+ }
+ },
+ "topcoder-react-utils": {
+ "version": "0.7.5",
+ "resolved": "https://registry.npmjs.org/topcoder-react-utils/-/topcoder-react-utils-0.7.5.tgz",
+ "integrity": "sha512-/jolO/UUCC/FL/MniBMFi9d7Wc1KbzwvgT5STGs4T+7u7R26bQugGPpGVISEPuglsmW0Xybh6iRi+pT/muOkbg==",
+ "requires": {
+ "babel-runtime": "^6.26.0",
+ "body-parser": "^1.18.3",
+ "command-line-args": "^5.0.2",
+ "command-line-usage": "^5.0.5",
+ "compression": "^1.7.2",
+ "config": "^1.30.0",
+ "cookie-parser": "^1.4.3",
+ "express": "^4.16.3",
+ "helmet": "^3.12.1",
+ "lodash": "^4.17.10",
+ "moment": "^2.22.2",
+ "morgan": "^1.9.0",
+ "node-forge": "^0.7.5",
+ "prop-types": "^15.6.2",
+ "raf": "^3.4.0",
+ "react": "^16.4.1",
+ "react-css-super-themr": "^2.2.0",
+ "react-dom": "^16.4.1",
+ "react-helmet": "^5.2.0",
+ "react-redux": "^5.0.7",
+ "react-router-dom": "^4.3.1",
+ "redux": "^3.7.2",
+ "redux-actions": "^2.4.0",
+ "redux-devtools": "^3.4.1",
+ "redux-devtools-dock-monitor": "^1.1.3",
+ "redux-devtools-log-monitor": "^1.4.0",
+ "redux-promise": "^0.6.0",
+ "request-ip": "^2.0.2",
+ "serialize-javascript": "^1.5.0",
+ "serve-favicon": "^2.5.0",
+ "shortid": "^2.2.8",
+ "url-parse": "^1.4.1"
+ },
+ "dependencies": {
+ "config": {
+ "version": "1.31.0",
+ "resolved": "https://registry.npmjs.org/config/-/config-1.31.0.tgz",
+ "integrity": "sha512-Ep/l9Rd1J9IPueztJfpbOqVzuKHQh4ZODMNt9xqTYdBBNRXbV4oTu34kCkkfdRVcDq0ohtpaeXGgb+c0LQxFRA==",
+ "requires": {
+ "json5": "^1.0.1"
+ }
+ },
+ "react-redux": {
+ "version": "5.1.2",
+ "resolved": "https://registry.npmjs.org/react-redux/-/react-redux-5.1.2.tgz",
+ "integrity": "sha512-Ns1G0XXc8hDyH/OcBHOxNgQx9ayH3SPxBnFCOidGKSle8pKihysQw2rG/PmciUQRoclhVBO8HMhiRmGXnDja9Q==",
+ "requires": {
+ "@babel/runtime": "^7.1.2",
+ "hoist-non-react-statics": "^3.3.0",
+ "invariant": "^2.2.4",
+ "loose-envify": "^1.1.0",
+ "prop-types": "^15.6.1",
+ "react-is": "^16.6.0",
+ "react-lifecycles-compat": "^3.0.0"
+ }
+ }
+ }
+ }
+ }
+ },
"topcoder-react-utils": {
"version": "0.7.9",
"resolved": "https://registry.npmjs.org/topcoder-react-utils/-/topcoder-react-utils-0.7.9.tgz",
@@ -14775,6 +14975,19 @@
"shortid": "^2.2.14",
"url-parse": "^1.4.4"
}
+ },
+ "winchan": {
+ "version": "0.1.4",
+ "resolved": "https://registry.npmjs.org/winchan/-/winchan-0.1.4.tgz",
+ "integrity": "sha1-iPoSQRzVQutiYBjDihlry7F5k7s="
+ },
+ "xtend": {
+ "version": "2.1.2",
+ "resolved": "https://registry.npmjs.org/xtend/-/xtend-2.1.2.tgz",
+ "integrity": "sha1-bv7MKk2tjmlixJAbM3znuoe10os=",
+ "requires": {
+ "object-keys": "~0.4.0"
+ }
}
}
},
@@ -14826,6 +15039,14 @@
"semver": "^5.4.1"
}
},
+ "node-bourbon": {
+ "version": "4.2.8",
+ "resolved": "https://registry.npmjs.org/node-bourbon/-/node-bourbon-4.2.8.tgz",
+ "integrity": "sha1-5ETx8JQ0q3ZQ6jGMKOLhA9P5Qs0=",
+ "requires": {
+ "bourbon": "^4.2.6"
+ }
+ },
"node-dir": {
"version": "0.1.17",
"resolved": "https://registry.npmjs.org/node-dir/-/node-dir-0.1.17.tgz",
@@ -14964,6 +15185,15 @@
"resolved": "https://registry.npmjs.org/node-modules-regexp/-/node-modules-regexp-1.0.0.tgz",
"integrity": "sha1-jZ2+KJZKSsVxLpExZCEHxx6Q7EA="
},
+ "node-neat": {
+ "version": "1.7.2",
+ "resolved": "https://registry.npmjs.org/node-neat/-/node-neat-1.7.2.tgz",
+ "integrity": "sha1-OEcpELgV4mG4sbmbpRmZRGWhXCE=",
+ "requires": {
+ "bourbon-neat": "1.7.2",
+ "node-bourbon": "^4.2.3"
+ }
+ },
"node-notifier": {
"version": "5.4.3",
"resolved": "https://registry.npmjs.org/node-notifier/-/node-notifier-5.4.3.tgz",
@@ -15850,8 +16080,7 @@
"version": "2.2.2",
"resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.2.2.tgz",
"integrity": "sha512-q0M/9eZHzmr0AulXyPwNfZjtwZ/RBZlbN3K3CErVrk50T2ASYI7Bye0EvekFY3IP1Nt2DHu0re+V2ZHIpMkuWg==",
- "dev": true,
- "optional": true
+ "dev": true
},
"pify": {
"version": "3.0.0",
@@ -18828,8 +19057,7 @@
"version": "0.3.2",
"resolved": "https://registry.npmjs.org/array-unique/-/array-unique-0.3.2.tgz",
"integrity": "sha1-qJS3XUvE9s1nnvMkSp/Y9Gri1Cg=",
- "dev": true,
- "optional": true
+ "dev": true
},
"braces": {
"version": "2.3.2",
@@ -22500,15 +22728,12 @@
"@uirouter/angularjs": "^1.0.0",
"angucomplete-alt": "^2.1.0",
"angular": "^1.4.8",
- "angular-animate": "^1.7.9",
- "angular-aria": "^1.7.9",
"angular-auth0": "^3.0.0",
"angular-cookies": "^1.5.1",
- "angular-material": "^1.1.21",
"angular-messages": "^1.5.2",
- "appirio-tech-ng-iso-constants": "github:appirio-tech/ng-iso-constants#v1.0.7",
+ "appirio-tech-ng-iso-constants": "github:appirio-tech/ng-iso-constants#d8466ab76828208ccdaaeb10816a3f35cd59c39b",
"appirio-tech-ng-ui-components": "^2.2.4",
- "appirio-tech-react-components": "github:appirio-tech/react-components#feature/connectv2",
+ "appirio-tech-react-components": "github:appirio-tech/react-components#a471d4f9d1a4cd5a1a2f53aea3d1cc5dd6d78aea",
"auth0-js": "^9.6.1",
"babel-polyfill": "^6.7.4",
"filestack-js": "^1.13.2",
@@ -22686,16 +22911,6 @@
"resolved": "https://registry.npmjs.org/angular/-/angular-1.7.2.tgz",
"integrity": "sha512-JcKKJbBdybUsmQ6x1M3xWyTYQ/ioVKJhSByEAjqrhmlOfvMFdhfMqAx5KIo8rLGk4DFolYPcCSgssjgTVjCtRQ=="
},
- "angular-animate": {
- "version": "1.7.9",
- "resolved": "https://registry.npmjs.org/angular-animate/-/angular-animate-1.7.9.tgz",
- "integrity": "sha512-fV+AISy/HTzurQH2ngsJg+lLIvfu0ahc1h4AYKauaXVw97rZc2k4iUA1bMstiEyClsdayQX568kjQc1NK+oYhw=="
- },
- "angular-aria": {
- "version": "1.7.9",
- "resolved": "https://registry.npmjs.org/angular-aria/-/angular-aria-1.7.9.tgz",
- "integrity": "sha512-luI3Jemd1AbOQW0krdzfEG3fM0IFtLY0bSSqIDEx3POE0XjKIC1MkrO8Csyq9PPgueLphyAPofzUwZ8YeZ88SA=="
- },
"angular-auth0": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/angular-auth0/-/angular-auth0-3.0.0.tgz",
@@ -22710,11 +22925,6 @@
"resolved": "https://registry.npmjs.org/angular-cookies/-/angular-cookies-1.7.2.tgz",
"integrity": "sha512-5+B6ypV51aRPbQaqC2R5pr96q946C662dQC8QC1UL+cAlLkgkKZXXXzFRhiaEnhntkSnURWVCPasLVHQdZ3YgA=="
},
- "angular-material": {
- "version": "1.1.21",
- "resolved": "https://registry.npmjs.org/angular-material/-/angular-material-1.1.21.tgz",
- "integrity": "sha512-BiqvEu82dqQ4Sb4OjJHdVp/YJvFEMrtr7K2eS+6qlWPWUiF9K2K6IkX2H3p0wD7QlscjTz8n9W8uKL46PQjlCQ=="
- },
"angular-messages": {
"version": "1.7.2",
"resolved": "https://registry.npmjs.org/angular-messages/-/angular-messages-1.7.2.tgz",
@@ -23033,6 +23243,7 @@
"react-textarea-autosize": "^5.2.1",
"react-transition-group": "^2.2.1",
"redux-thunk": "^2.1.0",
+ "tc-ui": "git+https://github.com/appirio-tech/tc-ui.git#e577a0e704136f1e9ecce92ce4c0626aab932691",
"uncontrollable": "^4.0.1"
},
"dependencies": {
@@ -23041,44 +23252,16 @@
"resolved": "https://registry.npmjs.org/coffeescript/-/coffeescript-1.12.7.tgz",
"integrity": "sha512-pLXHFxQMPklVoEekowk8b3erNynC+DVJzChxS/LCBBgR6/8AJkHivkm//zbowcfc7BTCAjryuhx6gPqPRfsFoA=="
},
- "fbjs": {
- "version": "0.6.1",
- "resolved": "https://registry.npmjs.org/fbjs/-/fbjs-0.6.1.tgz",
- "integrity": "sha1-lja3cF9bqWhNRLcveDISVK/IYPc=",
+ "libphonenumber-js": {
+ "version": "1.4.6",
+ "resolved": "https://registry.npmjs.org/libphonenumber-js/-/libphonenumber-js-1.4.6.tgz",
+ "integrity": "sha512-TD1DyhPjVfNNiIxhwsooCO5j9L6JB60Qd+rlIEItgw8RKEqezu8Tva3V/4wrBiYMnBOHkp3uyzAe/PT9omyUdw==",
"requires": {
- "core-js": "^1.0.0",
- "loose-envify": "^1.0.0",
- "promise": "^7.0.3",
- "ua-parser-js": "^0.7.9",
- "whatwg-fetch": "^0.9.0"
- }
- },
- "history": {
- "version": "2.1.2",
- "resolved": "https://registry.npmjs.org/history/-/history-2.1.2.tgz",
- "integrity": "sha1-SqLeiXoOSGfkU5hDvm7Nsphr/ew=",
- "requires": {
- "deep-equal": "^1.0.0",
- "invariant": "^2.0.0",
- "query-string": "^3.0.0",
- "warning": "^2.0.0"
- },
- "dependencies": {
- "warning": {
- "version": "2.1.0",
- "resolved": "https://registry.npmjs.org/warning/-/warning-2.1.0.tgz",
- "integrity": "sha1-ISINnGOvx3qMkhEeARr3Bc4MaQE=",
- "requires": {
- "loose-envify": "^1.0.0"
- }
- }
+ "minimist": "^1.2.0",
+ "semver-compare": "^1.0.0",
+ "xml2js": "^0.4.17"
}
},
- "hoist-non-react-statics": {
- "version": "1.2.0",
- "resolved": "https://registry.npmjs.org/hoist-non-react-statics/-/hoist-non-react-statics-1.2.0.tgz",
- "integrity": "sha1-qkSM8JhtVcxAdzsXF0t90GbLfPs="
- },
"loose-envify": {
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz",
@@ -23107,60 +23290,20 @@
"react-is": "^16.8.1"
}
},
- "query-string": {
- "version": "3.0.3",
- "resolved": "https://registry.npmjs.org/query-string/-/query-string-3.0.3.tgz",
- "integrity": "sha1-ri4UtNBQcdTpuetIc8NbDc1C5jg=",
- "requires": {
- "strict-uri-encode": "^1.0.0"
- }
- },
- "react-router": {
- "version": "2.8.1",
- "resolved": "https://registry.npmjs.org/react-router/-/react-router-2.8.1.tgz",
- "integrity": "sha1-c+lJH2zrMW0Pd5gpCBhj43juTtc=",
+ "rc-slider": {
+ "version": "8.6.4",
+ "resolved": "https://registry.npmjs.org/rc-slider/-/rc-slider-8.6.4.tgz",
+ "integrity": "sha512-CV2i2Ww6ib0EjFuBKvgjw3PgT6QwvWKC93iEpqPtrztZrx5wO9Iw//AUri4KHRqptW13AuBvFdEHovqLi6XFTw==",
"requires": {
- "history": "^2.1.2",
- "hoist-non-react-statics": "^1.2.0",
- "invariant": "^2.2.1",
- "loose-envify": "^1.2.0",
+ "babel-runtime": "6.x",
+ "classnames": "^2.2.5",
+ "prop-types": "^15.5.4",
+ "rc-tooltip": "^3.7.0",
+ "rc-util": "^4.0.4",
+ "shallowequal": "^1.0.1",
"warning": "^3.0.0"
}
},
- "tc-ui": {
- "version": "git+https://github.com/appirio-tech/tc-ui.git#e577a0e704136f1e9ecce92ce4c0626aab932691",
- "from": "git+https://github.com/appirio-tech/tc-ui.git#e577a0e704136f1e9ecce92ce4c0626aab932691",
- "requires": {
- "classnames": "^2.2.3",
- "lodash": "^4.0.0",
- "moment": "^2.11.2",
- "node-neat": "~1.7.1-beta1",
- "react": "^0.14.7",
- "react-datetime": "^2.0.2",
- "react-dom": "^0.14.7",
- "react-dropzone": "^3.3.2",
- "react-redux": "^4.2.1",
- "react-router": "^2.0.0-rc6",
- "react-select": "^0.9.1",
- "redux": "^3.3.1"
- },
- "dependencies": {
- "react": {
- "version": "0.14.9",
- "resolved": "https://registry.npmjs.org/react/-/react-0.14.9.tgz",
- "integrity": "sha1-kRCmSXxJ1EuhwO3TF67CnC4NkdE=",
- "requires": {
- "envify": "^3.0.0",
- "fbjs": "^0.6.1"
- }
- },
- "react-dom": {
- "version": "0.14.9",
- "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-0.14.9.tgz",
- "integrity": "sha1-BQZKPc8PsYgKOyv8nVjFXY2fYpM="
- }
- }
- },
"warning": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/warning/-/warning-3.0.0.tgz",
@@ -24387,16 +24530,6 @@
"hoek": "2.x.x"
}
},
- "bourbon": {
- "version": "4.3.4",
- "resolved": "https://registry.npmjs.org/bourbon/-/bourbon-4.3.4.tgz",
- "integrity": "sha1-TaOAAp6SwMj5dkx3lFGhNLEefMM="
- },
- "bourbon-neat": {
- "version": "1.7.2",
- "resolved": "https://registry.npmjs.org/bourbon-neat/-/bourbon-neat-1.7.2.tgz",
- "integrity": "sha1-oiixJ0R53iR20yszFTEHylBTzz0="
- },
"bowser": {
"version": "1.9.4",
"resolved": "https://registry.npmjs.org/bowser/-/bowser-1.9.4.tgz",
@@ -26415,8 +26548,7 @@
"ansi-regex": {
"version": "2.1.1",
"resolved": false,
- "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=",
- "optional": true
+ "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8="
},
"aproba": {
"version": "1.2.0",
@@ -26437,14 +26569,12 @@
"balanced-match": {
"version": "1.0.0",
"resolved": false,
- "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=",
- "optional": true
+ "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c="
},
"brace-expansion": {
"version": "1.1.11",
"resolved": false,
"integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==",
- "optional": true,
"requires": {
"balanced-match": "^1.0.0",
"concat-map": "0.0.1"
@@ -26459,20 +26589,17 @@
"code-point-at": {
"version": "1.1.0",
"resolved": false,
- "integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=",
- "optional": true
+ "integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c="
},
"concat-map": {
"version": "0.0.1",
"resolved": false,
- "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=",
- "optional": true
+ "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s="
},
"console-control-strings": {
"version": "1.1.0",
"resolved": false,
- "integrity": "sha1-PXz0Rk22RG6mRL9LOVB/mFEAjo4=",
- "optional": true
+ "integrity": "sha1-PXz0Rk22RG6mRL9LOVB/mFEAjo4="
},
"core-util-is": {
"version": "1.0.2",
@@ -26589,8 +26716,7 @@
"inherits": {
"version": "2.0.3",
"resolved": false,
- "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=",
- "optional": true
+ "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4="
},
"ini": {
"version": "1.3.5",
@@ -26602,7 +26728,6 @@
"version": "1.0.0",
"resolved": false,
"integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=",
- "optional": true,
"requires": {
"number-is-nan": "^1.0.0"
}
@@ -26617,7 +26742,6 @@
"version": "3.0.4",
"resolved": false,
"integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==",
- "optional": true,
"requires": {
"brace-expansion": "^1.1.7"
}
@@ -26625,14 +26749,12 @@
"minimist": {
"version": "0.0.8",
"resolved": false,
- "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=",
- "optional": true
+ "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0="
},
"minipass": {
"version": "2.3.5",
"resolved": false,
"integrity": "sha512-Gi1W4k059gyRbyVUZQ4mEqLm0YIUiGYfvxhF6SIlk3ui1WVxMTGfGdQ2SInh3PDrRTVvPKgULkpJtT4RH10+VA==",
- "optional": true,
"requires": {
"safe-buffer": "^5.1.2",
"yallist": "^3.0.0"
@@ -26651,7 +26773,6 @@
"version": "0.5.1",
"resolved": false,
"integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=",
- "optional": true,
"requires": {
"minimist": "0.0.8"
}
@@ -26738,8 +26859,7 @@
"number-is-nan": {
"version": "1.0.1",
"resolved": false,
- "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=",
- "optional": true
+ "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0="
},
"object-assign": {
"version": "4.1.1",
@@ -26751,7 +26871,6 @@
"version": "1.4.0",
"resolved": false,
"integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=",
- "optional": true,
"requires": {
"wrappy": "1"
}
@@ -26837,8 +26956,7 @@
"safe-buffer": {
"version": "5.1.2",
"resolved": false,
- "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==",
- "optional": true
+ "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g=="
},
"safer-buffer": {
"version": "2.1.2",
@@ -26874,7 +26992,6 @@
"version": "1.0.2",
"resolved": false,
"integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=",
- "optional": true,
"requires": {
"code-point-at": "^1.0.0",
"is-fullwidth-code-point": "^1.0.0",
@@ -26894,7 +27011,6 @@
"version": "3.0.1",
"resolved": false,
"integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=",
- "optional": true,
"requires": {
"ansi-regex": "^2.0.0"
}
@@ -26938,14 +27054,12 @@
"wrappy": {
"version": "1.0.2",
"resolved": false,
- "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=",
- "optional": true
+ "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8="
},
"yallist": {
"version": "3.0.3",
"resolved": false,
- "integrity": "sha512-S+Zk8DEWE6oKpV+vI3qWkaK+jSbIK86pCwe2IF/xwIpQ8jEuxpw9NyaGjmp9+BoJv5FV2piqCDcoCtStppiq2A==",
- "optional": true
+ "integrity": "sha512-S+Zk8DEWE6oKpV+vI3qWkaK+jSbIK86pCwe2IF/xwIpQ8jEuxpw9NyaGjmp9+BoJv5FV2piqCDcoCtStppiq2A=="
}
}
},
@@ -28581,14 +28695,6 @@
"lower-case": "^1.1.1"
}
},
- "node-bourbon": {
- "version": "4.2.8",
- "resolved": "https://registry.npmjs.org/node-bourbon/-/node-bourbon-4.2.8.tgz",
- "integrity": "sha1-5ETx8JQ0q3ZQ6jGMKOLhA9P5Qs0=",
- "requires": {
- "bourbon": "^4.2.6"
- }
- },
"node-fetch": {
"version": "1.7.3",
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-1.7.3.tgz",
@@ -28726,15 +28832,6 @@
}
}
},
- "node-neat": {
- "version": "1.7.2",
- "resolved": "https://registry.npmjs.org/node-neat/-/node-neat-1.7.2.tgz",
- "integrity": "sha1-OEcpELgV4mG4sbmbpRmZRGWhXCE=",
- "requires": {
- "bourbon-neat": "1.7.2",
- "node-bourbon": "^4.2.3"
- }
- },
"node-sass": {
"version": "3.13.1",
"resolved": "https://registry.npmjs.org/node-sass/-/node-sass-3.13.1.tgz",
@@ -31708,6 +31805,111 @@
"inherits": "2"
}
},
+ "tc-ui": {
+ "version": "git+https://github.com/appirio-tech/tc-ui.git#e577a0e704136f1e9ecce92ce4c0626aab932691",
+ "from": "git+https://github.com/appirio-tech/tc-ui.git#feature/connectv2",
+ "requires": {
+ "classnames": "^2.2.3",
+ "lodash": "^4.0.0",
+ "moment": "^2.11.2",
+ "node-neat": "~1.7.1-beta1",
+ "react": "^0.14.7",
+ "react-datetime": "^2.0.2",
+ "react-dom": "^0.14.7",
+ "react-dropzone": "^3.3.2",
+ "react-redux": "^4.2.1",
+ "react-router": "^2.0.0-rc6",
+ "react-select": "^0.9.1",
+ "redux": "^3.3.1"
+ },
+ "dependencies": {
+ "fbjs": {
+ "version": "0.6.1",
+ "resolved": "https://registry.npmjs.org/fbjs/-/fbjs-0.6.1.tgz",
+ "integrity": "sha1-lja3cF9bqWhNRLcveDISVK/IYPc=",
+ "requires": {
+ "core-js": "^1.0.0",
+ "loose-envify": "^1.0.0",
+ "promise": "^7.0.3",
+ "ua-parser-js": "^0.7.9",
+ "whatwg-fetch": "^0.9.0"
+ }
+ },
+ "history": {
+ "version": "2.1.2",
+ "resolved": "https://registry.npmjs.org/history/-/history-2.1.2.tgz",
+ "integrity": "sha1-SqLeiXoOSGfkU5hDvm7Nsphr/ew=",
+ "requires": {
+ "deep-equal": "^1.0.0",
+ "invariant": "^2.0.0",
+ "query-string": "^3.0.0",
+ "warning": "^2.0.0"
+ },
+ "dependencies": {
+ "warning": {
+ "version": "2.1.0",
+ "resolved": "https://registry.npmjs.org/warning/-/warning-2.1.0.tgz",
+ "integrity": "sha1-ISINnGOvx3qMkhEeARr3Bc4MaQE=",
+ "requires": {
+ "loose-envify": "^1.0.0"
+ }
+ }
+ }
+ },
+ "hoist-non-react-statics": {
+ "version": "1.2.0",
+ "resolved": "https://registry.npmjs.org/hoist-non-react-statics/-/hoist-non-react-statics-1.2.0.tgz",
+ "integrity": "sha1-qkSM8JhtVcxAdzsXF0t90GbLfPs="
+ },
+ "moment": {
+ "version": "2.26.0",
+ "resolved": "https://registry.npmjs.org/moment/-/moment-2.26.0.tgz",
+ "integrity": "sha512-oIixUO+OamkUkwjhAVE18rAMfRJNsNe/Stid/gwHSOfHrOtw9EhAY2AHvdKZ/k/MggcYELFCJz/Sn2pL8b8JMw=="
+ },
+ "query-string": {
+ "version": "3.0.3",
+ "resolved": "https://registry.npmjs.org/query-string/-/query-string-3.0.3.tgz",
+ "integrity": "sha1-ri4UtNBQcdTpuetIc8NbDc1C5jg=",
+ "requires": {
+ "strict-uri-encode": "^1.0.0"
+ }
+ },
+ "react": {
+ "version": "0.14.9",
+ "resolved": "https://registry.npmjs.org/react/-/react-0.14.9.tgz",
+ "integrity": "sha1-kRCmSXxJ1EuhwO3TF67CnC4NkdE=",
+ "requires": {
+ "envify": "^3.0.0",
+ "fbjs": "^0.6.1"
+ }
+ },
+ "react-dom": {
+ "version": "0.14.9",
+ "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-0.14.9.tgz",
+ "integrity": "sha1-BQZKPc8PsYgKOyv8nVjFXY2fYpM="
+ },
+ "react-router": {
+ "version": "2.8.1",
+ "resolved": "https://registry.npmjs.org/react-router/-/react-router-2.8.1.tgz",
+ "integrity": "sha1-c+lJH2zrMW0Pd5gpCBhj43juTtc=",
+ "requires": {
+ "history": "^2.1.2",
+ "hoist-non-react-statics": "^1.2.0",
+ "invariant": "^2.2.1",
+ "loose-envify": "^1.2.0",
+ "warning": "^3.0.0"
+ }
+ },
+ "warning": {
+ "version": "3.0.0",
+ "resolved": "https://registry.npmjs.org/warning/-/warning-3.0.0.tgz",
+ "integrity": "sha1-MuU3fLVy3kqwR1O9+IIcAe1gW3w=",
+ "requires": {
+ "loose-envify": "^1.0.0"
+ }
+ }
+ }
+ },
"tcomb": {
"version": "3.2.29",
"resolved": "https://registry.npmjs.org/tcomb/-/tcomb-3.2.29.tgz",
@@ -33246,8 +33448,8 @@
"react-redux": "^6.0.1",
"redux": "^3.7.2",
"redux-actions": "^2.4.0",
- "tc-accounts": "git+https://github.com/appirio-tech/accounts-app.git#dev",
- "tc-core-library-js": "github:appirio-tech/tc-core-library-js#v2.6",
+ "tc-accounts": "git+https://github.com/appirio-tech/accounts-app.git#9d0daa189dbf5127ad6ca470ed1683eeb2495ac7",
+ "tc-core-library-js": "github:appirio-tech/tc-core-library-js#d16413db30b1eed21c0cf426e185bedb2329ddab",
"to-capital-case": "^1.0.0",
"topcoder-react-utils": "0.7.5"
},
@@ -33260,7 +33462,7 @@
"Base64": "~0.1.3",
"json-fallback": "0.0.1",
"jsonp": "~0.0.4",
- "qs": "git+https://github.com/jfromaniello/node-querystring.git#fix_ie7_bug_with_arrays",
+ "qs": "git+https://github.com/jfromaniello/node-querystring.git#5d96513991635e3e22d7aa54a8584d6ce97cace8",
"reqwest": "^1.1.4",
"trim": "~0.0.1",
"winchan": "^0.1.1",
@@ -34336,15 +34538,13 @@
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz",
"integrity": "sha1-qIwCU1eR8C7TfHahueqXc8gz+MI=",
- "dev": true,
- "optional": true
+ "dev": true
},
"is-glob": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.1.tgz",
"integrity": "sha512-5G0tKtBTFImOqDnLB2hG6Bp2qcKEFduo4tZu9MT/H6NQv/ghhy30o55ufafxJ/LdH79LLs2Kfrn85TLKyA7BUg==",
"dev": true,
- "optional": true,
"requires": {
"is-extglob": "^2.1.1"
}
@@ -34360,8 +34560,7 @@
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz",
"integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==",
- "dev": true,
- "optional": true
+ "dev": true
},
"readdirp": {
"version": "3.4.0",
@@ -34429,15 +34628,13 @@
"version": "0.3.2",
"resolved": "https://registry.npmjs.org/array-unique/-/array-unique-0.3.2.tgz",
"integrity": "sha1-qJS3XUvE9s1nnvMkSp/Y9Gri1Cg=",
- "dev": true,
- "optional": true
+ "dev": true
},
"braces": {
"version": "2.3.2",
"resolved": "https://registry.npmjs.org/braces/-/braces-2.3.2.tgz",
"integrity": "sha512-aNdbnj9P8PjdXU4ybaWLK2IF3jc/EoDYbC7AazW6to3TRsfXxscC9UXOB5iDiEQrkyIbWp2SLQda4+QAa7nc3w==",
"dev": true,
- "optional": true,
"requires": {
"arr-flatten": "^1.1.0",
"array-unique": "^0.3.2",
@@ -34456,7 +34653,6 @@
"resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz",
"integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=",
"dev": true,
- "optional": true,
"requires": {
"is-extendable": "^0.1.0"
}
@@ -34629,7 +34825,6 @@
"resolved": "https://registry.npmjs.org/fill-range/-/fill-range-4.0.0.tgz",
"integrity": "sha1-1USBHUKPmOsGpj3EAtJAPDKMOPc=",
"dev": true,
- "optional": true,
"requires": {
"extend-shallow": "^2.0.1",
"is-number": "^3.0.0",
@@ -34642,7 +34837,6 @@
"resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz",
"integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=",
"dev": true,
- "optional": true,
"requires": {
"is-extendable": "^0.1.0"
}
@@ -34708,8 +34902,7 @@
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz",
"integrity": "sha1-qIwCU1eR8C7TfHahueqXc8gz+MI=",
- "dev": true,
- "optional": true
+ "dev": true
},
"is-glob": {
"version": "4.0.1",
@@ -34726,7 +34919,6 @@
"resolved": "https://registry.npmjs.org/is-number/-/is-number-3.0.0.tgz",
"integrity": "sha1-JP1iAaR4LPUFYcgQJ2r8fRLXEZU=",
"dev": true,
- "optional": true,
"requires": {
"kind-of": "^3.0.2"
},
@@ -34736,7 +34928,6 @@
"resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz",
"integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=",
"dev": true,
- "optional": true,
"requires": {
"is-buffer": "^1.1.5"
}
diff --git a/package.json b/package.json
index adf6e8f71c..65bdc760c4 100644
--- a/package.json
+++ b/package.json
@@ -140,7 +140,7 @@
"tc-accounts": "git+https://github.com/appirio-tech/accounts-app.git#dev",
"tc-core-library-js": "github:appirio-tech/tc-core-library-js#v2.6.3",
"tc-ui": "^1.0.12",
- "topcoder-react-lib": "1.0.7",
+ "topcoder-react-lib": "1000.24.5",
"topcoder-react-ui-kit": "2.0.1",
"topcoder-react-utils": "0.7.8",
"turndown": "^4.0.2",
diff --git a/src/server/services/communities.js b/src/server/services/communities.js
index a889a7625b..54c797eee3 100644
--- a/src/server/services/communities.js
+++ b/src/server/services/communities.js
@@ -142,6 +142,7 @@ export function getList(userGroupIds) {
description: data.description,
groupIds: data.groupIds,
hidden: data.hidden || false,
+ hideFilter: data.hideFilter || false,
image: data.image,
mainSubdomain: _.get(data, 'subdomains[0]', ''),
});
diff --git a/src/server/tc-communities/blockchain/metadata.json b/src/server/tc-communities/blockchain/metadata.json
index 122170f340..e7055fefb4 100644
--- a/src/server/tc-communities/blockchain/metadata.json
+++ b/src/server/tc-communities/blockchain/metadata.json
@@ -9,6 +9,7 @@
"communityName": "Blockchain Community",
"groupIds": ["20000010"],
"hideSearch": true,
+ "hideFilter": true,
"logos": [{
"img": "/community-app-assets/themes/blockchain/logo_topcoder_with_name.svg",
"url": "https://www.topcoder.com"
diff --git a/src/server/tc-communities/cognitive/metadata.json b/src/server/tc-communities/cognitive/metadata.json
index 0015366d56..8c26e43e68 100644
--- a/src/server/tc-communities/cognitive/metadata.json
+++ b/src/server/tc-communities/cognitive/metadata.json
@@ -16,6 +16,7 @@
"url": "https://www.topcoder.com"
}],
"hideSearch": true,
+ "hideFilter": true,
"menuItems": [
{
"title": "Home",
diff --git a/src/server/tc-communities/tco19/metadata.json b/src/server/tc-communities/tco19/metadata.json
index d3e84c70ea..77db47c198 100644
--- a/src/server/tc-communities/tco19/metadata.json
+++ b/src/server/tc-communities/tco19/metadata.json
@@ -2,6 +2,7 @@
"challengeFilter": {
"events": ["tco19"]
},
+ "hidden": true,
"communityId": "tco19",
"communityName": "TCO19",
"groupIds": ["20000078"],
diff --git a/src/shared/actions/challenge-listing/index.js b/src/shared/actions/challenge-listing/index.js
index a33623e9b7..62d5db8c49 100644
--- a/src/shared/actions/challenge-listing/index.js
+++ b/src/shared/actions/challenge-listing/index.js
@@ -8,6 +8,8 @@ import { decodeToken } from 'tc-accounts';
import 'isomorphic-fetch';
import { processSRM } from 'utils/tc';
import { errors, services } from 'topcoder-react-lib';
+import { BUCKETS } from 'utils/challenge-listing/buckets';
+import SORT from 'utils/challenge-listing/sort';
const { fireErrorMessage } = errors;
const { getService } = services.challenge;
@@ -16,7 +18,7 @@ const { getReviewOpportunitiesService } = services.reviewOpportunities;
/**
* The maximum number of challenges to fetch in a single API call.
*/
-const PAGE_SIZE = 99;
+const PAGE_SIZE = 10;
/**
* The maximum number of review opportunities to fetch in a single API call.
@@ -31,19 +33,19 @@ const REVIEW_OPPORTUNITY_PAGE_SIZE = 1000;
* @param {Number} page Optional. Next page of challenges to load.
* @param {Array} prev Optional. Challenges loaded so far.
*/
-function getAll(getter, page = 0, prev) {
- /* Amount of challenges to fetch in one API call. 50 is the current maximum
- * amount of challenges the backend returns, event when the larger limit is
- * explicitely required. */
-
- return getter({
- perPage: PAGE_SIZE,
- page: page + 1,
- }).then(({ challenges: chunk }) => {
- if (!chunk.length) return prev || [];
- return getAll(getter, 1 + page, prev ? prev.concat(chunk) : chunk);
- });
-}
+// function getAll(getter, page = 0, prev) {
+// /* Amount of challenges to fetch in one API call. 50 is the current maximum
+// * amount of challenges the backend returns, event when the larger limit is
+// * explicitely required. */
+
+// return getter({
+// perPage: PAGE_SIZE,
+// page: page + 1,
+// }).then(({ challenges: chunk }) => {
+// if (!chunk.length) return prev || [];
+// return getAll(getter, 1 + page, prev ? prev.concat(chunk) : chunk);
+// });
+// }
/**
* Gets possible challenge types.
@@ -77,6 +79,18 @@ function getActiveChallengesInit(uuid, page, frontFilter) {
return { uuid, page, frontFilter };
}
+function getOpenForRegistrationChallengesInit(uuid, page, frontFilter) {
+ return { uuid, page, frontFilter };
+}
+
+function getMyChallengesInit(uuid, page, frontFilter) {
+ return { uuid, page, frontFilter };
+}
+
+function getAllChallengesInit(uuid, page, frontFilter) {
+ return { uuid, page, frontFilter };
+}
+
/**
* Get all challenges and match with user challenges
* @param {String} uuid progress id
@@ -84,70 +98,70 @@ function getActiveChallengesInit(uuid, page, frontFilter) {
* @param {Object} filter filter object
* @param {number} page start page
*/
-function getAllActiveChallengesWithUsersDone(uuid, tokenV3, filter, page = 0) {
- const service = getService(tokenV3);
- const calls = [
- getAll(params => service.getChallenges(filter, params), page),
- ];
- let user;
- if (tokenV3) {
- user = decodeToken(tokenV3).userId;
-
- const newFilter = _.mapKeys(filter, (value, key) => {
- if (key === 'tag') return 'technologies';
-
- return key;
- });
-
- // Handle any errors on this endpoint so that the non-user specific challenges
- // will still be loaded.
- calls.push(getAll(params => service.getUserChallenges(user, newFilter, params)
- .catch(() => ({ challenges: [] }))), page);
- }
- return Promise.all(calls).then(([ch, uch]) => {
- /* uch array contains challenges where the user is participating in
-@@ -111,8 +124,8 @@ function getAllActiveChallengesDone(uuid, tokenV3) {
- * challenges in an efficient way. */
- if (uch) {
- const map = {};
- uch.forEach((item) => { map[item.id] = item; });
- ch.forEach((item) => {
- if (map[item.id]) {
- /* It is fine to reassing, as the array we modifying is created just
- * above within the same function. */
- /* eslint-disable no-param-reassign */
- item.users[user] = true;
- item.userDetails = map[item.id].userDetails;
- /* eslint-enable no-param-reassign */
- }
- });
- }
-
- return { uuid, challenges: ch, ...filter };
- });
-}
+// function getAllActiveChallengesWithUsersDone(uuid, tokenV3, filter, page = 0) {
+// const service = getService(tokenV3);
+// const calls = [
+// getAll(params => service.getChallenges(filter, params), page),
+// ];
+// let user;
+// if (tokenV3) {
+// user = decodeToken(tokenV3).userId;
+
+// const newFilter = _.mapKeys(filter, (value, key) => {
+// if (key === 'tag') return 'technologies';
+
+// return key;
+// });
+
+// // Handle any errors on this endpoint so that the non-user specific challenges
+// // will still be loaded.
+// calls.push(getAll(params => service.getUserChallenges(user, newFilter, params)
+// .catch(() => ({ challenges: [] }))), page);
+// }
+// return Promise.all(calls).then(([ch, uch]) => {
+// /* uch array contains challenges where the user is participating in
+// @@ -111,8 +124,8 @@ function getAllActiveChallengesDone(uuid, tokenV3) {
+// * challenges in an efficient way. */
+// if (uch) {
+// const map = {};
+// uch.forEach((item) => { map[item.id] = item; });
+// ch.forEach((item) => {
+// if (map[item.id]) {
+// /* It is fine to reassing, as the array we modifying is created just
+// * above within the same function. */
+// /* eslint-disable no-param-reassign */
+// item.users[user] = true;
+// item.userDetails = map[item.id].userDetails;
+// /* eslint-enable no-param-reassign */
+// }
+// });
+// }
+
+// return { uuid, challenges: ch, ...filter };
+// });
+// }
/** TODO: Inspect if the 2 actions bellow can be removed?
* They do duplicate what is done in `getActiveChallengesDone` but fetch all challenges
* which was refactored in listing-improve
*/
-function getAllActiveChallengesInit(uuid) {
- return uuid;
-}
-function getAllActiveChallengesDone(uuid, tokenV3) {
- const filter = { status: 'Active' };
- return getAllActiveChallengesWithUsersDone(uuid, tokenV3, filter);
-}
-
-function getAllUserChallengesInit(uuid) {
- return uuid;
-}
-
-function getAllUserChallengesDone(uuid, tokenV3) {
- const memberId = decodeToken(tokenV3).userId;
- const filter = { status: 'Active', memberId };
- return getAllActiveChallengesWithUsersDone(uuid, tokenV3, filter);
-}
+// function getAllActiveChallengesInit(uuid) {
+// return uuid;
+// }
+// function getAllActiveChallengesDone(uuid, tokenV3) {
+// const filter = { status: 'Active' };
+// return getAllActiveChallengesWithUsersDone(uuid, tokenV3, filter);
+// }
+
+// function getAllUserChallengesInit(uuid) {
+// return uuid;
+// }
+
+// function getAllUserChallengesDone(uuid, tokenV3) {
+// const memberId = decodeToken(tokenV3).userId;
+// const filter = { status: 'Active', memberId };
+// return getAllActiveChallengesWithUsersDone(uuid, tokenV3, filter);
+// }
/**
* Gets 1 page of active challenges (including marathon matches) from the backend.
@@ -165,75 +179,189 @@ function getAllUserChallengesDone(uuid, tokenV3) {
* @return {Promise}
*/
function getActiveChallengesDone(uuid, page, backendFilter, tokenV3, frontFilter = {}) {
+ const { sorts } = frontFilter;
+ const filter = {
+ backendFilter,
+ frontFilter: {
+ ...frontFilter,
+ status: 'Active',
+ currentPhaseName: 'Submission',
+ registrationEndDateEnd: new Date().toISOString(),
+ perPage: PAGE_SIZE,
+ page: page + 1,
+ sortBy: sorts[BUCKETS.ONGOING],
+ sortOrder: SORT[sorts[BUCKETS.ONGOING]].order,
+ },
+ };
+ delete filter.frontFilter.sorts;
+ const service = getService(tokenV3);
+ return service.getChallenges(filter).then(ch => ({
+ uuid,
+ challenges: ch.challenges,
+ meta: ch.meta,
+ frontFilter,
+ }));
+ // const calls = [
+ // service.getChallenges(filter, {
+ // perPage: PAGE_SIZE,
+ // page: page + 1,
+ // }),
+ // ];
+ // let user;
+ // if (tokenV3) {
+ // user = decodeToken(tokenV3).userId;
+
+ // // Handle any errors on this endpoint so that the non-user specific challenges
+ // // will still be loaded.
+ // calls.push(service.getUserChallenges(user, filter, {})
+ // .catch(() => ({ challenges: [] })));
+ // }
+ // return Promise.all(calls).then(([ch]) => ({
+ // uuid,
+ // challenges: ch.challenges,
+ // meta: ch.meta,
+ // frontFilter,
+ // }));
+}
+
+function getOpenForRegistrationChallengesDone(uuid, page, backendFilter,
+ tokenV3, frontFilter = {}) {
+ const { sorts } = frontFilter;
const filter = {
- ...backendFilter,
- status: 'Active',
+ backendFilter,
+ frontFilter: {
+ ...frontFilter,
+ status: 'Active',
+ currentPhaseName: 'Registration',
+ perPage: PAGE_SIZE,
+ page: page + 1,
+ sortBy: sorts[BUCKETS.OPEN_FOR_REGISTRATION],
+ sortOrder: SORT[sorts[BUCKETS.OPEN_FOR_REGISTRATION]].order,
+ },
};
+ delete filter.frontFilter.sorts;
const service = getService(tokenV3);
- const calls = [
- service.getChallenges(filter, {
+ return service.getChallenges(filter).then(ch => ({
+ uuid,
+ openForRegistrationChallenges: ch.challenges,
+ meta: ch.meta,
+ frontFilter,
+ }));
+}
+
+function getMyChallengesDone(uuid, page, backendFilter, tokenV3, frontFilter = {}) {
+ const userId = decodeToken(tokenV3).userId.toString();
+ const { sorts } = frontFilter;
+ const filter = {
+ backendFilter,
+ frontFilter: {
+ ...frontFilter,
+ status: 'Active',
+ memberId: userId,
perPage: PAGE_SIZE,
page: page + 1,
- }),
- ];
- let user;
- if (tokenV3) {
- user = decodeToken(tokenV3).userId;
-
- // Handle any errors on this endpoint so that the non-user specific challenges
- // will still be loaded.
- calls.push(service.getUserChallenges(user, filter, {})
- .catch(() => ({ challenges: [] })));
+ sortBy: sorts[BUCKETS.MY],
+ sortOrder: SORT[sorts[BUCKETS.MY]].order,
+ },
+ };
+ delete filter.frontFilter.sorts;
+ const service = getService(tokenV3);
+ return service.getChallenges(filter).then(ch => ({
+ uuid,
+ myChallenges: ch.challenges,
+ meta: ch.meta,
+ frontFilter,
+ }));
+}
+
+function getAllChallengesDone(uuid, page, backendFilter, tokenV3, frontFilter = {}) {
+ const { sorts, status } = frontFilter;
+ const filter = {
+ backendFilter,
+ frontFilter: {
+ ...frontFilter,
+ perPage: PAGE_SIZE,
+ page: page + 1,
+ sortBy: sorts[BUCKETS.ALL],
+ sortOrder: SORT[sorts[BUCKETS.ALL]].order,
+ },
+ };
+ delete filter.frontFilter.sorts;
+ if (status === 'All') {
+ delete filter.frontFilter.status;
}
- return Promise.all(calls).then(([ch]) => ({
+ const service = getService(tokenV3);
+ return service.getChallenges(filter).then(ch => ({
uuid,
- challenges: ch.challenges,
+ allChallenges: ch.challenges,
meta: ch.meta,
frontFilter,
}));
}
+function getTotalChallengesCountInit(uuid) {
+ return { uuid };
+}
+
+function getTotalChallengesCountDone(uuid, tokenV3, frontFilter = {}) {
+ const filter = {
+ backendFilter: {},
+ frontFilter: {
+ ...frontFilter,
+ status: 'Active',
+ isLightweight: true,
+ perPage: 1,
+ },
+ };
+ delete filter.frontFilter.sorts;
+ const service = getService(tokenV3);
+ return service.getChallenges(filter).then(ch => ({
+ uuid,
+ meta: ch.meta,
+ }));
+}
+
/**
* Init loading of all challenges
* @param {String} uuid
*/
-function getRestActiveChallengesInit(uuid) {
- return { uuid };
-}
+// function getRestActiveChallengesInit(uuid) {
+// return { uuid };
+// }
/**
* Loading all challenges
* @param {String} uuid progress id
* @param {String} tokenV3 token v3
*/
-function getRestActiveChallengesDone(uuid, tokenV3, filter) {
- const mergedFilter = {
- ...filter,
- status: 'Active',
- };
- return getAllActiveChallengesWithUsersDone(uuid, tokenV3, mergedFilter, 1);
-}
+// function getRestActiveChallengesDone(uuid, tokenV3, filter) {
+// const mergedFilter = {
+// ...filter,
+// status: 'Active',
+// };
+// return getAllActiveChallengesWithUsersDone(uuid, tokenV3, mergedFilter, 1);
+// }
/**
* Prepare for getting all recommended challenges
* @param {String} uuid progress id
*/
-function getAllRecommendedChallengesInit(uuid) {
- return uuid;
-}
+// function getAllRecommendedChallengesInit(uuid) {
+// return uuid;
+// }
/**
* Get all recommended challenges
* @param {String} uuid progress id
* @param {String} tokenV3 token v3
* @param {*} recommendedTags recommended tags
*/
-function getAllRecommendedChallengesDone(uuid, tokenV3, recommendedTags) {
- const filter = {
- status: 'Active',
- ...(!_.isEmpty(recommendedTags) && { tag: recommendedTags }),
- };
- return getAllActiveChallengesWithUsersDone(uuid, tokenV3, filter);
-}
+// function getAllRecommendedChallengesDone(uuid, tokenV3, recommendedTags) {
+// const filter = {
+// status: 'Active',
+// ...(!_.isEmpty(recommendedTags) && { tag: recommendedTags }),
+// };
+// return getAllActiveChallengesWithUsersDone(uuid, tokenV3, filter);
+// }
/**
* Notifies the state that we are about to load the specified page of past
@@ -243,9 +371,9 @@ function getAllRecommendedChallengesDone(uuid, tokenV3, recommendedTags) {
* @param {Object} frontFilter
* @return {Object}
*/
-function getPastChallengesInit(uuid, page, frontFilter) {
- return { uuid, page, frontFilter };
-}
+// function getPastChallengesInit(uuid, page, frontFilter) {
+// return { uuid, page, frontFilter };
+// }
/**
* Gets the specified page of past challenges (including MMs).
@@ -255,16 +383,27 @@ function getPastChallengesInit(uuid, page, frontFilter) {
* @param {Object} frontFilter Optional. Original frontend filter.
* @param {Object}
*/
-function getPastChallengesDone(uuid, page, filter, tokenV3, frontFilter = {}) {
- const service = getService(tokenV3);
- return service.getChallenges({
- ...filter,
- status: 'Completed',
- }, {
- perPage: PAGE_SIZE,
- page: page + 1,
- }).then(({ challenges }) => ({ uuid, challenges, frontFilter }));
-}
+// function getPastChallengesDone(uuid, page, backendFilter, tokenV3, frontFilter = {}) {
+// const { sorts } = frontFilter;
+// const filter = {
+// backendFilter,
+// frontFilter: {
+// ...frontFilter,
+// status: 'Completed',
+// perPage: PAGE_SIZE,
+// page: page + 1,
+// sortBy: sorts[BUCKETS.PAST],
+// sortOrder: SORT[sorts[BUCKETS.PAST]].order,
+// },
+// };
+// delete filter.frontFilter.sorts;
+// const service = getService(tokenV3);
+// return service.getChallenges(filter).then(({ challenges }) => ({
+// uuid,
+// pastChallenges: challenges,
+// frontFilter,
+// }));
+// }
/**
* Action to get a list of currently open Review Opportunities using V3 API
@@ -326,54 +465,71 @@ function getSrmsDone(uuid, handle, params, tokenV3) {
* Payload creator for the action that initialize user registered challenges.
* @param {String} uuid
* @return {String}
- */
-function getUserChallengesInit(uuid) {
- return { uuid };
-}
-
-/**
- * Payload creator for the action that loads user registered challenges.
- * @param {String} userId
- * @return {String}
- */
-function getUserChallengesDone(userId, tokenV3) {
- const service = getService(tokenV3);
-
- return service.getUserResources(userId, 1, 10000)
- .then(item => item)
- .catch((error) => {
- fireErrorMessage('Error Getting User Challenges', error.content || error);
- return Promise.reject(error);
- });
-}
+// */
+// function getUserChallengesInit(uuid) {
+// return { uuid };
+// }
+
+// /**
+// * Payload creator for the action that loads user registered challenges.
+// * @param {String} userId
+// * @return {String}
+// */
+// function getUserChallengesDone(userId, tokenV3) {
+// const service = getService(tokenV3);
+
+// return service.getUserResources(userId)
+// .then(item => item)
+// .catch((error) => {
+// fireErrorMessage('Error Getting User Challenges', error.content || error);
+// return Promise.reject(error);
+// });
+// }
export default createActions({
CHALLENGE_LISTING: {
DROP_CHALLENGES: _.noop,
+ DROP_ACTIVE_CHALLENGES: _.noop,
+ DROP_OPEN_FOR_REGISTRATION_CHALLENGES: _.noop,
+ DROP_MY_CHALLENGES: _.noop,
+ DROP_ALL_CHALLENGES: _.noop,
+ DROP_PAST_CHALLENGES: _.noop,
+
+ // GET_ALL_ACTIVE_CHALLENGES_INIT: getAllActiveChallengesInit,
+ // GET_ALL_ACTIVE_CHALLENGES_DONE: getAllActiveChallengesDone,
- GET_ALL_ACTIVE_CHALLENGES_INIT: getAllActiveChallengesInit,
- GET_ALL_ACTIVE_CHALLENGES_DONE: getAllActiveChallengesDone,
+ // GET_ALL_USER_CHALLENGES_INIT: getAllUserChallengesInit,
+ // GET_ALL_USER_CHALLENGES_DONE: getAllUserChallengesDone,
- GET_ALL_USER_CHALLENGES_INIT: getAllUserChallengesInit,
- GET_ALL_USER_CHALLENGES_DONE: getAllUserChallengesDone,
+ // GET_ALL_RECOMMENDED_CHALLENGES_INIT: getAllRecommendedChallengesInit,
+ // GET_ALL_RECOMMENDED_CHALLENGES_DONE: getAllRecommendedChallengesDone,
- GET_ALL_RECOMMENDED_CHALLENGES_INIT: getAllRecommendedChallengesInit,
- GET_ALL_RECOMMENDED_CHALLENGES_DONE: getAllRecommendedChallengesDone,
+ GET_ALL_CHALLENGES_INIT: getAllChallengesInit,
+ GET_ALL_CHALLENGES_DONE: getAllChallengesDone,
GET_ACTIVE_CHALLENGES_INIT: getActiveChallengesInit,
GET_ACTIVE_CHALLENGES_DONE: getActiveChallengesDone,
- GET_REST_ACTIVE_CHALLENGES_INIT: getRestActiveChallengesInit,
- GET_REST_ACTIVE_CHALLENGES_DONE: getRestActiveChallengesDone,
+ GET_OPEN_FOR_REGISTRATION_CHALLENGES_INIT: getOpenForRegistrationChallengesInit,
+ GET_OPEN_FOR_REGISTRATION_CHALLENGES_DONE: getOpenForRegistrationChallengesDone,
+
+ GET_MY_CHALLENGES_INIT: getMyChallengesInit,
+ GET_MY_CHALLENGES_DONE: getMyChallengesDone,
+
+ // GET_REST_ACTIVE_CHALLENGES_INIT: getRestActiveChallengesInit,
+ // GET_REST_ACTIVE_CHALLENGES_DONE: getRestActiveChallengesDone,
GET_CHALLENGE_TYPES_INIT: _.noop,
GET_CHALLENGE_TYPES_DONE: getChallengeTypesDone,
+ GET_TOTAL_CHALLENGES_COUNT_INIT: getTotalChallengesCountInit,
+ GET_TOTAL_CHALLENGES_COUNT_DONE: getTotalChallengesCountDone,
+
GET_CHALLENGE_TAGS_INIT: _.noop,
GET_CHALLENGE_TAGS_DONE: getChallengeTagsDone,
- GET_PAST_CHALLENGES_INIT: getPastChallengesInit,
- GET_PAST_CHALLENGES_DONE: getPastChallengesDone,
+ // GET_PAST_CHALLENGES_INIT: getPastChallengesInit,
+ // GET_PAST_CHALLENGES_DONE: getPastChallengesDone,
GET_REVIEW_OPPORTUNITIES_INIT: (uuid, page) => ({ uuid, page }),
GET_REVIEW_OPPORTUNITIES_DONE: getReviewOpportunitiesDone,
@@ -381,8 +537,8 @@ export default createActions({
GET_SRMS_INIT: getSrmsInit,
GET_SRMS_DONE: getSrmsDone,
- GET_USER_CHALLENGES_INIT: getUserChallengesInit,
- GET_USER_CHALLENGES_DONE: getUserChallengesDone,
+ // GET_USER_CHALLENGES_INIT: getUserChallengesInit,
+ // GET_USER_CHALLENGES_DONE: getUserChallengesDone,
EXPAND_TAG: id => id,
diff --git a/src/shared/actions/challenge-listing/sidebar.js b/src/shared/actions/challenge-listing/sidebar.js
index 98fb81ce5e..d126b08bc2 100644
--- a/src/shared/actions/challenge-listing/sidebar.js
+++ b/src/shared/actions/challenge-listing/sidebar.js
@@ -4,18 +4,18 @@
import _ from 'lodash';
import { createActions } from 'redux-actions';
-import { services } from 'topcoder-react-lib';
+// import { services } from 'topcoder-react-lib';
-const { getUserSettingsService } = services.userSetting;
+// const { getUserSettingsService } = services.userSetting;
/**
* Changes name of the specified filter (but does not save it to the backend).
* @param {String} index
* @param {String} name
*/
-function changeFilterName(index, name) {
- return { index, name };
-}
+// function changeFilterName(index, name) {
+// return { index, name };
+// }
/**
* Deletes saved filter.
@@ -23,10 +23,10 @@ function changeFilterName(index, name) {
* @param {Object} tokenV2
* @return {Promise}
*/
-function deleteSavedFilter(id, tokenV2) {
- return getUserSettingsService(tokenV2)
- .deleteFilter(id).then(() => id);
-}
+// function deleteSavedFilter(id, tokenV2) {
+// return getUserSettingsService(tokenV2)
+// .deleteFilter(id).then(() => id);
+// }
/**
* Handles drag move event.
@@ -44,22 +44,22 @@ function deleteSavedFilter(id, tokenV2) {
* with DOM, and, most probably, it is just easier to adopt some 3-rd party
* Drag-n-Drop library, then to find out a work-around.
*/
-function dragSavedFilterMove(dragEvent, dragState) {
- /* For a reason not clear to me, shortly after starting to drag a filter,
- * and also when the user releases the mouse button, thus ending the drag,
- * this handler gets an event with 'screenY' position equal 0. This breaks
- * the dragging handling, which works just fine otherwise. Hence, this simple
- * fix of the issue, until the real problem is figured out.
- */
- if (!dragEvent.screenY) return dragState;
-
- /* Calculation of the target position of the dragged item inside the filters
- * array. */
- const shift = (dragEvent.screenY - dragState.y) / dragEvent.target.offsetHeight;
- const index = Math.round(dragState.startIndex + shift);
- if (index === dragState.index) return dragState;
- return { ...dragState, currentIndex: index };
-}
+// function dragSavedFilterMove(dragEvent, dragState) {
+/* For a reason not clear to me, shortly after starting to drag a filter,
+ * and also when the user releases the mouse button, thus ending the drag,
+ * this handler gets an event with 'screenY' position equal 0. This breaks
+ * the dragging handling, which works just fine otherwise. Hence, this simple
+ * fix of the issue, until the real problem is figured out.
+ */
+// if (!dragEvent.screenY) return dragState;
+
+// /* Calculation of the target position of the dragged item inside the filters
+// * array. */
+// const shift = (dragEvent.screenY - dragState.y) / dragEvent.target.offsetHeight;
+// const index = Math.round(dragState.startIndex + shift);
+// if (index === dragState.index) return dragState;
+// return { ...dragState, currentIndex: index };
+// }
/**
* Initializes drag of a filter item.
@@ -67,17 +67,17 @@ function dragSavedFilterMove(dragEvent, dragState) {
* @param {Object} dragEvent
* @return {Object}
*/
-function dragSavedFilterStart(index, dragEvent) {
- return {
- currentIndex: index,
- startIndex: index,
- y: dragEvent.screenY,
- };
-}
-
-function getSavedFilters(tokenV2) {
- return getUserSettingsService(tokenV2).getFilters();
-}
+// function dragSavedFilterStart(index, dragEvent) {
+// return {
+// currentIndex: index,
+// startIndex: index,
+// y: dragEvent.screenY,
+// };
+// }
+
+// function getSavedFilters(tokenV2) {
+// return getUserSettingsService(tokenV2).getFilters();
+// }
/**
* After changing filter name with changeFilterName(..) this action can be used
@@ -85,9 +85,9 @@ function getSavedFilters(tokenV2) {
* as the last saved name is kept inside the state.
* @param {String} index
*/
-function resetFilterName(index) {
- return index;
-}
+// function resetFilterName(index) {
+// return index;
+// }
/**
* Saves filter to the backend.
@@ -96,10 +96,10 @@ function resetFilterName(index) {
* @param {String} tokenV2
* @return {Promise}
*/
-function saveFilter(name, filter, tokenV2) {
- return getUserSettingsService(tokenV2)
- .saveFilter(name, filter);
-}
+// function saveFilter(name, filter, tokenV2) {
+// return getUserSettingsService(tokenV2)
+// .saveFilter(name, filter);
+// }
/**
* Updates all saved filters (basically to update their ordering in the
@@ -107,10 +107,10 @@ function saveFilter(name, filter, tokenV2) {
* @param {Array} savedFilters
* @param {String} tokenV2
*/
-function updateAllSavedFilters(savedFilters, tokenV2) {
- const service = getUserSettingsService(tokenV2);
- savedFilters.forEach(filter => service.updateFilter(filter.id, filter.name, filter.filter));
-}
+// function updateAllSavedFilters(savedFilters, tokenV2) {
+// const service = getUserSettingsService(tokenV2);
+// savedFilters.forEach(filter => service.updateFilter(filter.id, filter.name, filter.filter));
+// }
/**
* Saves updated fitler to the backend.
@@ -118,41 +118,41 @@ function updateAllSavedFilters(savedFilters, tokenV2) {
* @param {String} tokenV2
* @return {Promise}
*/
-function updateSavedFilter(filter, tokenV2) {
- return getUserSettingsService(tokenV2)
- .updateFilter(filter.id, filter.name, filter.filter);
-}
+// function updateSavedFilter(filter, tokenV2) {
+// return getUserSettingsService(tokenV2)
+// .updateFilter(filter.id, filter.name, filter.filter);
+// }
export default createActions({
CHALLENGE_LISTING: {
SIDEBAR: {
- CHANGE_FILTER_NAME: changeFilterName,
+ // CHANGE_FILTER_NAME: changeFilterName,
- DELETE_SAVED_FILTER: deleteSavedFilter,
+ // DELETE_SAVED_FILTER: deleteSavedFilter,
- DRAG_SAVED_FILTER_MOVE: dragSavedFilterMove,
- DRAG_SAVED_FILTER_START: dragSavedFilterStart,
+ // DRAG_SAVED_FILTER_MOVE: dragSavedFilterMove,
+ // DRAG_SAVED_FILTER_START: dragSavedFilterStart,
- GET_SAVED_FILTERS: getSavedFilters,
+ // GET_SAVED_FILTERS: getSavedFilters,
- RESET_FILTER_NAME: resetFilterName,
+ // RESET_FILTER_NAME: resetFilterName,
- SAVE_FILTER_DONE: saveFilter,
+ // SAVE_FILTER_DONE: saveFilter,
- SAVE_FILTER_INIT: _.noop,
+ // SAVE_FILTER_INIT: _.noop,
/* Pass in the bucket type. */
- SELECT_BUCKET: _.identity,
+ SELECT_BUCKET: (bucket, expanding = false) => ({ bucket, expanding }),
SELECT_BUCKET_DONE: _.noop,
/* Pass in the index of filter inside savedFilters array. */
- SELECT_SAVED_FILTER: _.identity,
+ // SELECT_SAVED_FILTER: _.identity,
/* Pass in true/false to enable/disable. */
- SET_EDIT_SAVED_FILTERS_MODE: _.identity,
+ // SET_EDIT_SAVED_FILTERS_MODE: _.identity,
- UPDATE_ALL_SAVED_FILTERS: updateAllSavedFilters,
- UPDATE_SAVED_FILTER: updateSavedFilter,
+ // UPDATE_ALL_SAVED_FILTERS: updateAllSavedFilters,
+ // UPDATE_SAVED_FILTER: updateSavedFilter,
},
},
});
diff --git a/src/shared/components/ChallengeTile/index.jsx b/src/shared/components/ChallengeTile/index.jsx
index 3e90be664f..c1611df3dd 100644
--- a/src/shared/components/ChallengeTile/index.jsx
+++ b/src/shared/components/ChallengeTile/index.jsx
@@ -82,8 +82,8 @@ class ChallengeTile extends React.Component {
margin: '10px 5px',
};
- const isDevelopment = track === COMPETITION_TRACKS.DEVELOP;
- const isDesign = track === COMPETITION_TRACKS.DESIGN;
+ const isDevelopment = track === COMPETITION_TRACKS.DEV;
+ const isDesign = track === COMPETITION_TRACKS.DES;
return (
@@ -308,7 +308,7 @@ class ChallengeTile extends React.Component {
- { track !== COMPETITION_TRACKS.DATA_SCIENCE
+ { track !== COMPETITION_TRACKS.DS
&& (
diff --git a/src/shared/components/Contentful/ChallengesBlock/Card/index.jsx b/src/shared/components/Contentful/ChallengesBlock/Card/index.jsx
index 3c51580da6..565036305b 100644
--- a/src/shared/components/Contentful/ChallengesBlock/Card/index.jsx
+++ b/src/shared/components/Contentful/ChallengesBlock/Card/index.jsx
@@ -30,13 +30,13 @@ export default function Card({
let TrackTag;
switch (track.toLowerCase()) {
- case COMPETITION_TRACKS.DATA_SCIENCE:
+ case COMPETITION_TRACKS.DS:
TrackTag = DataScienceTrackTag;
break;
- case COMPETITION_TRACKS.DESIGN:
+ case COMPETITION_TRACKS.DES:
TrackTag = DesignTrackTag;
break;
- case COMPETITION_TRACKS.DEVELOP:
+ case COMPETITION_TRACKS.DEV:
TrackTag = DevelopmentTrackTag;
break;
case COMPETITION_TRACKS.QA:
diff --git a/src/shared/components/Dashboard/CurrentActivity/Challenges/ChallengeCard/index.jsx b/src/shared/components/Dashboard/CurrentActivity/Challenges/ChallengeCard/index.jsx
index dbd735b2c5..98d1699988 100644
--- a/src/shared/components/Dashboard/CurrentActivity/Challenges/ChallengeCard/index.jsx
+++ b/src/shared/components/Dashboard/CurrentActivity/Challenges/ChallengeCard/index.jsx
@@ -47,13 +47,13 @@ export default function ChallengeCard({
let EventTag;
switch (track) {
- case COMPETITION_TRACKS.DATA_SCIENCE:
+ case COMPETITION_TRACKS.DS:
EventTag = DataScienceTrackEventTag;
break;
- case COMPETITION_TRACKS.DESIGN:
+ case COMPETITION_TRACKS.DES:
EventTag = DesignTrackEventTag;
break;
- case COMPETITION_TRACKS.DEVELOP:
+ case COMPETITION_TRACKS.DEV:
EventTag = DevelopmentTrackEventTag;
break;
case COMPETITION_TRACKS.QA:
@@ -66,7 +66,7 @@ export default function ChallengeCard({
const STALLED_MSG = 'Stalled';
const DRAFT_MSG = 'In Draft';
- const forumEndpoint = track === COMPETITION_TRACKS.DESIGN
+ const forumEndpoint = track === COMPETITION_TRACKS.DES
? `/?module=ThreadList&forumID=${legacy.forumId}`
: `/?module=Category&categoryID=${legacy.forumId}`;
diff --git a/src/shared/components/SubmissionManagement/Submission/index.jsx b/src/shared/components/SubmissionManagement/Submission/index.jsx
index 663456bc5c..2c29d62ef8 100644
--- a/src/shared/components/SubmissionManagement/Submission/index.jsx
+++ b/src/shared/components/SubmissionManagement/Submission/index.jsx
@@ -51,7 +51,7 @@ export default function Submission(props) {
{formatDate(submissionObject.created)}
{
- track === COMPETITION_TRACKS.DESIGN && (
+ track === COMPETITION_TRACKS.DES && (
{submissionObject.screening
&& (
@@ -68,7 +68,7 @@ export default function Submission(props) {
- { track === COMPETITION_TRACKS.DEVELOP ? (
+ { track === COMPETITION_TRACKS.DEV ? (
{isChallengeBelongToTopgearGroup
? ( Enter the URL to your submission. )
: ( Upload your entire submission as a single zip file. )}
) : null }
- { track === COMPETITION_TRACKS.DESIGN ? (
+ { track === COMPETITION_TRACKS.DES ? (
- Place your submission files into a "Submission.zip" file.
diff --git a/src/shared/components/SubmissionPage/Uploading/index.jsx b/src/shared/components/SubmissionPage/Uploading/index.jsx
index 600fbca5ba..7f22beff1c 100644
--- a/src/shared/components/SubmissionPage/Uploading/index.jsx
+++ b/src/shared/components/SubmissionPage/Uploading/index.jsx
@@ -158,7 +158,7 @@ const Uploading = ({
submitDone && !error
&& (
- { track === COMPETITION_TRACKS.DESIGN ? (
+ { track === COMPETITION_TRACKS.DES ? (
- {challengesInCommunity}
+ {/* {challengesInCommunity} */}
);
@@ -166,7 +170,7 @@ export default function FiltersPanel({
There are
- {challengesInCommunity}
+ {/* {challengesInCommunity} */}
{' '}
challenges in this sub community
@@ -179,21 +183,44 @@ export default function FiltersPanel({
);
};
- const communityOps = communityFilters.filter(community => !community.hidden)
+ const mapCommunityOps = (community) => {
+ if (community.challengeFilter
+ && community.challengeFilter.events && community.challengeFilter.events.length) {
+ return `event_${community.challengeFilter.events[0]}`;
+ }
+
+ return community.communityName === 'All' ? '' : community.groupIds[0];
+ };
+
+ const communityOps = communityFilters.filter(community => (
+ (!community.hidden && !community.hideFilter) || community.communityName === 'All'
+ ))
.map(community => ({
label: community.communityName,
- value: community.communityId,
+ value: mapCommunityOps(community),
name: community.communityName,
data: getLabel(community),
}));
- const disableClearSaveFilterButtons = isSavingFilter || (
- selectedCommunityId === defaultCommunityId
- && _.isEmpty(filterState)
- );
+ // const disableClearSaveFilterButtons = false;
+ // const disableClearSaveFilterButtons = isSavingFilter || (
+ // selectedCommunityId === defaultCommunityId
+ // && _.isEmpty(filterState)
+ // );
+ const disableClearSaveFilterButtons = isFilterEmpty(filterState);
const mapOps = item => ({ label: item, value: item });
- const mapTypes = item => ({ label: item.name, value: item.id });
+ const mapTypes = item => ({ label: item.name, value: item.abbreviation });
+ const getCommunityOption = () => {
+ if (filterState.events && filterState.events.length) {
+ return `event_${filterState.events[0]}`;
+ }
+ if (filterState.groups && filterState.groups.length) {
+ return filterState.groups[0];
+ }
+ return '';
+ };
+
return (
@@ -221,7 +248,7 @@ export default function FiltersPanel({
multi
onChange={(value) => {
const tags = value ? value.split(',') : undefined;
- setFilterState(Filter.setTags(filterState, tags));
+ setFilterState({ ..._.clone(filterState), tags });
}}
options={validKeywords.map(mapOps)}
simpleValue
@@ -237,10 +264,28 @@ export default function FiltersPanel({
autoBlur
clearable={false}
id="community-select"
- onChange={selectCommunity}
+ // onChange={selectCommunity}
+ onChange={(value) => {
+ if (value && value.startsWith('event_')) {
+ const event = value.split('_')[1];
+ setFilterState({
+ ..._.clone(filterState),
+ events: event === '' ? [] : [event],
+ groups: [],
+ });
+ } else {
+ const group = value;
+ setFilterState({
+ ..._.clone(filterState),
+ groups: group === '' ? [] : [group],
+ events: [],
+ });
+ }
+ // setFilterState({ ..._.clone(filterState), groups: [value] });
+ }}
options={communityOps}
simpleValue
- value={selectedCommunityId}
+ value={getCommunityOption()}
valueRenderer={option => (
{option.name}
@@ -261,7 +306,7 @@ export default function FiltersPanel({
multi
onChange={(value) => {
const types = value ? value.split(',') : undefined;
- setFilterState(Filter.setTypes(filterState, types));
+ setFilterState({ ..._.clone(filterState), types });
}}
options={validTypes.map(mapTypes)}
simpleValue
@@ -297,6 +342,28 @@ export default function FiltersPanel({
) : null
}
+ {/* Only shown when the All Challenges bucket is selected */}
+ { isAllBucket
+ ? (
+
+
+
+ ) : null
+ }
{
- let d = dates.endDate ? dates.endDate.toISOString() : null;
- let state = Filter.setEndDate(filterState, d);
- d = dates.startDate ? dates.startDate.toISOString() : null;
- state = Filter.setStartDate(state, d);
- setFilterState(state);
+ const d = dates.endDate ? dates.endDate.toISOString() : null;
+ const s = dates.startDate ? dates.startDate.toISOString() : null;
+ setFilterState({
+ ..._.clone(filterState),
+ endDateStart: s,
+ startDateEnd: d,
+ });
}}
startDate={
- filterState.startDate && moment(filterState.startDate)
+ filterState.endDateStart
+ && moment(filterState.endDateStart)
}
/>
@@ -325,17 +395,20 @@ export default function FiltersPanel({
{
- let d = dates.endDate ? dates.endDate.toISOString() : null;
- let state = Filter.setEndDate(filterState, d);
- d = dates.startDate ? dates.startDate.toISOString() : null;
- state = Filter.setStartDate(state, d);
- setFilterState(state);
+ const d = dates.endDate ? dates.endDate.toISOString() : null;
+ const s = dates.startDate ? dates.startDate.toISOString() : null;
+ setFilterState({
+ ..._.clone(filterState),
+ endDateStart: s,
+ startDateEnd: d,
+ });
}}
startDate={
- filterState.startDate && moment(filterState.startDate)
+ filterState.endDateStart
+ && moment(filterState.endDateStart)
}
/>
@@ -346,9 +419,24 @@ export default function FiltersPanel({
composeContextTheme={COMPOSE.SOFT}
disabled={disableClearSaveFilterButtons}
onClick={() => {
- setFilterState({});
+ setFilterState({
+ tracks: {
+ Dev: true,
+ Des: true,
+ DS: true,
+ QA: true,
+ },
+ name: '',
+ tags: [],
+ types: [],
+ groups: [],
+ events: [],
+ endDateStart: null,
+ startDateEnd: null,
+ });
selectCommunity(defaultCommunityId);
setSearchText('');
+ // localStorage.setItem('trackStatus', JSON.stringify({}));
}}
size="sm"
theme={{ button: style.button }}
@@ -370,10 +458,10 @@ export default function FiltersPanel({
}
FiltersPanel.defaultProps = {
- challenges: [],
+ // challenges: [],
hidden: false,
isAuth: false,
- isSavingFilter: false,
+ // isSavingFilter: false,
isReviewOpportunitiesBucket: false,
// onSaveFilter: _.noop,
onClose: _.noop,
@@ -385,16 +473,17 @@ FiltersPanel.propTypes = {
communityName: PT.string.isRequired,
})).isRequired,
defaultCommunityId: PT.string.isRequired,
+ activeBucket: PT.string.isRequired,
filterState: PT.shape().isRequired,
- challenges: PT.arrayOf(PT.shape()),
+ // challenges: PT.arrayOf(PT.shape()),
hidden: PT.bool,
isAuth: PT.bool,
auth: PT.shape().isRequired,
- isSavingFilter: PT.bool,
+ // isSavingFilter: PT.bool,
isReviewOpportunitiesBucket: PT.bool,
// onSaveFilter: PT.func,
selectCommunity: PT.func.isRequired,
- selectedCommunityId: PT.string.isRequired,
+ // selectedCommunityId: PT.string.isRequired,
setFilterState: PT.func.isRequired,
setSearchText: PT.func.isRequired,
validKeywords: PT.arrayOf(PT.string).isRequired,
diff --git a/src/shared/components/challenge-listing/Filters/FiltersPanel/style.scss b/src/shared/components/challenge-listing/Filters/FiltersPanel/style.scss
index 21c13a907a..c918eb2043 100644
--- a/src/shared/components/challenge-listing/Filters/FiltersPanel/style.scss
+++ b/src/shared/components/challenge-listing/Filters/FiltersPanel/style.scss
@@ -382,6 +382,32 @@ $panel-radius-4: $corner-radius * 2;
}
}
}
+
+ &.status {
+ @include calc(width, '50% - 45px - (12px + 112px) * 2 - 96px');
+
+ order: 3; // Show after Date Picker when in lg screen mode
+
+ @include xs-to-sm {
+ margin-top: $panel-space-15;
+ width: 100%;
+ }
+
+ :global(.Select) {
+ z-index: 3;
+ }
+
+ margin-right: $panel-space-30;
+
+ :global(.Select-value) {
+ top: inherit;
+ background: $tc-white !important;
+ font-weight: 300;
+ font-size: 13px;
+ color: $tc-gray-50;
+ line-height: $panel-space-30 - 2;
+ }
+ }
}
}
diff --git a/src/shared/components/challenge-listing/Listing/Bucket/index.jsx b/src/shared/components/challenge-listing/Listing/Bucket/index.jsx
index d58a3c0681..38175add29 100644
--- a/src/shared/components/challenge-listing/Listing/Bucket/index.jsx
+++ b/src/shared/components/challenge-listing/Listing/Bucket/index.jsx
@@ -6,39 +6,42 @@
import _ from 'lodash';
import PT from 'prop-types';
-import qs from 'qs';
+// import qs from 'qs';
import React, { useRef } from 'react';
-import { config } from 'topcoder-react-utils';
+// import { config } from 'topcoder-react-utils';
import Sort from 'utils/challenge-listing/sort';
-import { NO_LIVE_CHALLENGES_CONFIG, BUCKETS } from 'utils/challenge-listing/buckets';
+// import { NO_LIVE_CHALLENGES_CONFIG, BUCKETS, BUCKET_DATA }
+// from 'utils/challenge-listing/buckets';
+import { NO_LIVE_CHALLENGES_CONFIG, BUCKET_DATA } from 'utils/challenge-listing/buckets';
import SortingSelectBar from 'components/SortingSelectBar';
import Waypoint from 'react-waypoint';
-import { challenge as challengeUtils } from 'topcoder-react-lib';
+// import { challenge as challengeUtils } from 'topcoder-react-lib';
import CardPlaceholder from '../../placeholders/ChallengeCard';
import ChallengeCard from '../../ChallengeCard';
import './style.scss';
-const COLLAPSED_SIZE = 10;
+// const COLLAPSED_SIZE = 10;
-const Filter = challengeUtils.filter;
+// const Filter = challengeUtils.filter;
export default function Bucket({
bucket,
- bucketId,
+ // bucketId,
challenges,
challengeTypes,
challengesUrl,
expanded,
+ expanding,
expand,
filterState,
- keepPlaceholders,
+ // keepPlaceholders,
loading,
loadMore,
newChallengeDetails,
openChallengesInNewTabs,
prizeMode,
selectChallengeDetailsTab,
- selectedCommunityId,
+ // selectedCommunityId,
setFilterState,
setSort,
sort,
@@ -46,7 +49,7 @@ export default function Bucket({
expandedTags,
expandTag,
activeBucket,
- searchTimestamp,
+ // searchTimestamp,
isLoggedIn,
}) {
const refs = useRef([]);
@@ -56,56 +59,75 @@ export default function Bucket({
refs.current.push(el);
}
};
- const filter = Filter.getFilterFunction(bucket.filter);
- const activeSort = sort || bucket.sorts[0];
-
- const sortedChallenges = _.clone(challenges);
- sortedChallenges.sort(Sort[activeSort].func);
-
- const bucketQuery = qs.stringify({
- bucket: bucketId,
- communityId: selectedCommunityId || undefined,
- filter: filterState,
- }, { encodeValuesOnly: true });
-
- let expandable = false;
- const filteredChallenges = [];
- for (let i = 0; i < sortedChallenges.length; i += 1) {
- if (filter(sortedChallenges[i])) {
- filteredChallenges.push(sortedChallenges[i]);
- }
- if (!expanded && filteredChallenges.length >= COLLAPSED_SIZE) {
- expandable = true;
- break;
+ const activeSort = sort || 'startDate';
+
+ // const sortedChallenges = activeBucket === 'all' ?
+ // _.clone(challenges.slice(0, 10)) : _.clone(challenges);
+ let sortedChallenges;
+ if (activeBucket === 'all' && !expanded) {
+ if (loadMore && challenges.length > 10) {
+ sortedChallenges = _.clone(challenges);
+ } else {
+ sortedChallenges = _.clone(challenges.slice(0, 10));
}
+ } else {
+ sortedChallenges = _.clone(challenges);
}
-
- let noPastResult = false;
+ // sortedChallenges.sort(Sort[activeSort].func);
+
+ // const bucketQuery = qs.stringify({
+ // bucket: bucketId,
+ // communityId: selectedCommunityId || undefined,
+ // filter: filterState,
+ // }, { encodeValuesOnly: true });
+
+ const expandable = activeBucket === 'all';
+ // const filteredChallenges = [];
+ // for (let i = 0; i < sortedChallenges.length; i += 1) {
+ // if (filter(sortedChallenges[i])) {
+ // filteredChallenges.push(sortedChallenges[i]);
+ // }
+ // if (!expanded && filteredChallenges.length >= COLLAPSED_SIZE) {
+ // expandable = true;
+ // break;
+ // }
+ // }
+
+ // let noPastResult = false;
// check if no past challenge is found after configurable amount of time has passed
- if (activeBucket === BUCKETS.PAST && searchTimestamp > 0
- && !filteredChallenges.length && !refs.current.length) {
- const elapsedTime = Date.now() - searchTimestamp;
- noPastResult = elapsedTime > config.SEARCH_TIMEOUT;
- }
-
- if (noPastResult || (!filteredChallenges.length && !loadMore)) {
- if (activeBucket === BUCKETS.ALL) {
- return null;
- }
+ // if (activeBucket === BUCKETS.PAST && searchTimestamp > 0) {
+ // && !filteredChallenges.length && !refs.current.length)
+ // const elapsedTime = Date.now() - searchTimestamp;
+ // noPastResult = elapsedTime > config.SEARCH_TIMEOUT;
+ // }
+
+ // if (noPastResult
+ // // || (!filteredChallenges.length && !loadMore)) {
+ // ) {
+ // if (activeBucket === BUCKETS.ALL) {
+ // return null;
+ // }
+ // return (
+ //
+ // {/* {`${NO_LIVE_CHALLENGES_CONFIG[bucketId]}`} */}
+ //
+ // );
+ // }
+
+ if (!loading && sortedChallenges.length === 0) {
return (
- {`${NO_LIVE_CHALLENGES_CONFIG[bucketId]}`}
+ { `${NO_LIVE_CHALLENGES_CONFIG[bucket]}` }
);
}
-
- const cards = filteredChallenges.map(challenge => (
+ const cards = sortedChallenges.map(challenge => (
setFilterState({ tags: [tag] })}
+ onTechTagClicked={tag => setFilterState({ ..._.clone(filterState), tags: [tag] })}
openChallengesInNewTabs={openChallengesInNewTabs}
prizeMode={prizeMode}
key={challenge.id}
@@ -119,32 +141,35 @@ export default function Bucket({
));
const placeholders = [];
- if ((loading || keepPlaceholders) && (!expandable || expanded)) {
- for (let i = 0; i < 8; i += 1) {
+ if (loading) {
+ // if ((loading || keepPlaceholders) && (!expandable || expanded)) {
+ for (let i = 0; i < 10; i += 1) {
placeholders.push();
}
}
- if (filteredChallenges.length && filteredChallenges.length < COLLAPSED_SIZE
- && placeholders.length
- && (!expandable && loadMore && !loading)) {
- // loaded challenge list has less than configured collapsed
- // invoke loadMore here
- // instead of waiting for scrolling to hit the react-waypoint to do the loadMore
- loadMore();
- }
+ // if (filteredChallenges.length && filteredChallenges.length < COLLAPSED_SIZE
+ // && placeholders.length
+ // && (!expandable && loadMore && !loading)) {
+ // // loaded challenge list has less than configured collapsed
+ // // invoke loadMore here
+ // // instead of waiting for scrolling to hit the react-waypoint to do the loadMore
+ // loadMore();
+ // }
return (
+ // challenges.length !== 0
+ // && (
+ // )
);
}
@@ -183,7 +211,7 @@ Bucket.defaultProps = {
expanded: false,
expand: _.noop,
challengeTypes: [],
- keepPlaceholders: false,
+ // keepPlaceholders: false,
loading: false,
loadMore: null,
newChallengeDetails: false,
@@ -193,26 +221,28 @@ Bucket.defaultProps = {
expandedTags: [],
expandTag: null,
activeBucket: '',
- searchTimestamp: 0,
+ expanding: false,
+ // searchTimestamp: 0,
};
Bucket.propTypes = {
- bucket: PT.shape().isRequired,
- bucketId: PT.string.isRequired,
+ bucket: PT.string.isRequired,
+ // bucketId: PT.string.isRequired,
expanded: PT.bool,
+ expanding: PT.bool,
expand: PT.func,
challenges: PT.arrayOf(PT.shape()).isRequired,
challengeTypes: PT.arrayOf(PT.shape()),
challengesUrl: PT.string.isRequired,
filterState: PT.shape().isRequired,
- keepPlaceholders: PT.bool,
+ // keepPlaceholders: PT.bool,
loading: PT.bool,
loadMore: PT.func,
newChallengeDetails: PT.bool,
openChallengesInNewTabs: PT.bool,
prizeMode: PT.string.isRequired,
selectChallengeDetailsTab: PT.func.isRequired,
- selectedCommunityId: PT.string.isRequired,
+ // selectedCommunityId: PT.string.isRequired,
setFilterState: PT.func.isRequired,
setSort: PT.func.isRequired,
sort: PT.string,
@@ -220,6 +250,6 @@ Bucket.propTypes = {
expandedTags: PT.arrayOf(PT.number),
expandTag: PT.func,
activeBucket: PT.string,
- searchTimestamp: PT.number,
+ // searchTimestamp: PT.number,
isLoggedIn: PT.bool.isRequired,
};
diff --git a/src/shared/components/challenge-listing/Listing/ReviewOpportunityBucket/index.jsx b/src/shared/components/challenge-listing/Listing/ReviewOpportunityBucket/index.jsx
index b7b47dd371..dff18000ea 100644
--- a/src/shared/components/challenge-listing/Listing/ReviewOpportunityBucket/index.jsx
+++ b/src/shared/components/challenge-listing/Listing/ReviewOpportunityBucket/index.jsx
@@ -5,6 +5,7 @@ import _ from 'lodash';
import PT from 'prop-types';
import React from 'react';
import Sort from 'utils/challenge-listing/sort';
+import { BUCKET_DATA } from 'utils/challenge-listing/buckets';
import SortingSelectBar from 'components/SortingSelectBar';
import Waypoint from 'react-waypoint';
import { challenge as challengeUtils } from 'topcoder-react-lib';
@@ -35,7 +36,7 @@ export default function ReviewOpportunityBucket({
}) {
if (!opportunities.length && !loadMore) return null;
- const activeSort = sort || bucket.sorts[0];
+ const activeSort = sort || BUCKET_DATA[bucket].sorts[0];
const sortedOpportunities = _.clone(opportunities);
sortedOpportunities.sort(Sort[activeSort].func);
@@ -46,15 +47,16 @@ export default function ReviewOpportunityBucket({
* a filter is changed. */
const filteredOpportunities = sortedOpportunities.filter(
Filter.getReviewOpportunitiesFilterFunction({
- ...bucket.filter, // Default bucket filters from utils/buckets.js
+ ...BUCKET_DATA[bucket].filter, // Default bucket filters from utils/buckets.js
...filterState, // User selected filters
}, challengeTypes),
+ // }),
);
const cards = filteredOpportunities.map(item => (
setFilterState({ tags: [tag] })}
@@ -65,7 +67,7 @@ export default function ReviewOpportunityBucket({
const placeholders = [];
if ((loading || keepPlaceholders) && cards.length === 0) {
- for (let i = 0; i < 8; i += 1) {
+ for (let i = 0; i < 10; i += 1) {
placeholders.push();
}
}
@@ -76,7 +78,7 @@ export default function ReviewOpportunityBucket({
title="Open for review"
onSelect={setSort}
options={
- bucket.sorts.map(item => ({
+ BUCKET_DATA[bucket].sorts.map(item => ({
label: Sort[item].name,
value: item,
}))
@@ -116,7 +118,8 @@ ReviewOpportunityBucket.defaultProps = {
// Prop Validation
ReviewOpportunityBucket.propTypes = {
- bucket: PT.shape().isRequired,
+ // bucket: PT.shape().isRequired,
+ bucket: PT.string.isRequired,
challengesUrl: PT.string.isRequired,
expandedTags: PT.arrayOf(PT.number),
expandTag: PT.func,
diff --git a/src/shared/components/challenge-listing/Listing/index.jsx b/src/shared/components/challenge-listing/Listing/index.jsx
index 12e29b1b91..a7441474d6 100644
--- a/src/shared/components/challenge-listing/Listing/index.jsx
+++ b/src/shared/components/challenge-listing/Listing/index.jsx
@@ -7,29 +7,47 @@ import React from 'react';
import PT from 'prop-types';
import { connect } from 'react-redux';
import {
- BUCKETS, getBuckets, isReviewOpportunitiesBucket, NO_LIVE_CHALLENGES_CONFIG,
+ BUCKETS, isReviewOpportunitiesBucket, NO_LIVE_CHALLENGES_CONFIG,
+ // BUCKETS, getBuckets, isReviewOpportunitiesBucket, NO_LIVE_CHALLENGES_CONFIG,
} from 'utils/challenge-listing/buckets';
-import { challenge as challengeUtils } from 'topcoder-react-lib';
+// import { challenge as challengeUtils } from 'topcoder-react-lib';
import Bucket from './Bucket';
import ReviewOpportunityBucket from './ReviewOpportunityBucket';
+import CardPlaceholder from '../placeholders/ChallengeCard';
import './style.scss';
-const Filter = challengeUtils.filter;
+// const Filter = challengeUtils.filter;
function Listing({
activeBucket,
auth,
+ allActiveChallengesLoaded,
+ allMyChallengesLoaded,
+ allChallengesLoaded,
+ allOpenForRegistrationChallengesLoaded,
challenges,
+ openForRegistrationChallenges,
+ myChallenges,
+ allChallenges,
+ // pastChallenges,
challengeTypes,
- userChallenges,
+ // userChallenges,
challengesUrl,
communityName,
- extraBucket,
+ // extraBucket,
filterState,
keepPastPlaceholders,
- loadingPastChallenges,
+ // loadingPastChallenges,
loadingReviewOpportunities,
- loadMorePast,
+ loadingMyChallenges,
+ loadMoreMy,
+ loadingAllChallenges,
+ loadMoreAll,
+ loadingOpenForRegistrationChallenges,
+ loadMoreOpenForRegistration,
+ loadingOnGoingChallenges,
+ loadMoreOnGoing,
+ // loadMorePast,
loadMoreReviewOpportunities,
newChallengeDetails,
openChallengesInNewTabs,
@@ -42,34 +60,63 @@ function Listing({
setFilterState,
setSort,
sorts,
+ expanding,
expandedTags,
expandTag,
- pastSearchTimestamp,
+ // pastSearchTimestamp,
isLoggedIn,
+ meta,
}) {
- const buckets = getBuckets(userChallenges);
- const isChallengesAvailable = (bucket) => {
- const filter = Filter.getFilterFunction(buckets[bucket].filter);
- const clonedChallenges = _.clone(challenges);
- const filteredChallenges = [];
- for (let i = 0; i < clonedChallenges.length; i += 1) {
- if (filter(clonedChallenges[i])) {
- filteredChallenges.push(clonedChallenges[i]);
- }
- }
- return filteredChallenges.length > 0;
- };
+ // const buckets = getBuckets(userChallenges);
+ // const isChallengesAvailable = (bucket) => {
+ // // const filter = Filter.getFilterFunction(buckets[bucket].filter);
+ // const clonedChallenges = _.clone(challenges);
+ // const filteredChallenges = [];
+ // for (let i = 0; i < clonedChallenges.length; i += 1) {
+ // // if (filter(clonedChallenges[i])) {
+ // // filteredChallenges.push(clonedChallenges[i]);
+ // // }
+ // }
+ // return filteredChallenges.length > 0;
+ // };
const getBucket = (bucket, expanded = false) => {
- let keepPlaceholders = false;
+ // const keepPlaceholders = false;
let loading;
let loadMore;
- let searchTimestamp;
+ // let searchTimestamp;
+ let bucketChallenges = [];
+ let newExpanded = expanded;
switch (bucket) {
- case BUCKETS.PAST:
- keepPlaceholders = keepPastPlaceholders;
- loading = loadingPastChallenges;
- loadMore = loadMorePast;
- searchTimestamp = pastSearchTimestamp;
+ // case BUCKETS.PAST:
+ // keepPlaceholders = keepPastPlaceholders;
+ // bucketChallenges = [].concat(pastChallenges);
+ // loading = loadingPastChallenges;
+ // loadMore = loadMorePast;
+ // // searchTimestamp = pastSearchTimestamp;
+ // break;
+ case BUCKETS.MY:
+ bucketChallenges = [].concat(myChallenges);
+ loading = loadingMyChallenges;
+ loadMore = allMyChallengesLoaded ? null : loadMoreMy;
+ newExpanded = newExpanded || (+meta.myChallengesCount === bucketChallenges.length);
+ break;
+ case BUCKETS.OPEN_FOR_REGISTRATION:
+ bucketChallenges = [].concat(openForRegistrationChallenges);
+ loading = loadingOpenForRegistrationChallenges;
+ loadMore = allOpenForRegistrationChallengesLoaded ? null : loadMoreOpenForRegistration;
+ newExpanded = newExpanded || (+meta.openChallengesCount === bucketChallenges.length);
+ break;
+ case BUCKETS.ONGOING:
+ bucketChallenges = [].concat(challenges);
+ loading = loadingOnGoingChallenges;
+ loadMore = allActiveChallengesLoaded ? null : loadMoreOnGoing;
+ newExpanded = newExpanded || (+meta.ongoingChallengesCount === bucketChallenges.length);
+ break;
+ case BUCKETS.ALL:
+ bucketChallenges = [].concat(allChallenges);
+ loading = loadingAllChallenges;
+ loadMore = allChallengesLoaded ? null : loadMoreAll;
+ newExpanded = newExpanded || (+meta.allChallengesCount === bucketChallenges.length);
break;
default:
break;
@@ -80,12 +127,13 @@ function Listing({
isReviewOpportunitiesBucket(bucket)
? (
selectBucket(bucket)}
- expanded={expanded}
+ expand={() => {
+ selectBucket(bucket, true);
+ loadMore();
+ }}
+ expanded={newExpanded}
+ expanding={expanding}
expandedTags={expandedTags}
expandTag={expandTag}
filterState={filterState}
- keepPlaceholders={keepPlaceholders}
+ // keepPlaceholders={keepPlaceholders}
loading={loading}
loadMore={loadMore}
newChallengeDetails={newChallengeDetails}
@@ -122,14 +175,14 @@ function Listing({
sort={sorts[bucket]}
userId={_.get(auth, 'user.userId')}
activeBucket={activeBucket}
- searchTimestamp={searchTimestamp}
+ // searchTimestamp={searchTimestamp}
isLoggedIn={isLoggedIn}
/>
)
);
};
- if ((activeBucket !== BUCKETS.ALL)
+ if (!expanding && (activeBucket !== BUCKETS.ALL)
&& (activeBucket !== BUCKETS.SAVED_FILTER)) {
return (
@@ -138,71 +191,121 @@ function Listing({
);
}
- let isFilled = isChallengesAvailable(BUCKETS.OPEN_FOR_REGISTRATION)
- || isChallengesAvailable(BUCKETS.ONGOING);
- if (auth.user) {
- isFilled = isFilled || isChallengesAvailable(BUCKETS.MY);
- }
- if (!isFilled) {
+ // let isFilled = isChallengesAvailable(BUCKETS.OPEN_FOR_REGISTRATION)
+ // || isChallengesAvailable(BUCKETS.ONGOING);
+ // if (auth.user) {
+ // isFilled = isFilled || isChallengesAvailable(BUCKETS.MY);
+ // }
+ // if (!isFilled) {
+ // return (
+ //
+ //
+ // {`${NO_LIVE_CHALLENGES_CONFIG[activeBucket]}`}
+ //
+ //
+ // );
+ // }
+ const loading = loadingMyChallenges
+ || loadingOpenForRegistrationChallenges
+ || loadingOnGoingChallenges;
+ const placeholders = [];
+ if (challenges.length > 0 || (activeBucket === BUCKETS.ALL && allChallenges.length > 0)) {
return (
-
- {`${NO_LIVE_CHALLENGES_CONFIG[activeBucket]}`}
-
+ {preListingMsg}
+ {/* (auth.user && myChallenges.length > 0) ? getBucket(BUCKETS.MY) : null */}
+ {/* {extraBucket ? getBucket(extraBucket) : null} */}
+ {/* openForRegistrationChallenges.length > 0 && getBucket(BUCKETS.OPEN_FOR_REGISTRATION) */}
+ {/* {getBucket(BUCKETS.ONGOING)} */}
+ {getBucket(BUCKETS.ALL)}
);
}
+
+ if (loading) {
+ for (let i = 0; i < 10; i += 1) {
+ placeholders.push( );
+ }
+ }
return (
- {preListingMsg}
- {auth.user ? getBucket(BUCKETS.MY) : null}
- {extraBucket ? getBucket(extraBucket) : null}
- {getBucket(BUCKETS.OPEN_FOR_REGISTRATION)}
- {getBucket(BUCKETS.ONGOING)}
+ {
+ loading
+ ? placeholders
+ : (
+ { `${NO_LIVE_CHALLENGES_CONFIG[activeBucket]}` }
+ )
+ }
);
}
Listing.defaultProps = {
challenges: [],
+ openForRegistrationChallenges: [],
+ myChallenges: [],
+ allChallenges: [],
+ // pastChallenges: [],
challengeTypes: [],
communityName: null,
// currentFilterName: '',
// expanded: false,
expandedTags: [],
expandTag: null,
- extraBucket: null,
- loadMorePast: null,
+ // extraBucket: null,
+ // loadMorePast: null,
loadMoreReviewOpportunities: null,
+ loadMoreMy: null,
+ loadMoreAll: null,
+ loadMoreOpenForRegistration: null,
+ loadMoreOnGoing: null,
preListingMsg: null,
reviewOpportunities: [],
// onTechTagClicked: _.noop,
// onExpandFilterResult: _.noop,
openChallengesInNewTabs: false,
- pastSearchTimestamp: 0,
- userChallenges: [],
+ // pastSearchTimestamp: 0,
+ // userChallenges: [],
+ expanding: false,
};
Listing.propTypes = {
activeBucket: PT.string.isRequired,
+ expanding: PT.bool,
auth: PT.shape({
tokenV3: PT.string,
user: PT.shape({
userId: PT.string,
}),
}).isRequired,
+ allActiveChallengesLoaded: PT.bool.isRequired,
+ allMyChallengesLoaded: PT.bool.isRequired,
+ allChallengesLoaded: PT.bool.isRequired,
+ allOpenForRegistrationChallengesLoaded: PT.bool.isRequired,
challenges: PT.arrayOf(PT.shape()),
+ openForRegistrationChallenges: PT.arrayOf(PT.shape()),
+ myChallenges: PT.arrayOf(PT.shape()),
+ allChallenges: PT.arrayOf(PT.shape()),
+ // pastChallenges: PT.arrayOf(PT.shape()),
challengeTypes: PT.arrayOf(PT.shape()),
challengesUrl: PT.string.isRequired,
communityName: PT.string,
expandedTags: PT.arrayOf(PT.number),
expandTag: PT.func,
- extraBucket: PT.string,
+ // extraBucket: PT.string,
filterState: PT.shape().isRequired,
keepPastPlaceholders: PT.bool.isRequired,
- loadingPastChallenges: PT.bool.isRequired,
+ // loadingPastChallenges: PT.bool.isRequired,
+ loadingMyChallenges: PT.bool.isRequired,
+ loadingAllChallenges: PT.bool.isRequired,
+ loadingOpenForRegistrationChallenges: PT.bool.isRequired,
+ loadingOnGoingChallenges: PT.bool.isRequired,
loadingReviewOpportunities: PT.bool.isRequired,
- loadMorePast: PT.func,
+ loadMoreMy: PT.func,
+ loadMoreAll: PT.func,
+ loadMoreOnGoing: PT.func,
+ loadMoreOpenForRegistration: PT.func,
+ // loadMorePast: PT.func,
loadMoreReviewOpportunities: PT.func,
newChallengeDetails: PT.bool.isRequired,
openChallengesInNewTabs: PT.bool,
@@ -215,16 +318,21 @@ Listing.propTypes = {
setFilterState: PT.func.isRequired,
setSort: PT.func.isRequired,
sorts: PT.shape().isRequired,
- pastSearchTimestamp: PT.number,
- userChallenges: PT.arrayOf(PT.string),
+ // pastSearchTimestamp: PT.number,
+ // userChallenges: PT.arrayOf(PT.string),
isLoggedIn: PT.bool.isRequired,
+ meta: PT.shape().isRequired,
};
const mapStateToProps = (state) => {
const cl = state.challengeListing;
return {
+ // allActiveChallengesLoaded: cl.allActiveChallengesLoaded,
allActiveChallengesLoaded: cl.allActiveChallengesLoaded,
- pastSearchTimestamp: cl.pastSearchTimestamp,
+ allMyChallengesLoaded: cl.allMyChallengesLoaded,
+ allChallengesLoaded: cl.allChallengesLoaded,
+ allOpenForRegistrationChallengesLoaded: cl.allOpenForRegistrationChallengesLoaded,
+ // pastSearchTimestamp: cl.pastSearchTimestamp,
challengeTypes: cl.challengeTypes,
};
};
diff --git a/src/shared/components/challenge-listing/Sidebar/BucketSelector/Bucket/index.jsx b/src/shared/components/challenge-listing/Sidebar/BucketSelector/Bucket/index.jsx
index 83984b338b..72e09649ec 100644
--- a/src/shared/components/challenge-listing/Sidebar/BucketSelector/Bucket/index.jsx
+++ b/src/shared/components/challenge-listing/Sidebar/BucketSelector/Bucket/index.jsx
@@ -3,72 +3,73 @@
*/
import _ from 'lodash';
-import { challenge as challengeUtils } from 'topcoder-react-lib';
+// import { challenge as challengeUtils } from 'topcoder-react-lib';
+import { BUCKETS, BUCKET_DATA } from 'utils/challenge-listing/buckets';
import PT from 'prop-types';
import { connect } from 'react-redux';
import React from 'react';
import './style.scss';
-const Filter = challengeUtils.filter;
+// const Filter = challengeUtils.filter;
function Bucket({
active,
bucket,
- challenges,
+ // challenges,
disabled,
onClick,
- allActiveChallengesLoaded,
+ // allActiveChallengesLoaded,
meta,
}) {
- let countEl;
- if (!bucket.hideCount && !disabled) {
- const filter = Filter.getFilterFunction(bucket.filter);
- const clonedChallenges = _.clone(challenges);
- const filteredChallenges = [];
- for (let i = 0; i < clonedChallenges.length; i += 1) {
- if (filter(clonedChallenges[i])) {
- filteredChallenges.push(clonedChallenges[i]);
- }
- }
- let count;
- if (allActiveChallengesLoaded) {
- count = challenges.filter(filter).length;
- } else {
- switch (bucket.name) {
- case 'All Challenges':
- count = meta.allChallengesCount;
- break;
- case 'My Challenges':
- count = filteredChallenges.length;
- break;
- case 'Open for registration':
- count = meta.openChallengesCount;
- break;
- case 'Ongoing challenges':
- count = meta.ongoingChallengesCount;
- break;
- default:
- }
- }
- countEl = (
-
- {count}
-
- );
+ // let countEl;
+ // if (!disabled) { // !bucket.hideCount &&
+ // const filter = Filter.getFilterFunction(bucket.filter);
+ // const clonedChallenges = _.clone(challenges);
+ // const filteredChallenges = [];
+ // for (let i = 0; i < clonedChallenges.length; i += 1) {
+ // if (filter(clonedChallenges[i])) {
+ // filteredChallenges.push(clonedChallenges[i]);
+ // }
+ // }
+ let count;
+ // if (allActiveChallengesLoaded) {
+ // count = challenges.filter(filter).length;
+ // } else {
+ switch (bucket) {
+ case BUCKETS.ALL:
+ count = meta.allChallengesCount;
+ break;
+ case BUCKETS.MY:
+ count = meta.myChallengesCount;
+ break;
+ case BUCKETS.OPEN_FOR_REGISTRATION:
+ count = meta.openChallengesCount;
+ break;
+ case BUCKETS.ONGOING:
+ count = meta.ongoingChallengesCount;
+ break;
+ default:
}
-
- const error = Boolean(bucket.error) && (
-
- {bucket.error}
-
+ // }
+ const countEl = (
+
+ {count}
+
);
+ // }
+
+ // const error = Boolean(bucket.error) && (
+ //
+ // {bucket.error}
+ //
+ // );
if (active) {
return (
- {bucket.name}
- {countEl}
- {error}
+ {BUCKET_DATA[bucket].name}
+ {bucket !== BUCKETS.ALL && countEl}
+ {/* {error} */}
);
}
@@ -81,9 +82,9 @@ function Bucket({
styleName="bucket"
tabIndex={0}
>
- {bucket.name}
- {countEl}
- {error}
+ {BUCKET_DATA[bucket].name}
+ {bucket !== BUCKETS.ALL && countEl}
+ {/* {error} */}
);
}
@@ -97,23 +98,24 @@ Bucket.defaultProps = {
Bucket.propTypes = {
active: PT.bool,
- bucket: PT.shape({
- hideCount: PT.bool,
- name: PT.string.isRequired,
- error: PT.string,
- filter: PT.any,
- }).isRequired,
- challenges: PT.arrayOf(PT.shape).isRequired,
+ bucket: PT.string.isRequired,
+ // bucket: PT.shape({
+ // // hideCount: PT.bool,
+ // name: PT.string.isRequired,
+ // error: PT.string,
+ // filter: PT.any,
+ // }).isRequired,
+ // challenges: PT.arrayOf(PT.shape).isRequired,
disabled: PT.bool,
onClick: PT.func,
meta: PT.shape(),
- allActiveChallengesLoaded: PT.bool.isRequired,
+ // allActiveChallengesLoaded: PT.bool.isRequired,
};
const mapStateToProps = (state) => {
const cl = state.challengeListing;
return {
- allActiveChallengesLoaded: cl.allActiveChallengesLoaded,
+ // allActiveChallengesLoaded: cl.allActiveChallengesLoaded,
meta: cl.meta,
};
};
diff --git a/src/shared/components/challenge-listing/Sidebar/BucketSelector/index.jsx b/src/shared/components/challenge-listing/Sidebar/BucketSelector/index.jsx
index 66d7ea6988..0a971950fe 100644
--- a/src/shared/components/challenge-listing/Sidebar/BucketSelector/index.jsx
+++ b/src/shared/components/challenge-listing/Sidebar/BucketSelector/index.jsx
@@ -7,87 +7,92 @@
import PT from 'prop-types';
import React from 'react';
import { BUCKETS } from 'utils/challenge-listing/buckets';
-import { challenge as challengeUtils } from 'topcoder-react-lib';
+// import { challenge as challengeUtils } from 'topcoder-react-lib';
import Bucket from './Bucket';
import './style.scss';
-const Filter = challengeUtils.filter;
+// const Filter = challengeUtils.filter;
// DISABLED: Until feeds.topcoder.com domain fixed community-app#4606
// const RSS_LINK = 'http://feeds.topcoder.com/challenges/feed?list=active&contestType=all';
export default function BucketSelector({
activeBucket,
- activeSavedFilter,
- buckets,
- challenges,
- communityFilter,
+ // activeSavedFilter,
+ // buckets,
+ // challenges,
+ // communityFilter,
disabled,
- extraBucket,
- filterState,
+ expanding,
+ // extraBucket,
+ // filterState,
isAuth,
- savedFilters,
+ // savedFilters,
selectBucket,
- selectSavedFilter,
- setEditSavedFiltersMode,
+ // selectSavedFilter,
+ // setEditSavedFiltersMode,
}) {
- let filteredChallenges = challenges.filter(Filter.getFilterFunction(filterState));
+ // let filteredChallenges = challenges.filter(Filter.getFilterFunction(filterState));
- if (communityFilter) {
- filteredChallenges = filteredChallenges.filter(Filter.getFilterFunction(communityFilter));
- }
+ // if (communityFilter) {
+ // filteredChallenges = filteredChallenges.filter(Filter.getFilterFunction(communityFilter));
+ // }
- const getBucket = bucket => (
- {
- selectBucket(bucket);
- /* eslint-env browser */
- document.body.scrollTop = 0;
- document.documentElement.scrollTop = 0;
- }}
- />
- );
+ const getBucket = (bucket) => {
+ const isActive = expanding ? bucket === BUCKETS.ALL : activeBucket === bucket;
+ return (
+ {
+ selectBucket(bucket);
+ /* eslint-env browser */
+ document.body.scrollTop = 0;
+ document.documentElement.scrollTop = 0;
+ }}
+ />
+ );
+ };
- const savedFiltersRender = savedFilters.map((item, index) => (
- selectSavedFilter(index)}
- />
- ));
+ // const savedFiltersRender = savedFilters.map((item, index) => (
+ // selectSavedFilter(index)}
+ // />
+ // ));
return (
{getBucket(BUCKETS.ALL)}
{isAuth ? getBucket(BUCKETS.MY) : null}
- {extraBucket ? getBucket(extraBucket) : null}
+ {/* {extraBucket ? getBucket(extraBucket) : null} */}
{getBucket(BUCKETS.OPEN_FOR_REGISTRATION)}
- {getBucket(BUCKETS.ONGOING)}
+ {/* DISABLED: Until api receive fix community-app#5073 */}
+ {/* {getBucket(BUCKETS.ONGOING)} */}
{getBucket(BUCKETS.REVIEW_OPPORTUNITIES)}
- {getBucket(BUCKETS.PAST)}
+ {/* {getBucket(BUCKETS.PAST)} */}
{/* NOTE: We do not show upcoming challenges for now, for various reasons,
* more political than technical ;)
getBucket(BUCKETS.UPCOMING) */
}
- {
+ {/* {
savedFilters.length
? (
@@ -108,7 +113,7 @@ export default function BucketSelector({
{savedFiltersRender}
) : ''
- }
+ } */}
{/* DISABLED: Until feeds.topcoder.com domain fixed community-app#4606 */}
{/*
@@ -123,25 +128,27 @@ export default function BucketSelector({
}
BucketSelector.defaultProps = {
- communityFilter: null,
+ // communityFilter: null,
disabled: false,
- extraBucket: null,
+ // extraBucket: null,
isAuth: false,
+ expanding: false,
};
BucketSelector.propTypes = {
activeBucket: PT.string.isRequired,
- activeSavedFilter: PT.number.isRequired,
- buckets: PT.shape().isRequired,
- challenges: PT.arrayOf(PT.shape({
- })).isRequired,
- communityFilter: PT.shape(),
+ expanding: PT.bool,
+ // activeSavedFilter: PT.number.isRequired,
+ // buckets: PT.shape().isRequired,
+ // challenges: PT.arrayOf(PT.shape({
+ // })).isRequired,
+ // communityFilter: PT.shape(),
disabled: PT.bool,
- extraBucket: PT.string,
- filterState: PT.shape().isRequired,
+ // extraBucket: PT.string,
+ // filterState: PT.shape().isRequired,
isAuth: PT.bool,
- savedFilters: PT.arrayOf(PT.shape()).isRequired,
+ // savedFilters: PT.arrayOf(PT.shape()).isRequired,
selectBucket: PT.func.isRequired,
- selectSavedFilter: PT.func.isRequired,
- setEditSavedFiltersMode: PT.func.isRequired,
+ // selectSavedFilter: PT.func.isRequired,
+ // setEditSavedFiltersMode: PT.func.isRequired,
};
diff --git a/src/shared/components/challenge-listing/Sidebar/index.jsx b/src/shared/components/challenge-listing/Sidebar/index.jsx
index a96ed88860..903d90cde0 100644
--- a/src/shared/components/challenge-listing/Sidebar/index.jsx
+++ b/src/shared/components/challenge-listing/Sidebar/index.jsx
@@ -19,39 +19,40 @@ import React from 'react';
import PT from 'prop-types';
import BucketSelector from './BucketSelector';
-import FiltersEditor from './FiltersEditor';
+// import FiltersEditor from './FiltersEditor';
import Footer from './Footer';
import './style.scss';
export default function SideBarFilters({
activeBucket,
- activeSavedFilter,
- buckets,
- challenges,
- changeFilterName,
- communityFilter,
- deleteSavedFilter,
+ // activeSavedFilter,
+ // buckets,
+ // challenges,
+ // changeFilterName,
+ // communityFilter,
+ // deleteSavedFilter,
disabled,
- dragSavedFilterMove,
- dragSavedFilterStart,
- dragState,
- editSavedFiltersMode,
- extraBucket,
- filterState,
+ expanding,
+ // dragSavedFilterMove,
+ // dragSavedFilterStart,
+ // dragState,
+ // editSavedFiltersMode,
+ // extraBucket,
+ // filterState,
hideTcLinksInFooter,
isAuth,
- resetFilterName,
- savedFilters,
+ // resetFilterName,
+ // savedFilters,
selectBucket,
- selectSavedFilter,
- setEditSavedFiltersMode,
- updateAllSavedFilters,
- updateSavedFilter,
+ // selectSavedFilter,
+ // setEditSavedFiltersMode,
+ // updateAllSavedFilters,
+ // updateSavedFilter,
}) {
return (
- { editSavedFiltersMode ? (
+ {/* { editSavedFiltersMode ? (
- ) : (
-
- )}
+ ) : ( */}
+
+ {/* )} */}
@@ -88,37 +90,39 @@ export default function SideBarFilters({
}
SideBarFilters.defaultProps = {
- communityFilter: null,
+ // communityFilter: null,
disabled: false,
- dragState: {},
- extraBucket: null,
+ // dragState: {},
+ // extraBucket: null,
hideTcLinksInFooter: false,
isAuth: false,
+ expanding: false,
};
SideBarFilters.propTypes = {
activeBucket: PT.string.isRequired,
- activeSavedFilter: PT.number.isRequired,
- buckets: PT.shape().isRequired,
- challenges: PT.arrayOf(PT.shape({
- })).isRequired,
- changeFilterName: PT.func.isRequired,
- communityFilter: PT.shape(),
- deleteSavedFilter: PT.func.isRequired,
+ expanding: PT.bool,
+ // activeSavedFilter: PT.number.isRequired,
+ // buckets: PT.shape().isRequired,
+ // challenges: PT.arrayOf(PT.shape({
+ // })).isRequired,
+ // changeFilterName: PT.func.isRequired,
+ // communityFilter: PT.shape(),
+ // deleteSavedFilter: PT.func.isRequired,
disabled: PT.bool,
- dragState: PT.shape(),
- dragSavedFilterMove: PT.func.isRequired,
- dragSavedFilterStart: PT.func.isRequired,
- editSavedFiltersMode: PT.bool.isRequired,
- extraBucket: PT.string,
- filterState: PT.shape().isRequired,
+ // dragState: PT.shape(),
+ // dragSavedFilterMove: PT.func.isRequired,
+ // dragSavedFilterStart: PT.func.isRequired,
+ // editSavedFiltersMode: PT.bool.isRequired,
+ // extraBucket: PT.string,
+ // filterState: PT.shape().isRequired,
hideTcLinksInFooter: PT.bool,
isAuth: PT.bool,
- resetFilterName: PT.func.isRequired,
- savedFilters: PT.arrayOf(PT.shape()).isRequired,
+ // resetFilterName: PT.func.isRequired,
+ // savedFilters: PT.arrayOf(PT.shape()).isRequired,
selectBucket: PT.func.isRequired,
- selectSavedFilter: PT.func.isRequired,
- setEditSavedFiltersMode: PT.func.isRequired,
- updateAllSavedFilters: PT.func.isRequired,
- updateSavedFilter: PT.func.isRequired,
+ // selectSavedFilter: PT.func.isRequired,
+ // setEditSavedFiltersMode: PT.func.isRequired,
+ // updateAllSavedFilters: PT.func.isRequired,
+ // updateSavedFilter: PT.func.isRequired,
};
diff --git a/src/shared/components/challenge-listing/index.jsx b/src/shared/components/challenge-listing/index.jsx
index 4c381ab420..a2a3e9db12 100644
--- a/src/shared/components/challenge-listing/index.jsx
+++ b/src/shared/components/challenge-listing/index.jsx
@@ -1,56 +1,63 @@
+/* eslint-disable react/destructuring-assignment */
/**
* Challenge listing component.
*/
-import _ from 'lodash';
+// import _ from 'lodash';
import ChallengeFilters from 'containers/challenge-listing/FilterPanel';
-import moment from 'moment';
+// import moment from 'moment';
import React from 'react';
import PT from 'prop-types';
import Sticky from 'react-stickynode';
-import { challenge as challengeUtils } from 'topcoder-react-lib';
+// import { challenge as challengeUtils } from 'topcoder-react-lib';
import Sidebar from 'containers/challenge-listing/Sidebar';
-import { isReviewOpportunitiesBucket } from 'utils/challenge-listing/buckets';
-import { config } from 'topcoder-react-utils';
+// import { isReviewOpportunitiesBucket } from 'utils/challenge-listing/buckets';
+// import { config } from 'topcoder-react-utils';
import Listing from './Listing';
-import ChallengeCardPlaceholder from './placeholders/ChallengeCard';
+// import ChallengeCardPlaceholder from './placeholders/ChallengeCard';
import './style.scss';
-const Filter = challengeUtils.filter;
+// const Filter = challengeUtils.filter;
// Number of challenge placeholder card to display
-const CHALLENGE_PLACEHOLDER_COUNT = 8;
+// const CHALLENGE_PLACEHOLDER_COUNT = 8;
export default function ChallengeListing(props) {
const {
activeBucket,
auth,
- challenges: propChallenges,
- communityFilter,
+ challenges,
+ openForRegistrationChallenges,
+ myChallenges,
+ allChallenges,
+ // pastChallenges,
+ // communityFilter,
communityName,
defaultCommunityId,
- extraBucket,
- filterState,
+ expanding,
+ // extraBucket,
+ // filterState,
hideSrm,
hideTcLinksInFooter,
keepPastPlaceholders,
- loadingChallenges,
+ // loadingChallenges,
preListingMsg,
- isBucketSwitching,
+ // isBucketSwitching,
isLoggedIn,
+ meta,
} = props;
- let { challenges } = props;
+ // const { challenges } = props;
- if (communityFilter) {
- challenges = challenges.filter(Filter.getFilterFunction(props.communityFilter));
- }
+ // if (communityFilter) {
+ // challenges = challenges.filter(Filter.getFilterFunction(props.communityFilter));
+ // }
- challenges = challenges.filter(Filter.getFilterFunction(filterState));
+ // challenges = challenges.filter(Filter.getFilterFunction(filterState));
- const expanded = false;
+ // const expanded = false;
/* When we automatically reload cached challenge objects, we do not want to
* show the loading state, if the currently loaded challenges are not very
@@ -64,73 +71,89 @@ export default function ChallengeListing(props) {
* 1.5 - a reasonable margin factor, to decide when we consider already cached
* challenges too old to display while the reload takes place.
*/
- let suppressPlaceholders = false;
- if (config.CHALLENGE_LISTING_AUTO_REFRESH) {
- const outage = moment().diff(props.lastUpdateOfActiveChallenges);
- suppressPlaceholders = outage < 1.5 * 1000 * config.CHALLENGE_LISTING_AUTO_REFRESH;
- }
-
- let challengeCardContainer;
- if ((!expanded
- && loadingChallenges
- && !suppressPlaceholders
- && !isReviewOpportunitiesBucket(activeBucket))
- || isBucketSwitching) { // Skip, Review Opps are not auto-refreshed
- const challengeCards = _.range(CHALLENGE_PLACEHOLDER_COUNT)
- .map(key => );
- challengeCardContainer = (
-
-
- { challengeCards }
-
-
- );
- } else {
- challengeCardContainer = (
-
- );
- }
+ // let suppressPlaceholders = false;
+ // if (config.CHALLENGE_LISTING_AUTO_REFRESH) {
+ // const outage = moment().diff(props.lastUpdateOfActiveChallenges);
+ // suppressPlaceholders = outage < 1.5 * 1000 * config.CHALLENGE_LISTING_AUTO_REFRESH;
+ // }
+
+ // let challengeCardContainer;
+ // if ((!expanded
+ // && loadingChallenges
+ // && !suppressPlaceholders
+ // && !isReviewOpportunitiesBucket(activeBucket))
+ // || isBucketSwitching) { // Skip, Review Opps are not auto-refreshed
+ // if (!expanded && loadingChallenges) {
+ // const challengeCards = _.range(CHALLENGE_PLACEHOLDER_COUNT)
+ // .map(key => );
+ // challengeCardContainer = (
+ //
+ //
+ // { challengeCards }
+ //
+ //
+ // );
+ // } else {
+ const challengeCardContainer = (
+
+ );
+ // }
return (
this.setCardType(cardType) */}
- isCardTypeSet="Challenges"
+ // setCardType={_.noop}
+ // isCardTypeSet="Challenges"
isAuth={Boolean(auth.user)}
+ setFilterState={props.setFilterState}
/>
@@ -143,7 +166,8 @@ export default function ChallengeListing(props) {
@@ -155,11 +179,15 @@ export default function ChallengeListing(props) {
ChallengeListing.defaultProps = {
auth: null,
- communityFilter: null,
+ // communityFilter: null,
communityName: null,
- extraBucket: null,
+ // extraBucket: null,
hideTcLinksInFooter: false,
- loadMorePast: null,
+ loadMoreMy: null,
+ loadMoreAll: null,
+ loadMoreOpenForRegistration: null,
+ loadMoreOnGoing: null,
+ // loadMorePast: null,
loadMoreReviewOpportunities: null,
newChallengeDetails: false,
openChallengesInNewTabs: false,
@@ -169,29 +197,43 @@ ChallengeListing.defaultProps = {
expandedTags: [],
expandTag: null,
loadMoreActive: null,
- isBucketSwitching: false,
- userChallenges: [],
+ expanding: false,
+ // isBucketSwitching: false,
+ // userChallenges: [],
};
ChallengeListing.propTypes = {
activeBucket: PT.string.isRequired,
+ expanding: PT.bool,
challenges: PT.arrayOf(PT.shape()).isRequired,
+ openForRegistrationChallenges: PT.arrayOf(PT.shape()).isRequired,
+ myChallenges: PT.arrayOf(PT.arrayOf()).isRequired,
+ allChallenges: PT.arrayOf(PT.arrayOf()).isRequired,
+ // pastChallenges: PT.arrayOf(PT.arrayOf()).isRequired,
challengesUrl: PT.string.isRequired,
- communityFilter: PT.shape(),
+ // communityFilter: PT.shape(),
communityName: PT.string,
defaultCommunityId: PT.string.isRequired,
expandedTags: PT.arrayOf(PT.number),
expandTag: PT.func,
- extraBucket: PT.string,
+ // extraBucket: PT.string,
filterState: PT.shape().isRequired,
hideSrm: PT.bool.isRequired,
hideTcLinksInFooter: PT.bool,
keepPastPlaceholders: PT.bool.isRequired,
- lastUpdateOfActiveChallenges: PT.number.isRequired,
- loadingChallenges: PT.bool.isRequired,
- loadingPastChallenges: PT.bool.isRequired,
+ // lastUpdateOfActiveChallenges: PT.number.isRequired,
+ // loadingChallenges: PT.bool.isRequired,
+ loadingMyChallenges: PT.bool.isRequired,
+ loadingAllChallenges: PT.bool.isRequired,
+ loadingOpenForRegistrationChallenges: PT.bool.isRequired,
+ loadingOnGoingChallenges: PT.bool.isRequired,
+ // loadingPastChallenges: PT.bool.isRequired,
loadingReviewOpportunities: PT.bool.isRequired,
- loadMorePast: PT.func,
+ loadMoreMy: PT.func,
+ loadMoreAll: PT.func,
+ loadMoreOpenForRegistration: PT.func,
+ loadMoreOnGoing: PT.func,
+ // loadMorePast: PT.func,
loadMoreReviewOpportunities: PT.func,
newChallengeDetails: PT.bool,
openChallengesInNewTabs: PT.bool,
@@ -206,7 +248,8 @@ ChallengeListing.propTypes = {
sorts: PT.shape().isRequired,
auth: PT.shape(),
loadMoreActive: PT.func,
- isBucketSwitching: PT.bool,
- userChallenges: PT.arrayOf(PT.string),
+ // isBucketSwitching: PT.bool,
+ // userChallenges: PT.arrayOf(PT.string),
isLoggedIn: PT.bool.isRequired,
+ meta: PT.shape().isRequired,
};
diff --git a/src/shared/components/tc-communities/ChallengesBlock/Card/index.jsx b/src/shared/components/tc-communities/ChallengesBlock/Card/index.jsx
index 5c3e4e4b65..d79b811a07 100644
--- a/src/shared/components/tc-communities/ChallengesBlock/Card/index.jsx
+++ b/src/shared/components/tc-communities/ChallengesBlock/Card/index.jsx
@@ -31,13 +31,13 @@ export default function Card({
let TrackTag;
switch (track.toLowerCase()) {
case 'datasci':
- case COMPETITION_TRACKS.DATA_SCIENCE:
+ case COMPETITION_TRACKS.DS:
TrackTag = DataScienceTrackTag;
break;
- case COMPETITION_TRACKS.DESIGN:
+ case COMPETITION_TRACKS.DES:
TrackTag = DesignTrackTag;
break;
- case COMPETITION_TRACKS.DEVELOP:
+ case COMPETITION_TRACKS.DEV:
TrackTag = DevelopmentTrackTag;
break;
case COMPETITION_TRACKS.QA:
diff --git a/src/shared/containers/challenge-detail/index.jsx b/src/shared/containers/challenge-detail/index.jsx
index fb27c202ca..5e18d5256c 100644
--- a/src/shared/containers/challenge-detail/index.jsx
+++ b/src/shared/containers/challenge-detail/index.jsx
@@ -21,7 +21,8 @@ import MySubmissions from 'components/challenge-detail/MySubmissions';
import Winners from 'components/challenge-detail/Winners';
import ChallengeDetailsView from 'components/challenge-detail/Specification';
import RecommendedThriveArticles from 'components/challenge-detail/ThriveArticles';
-import RecommendedActiveChallenges from 'components/challenge-detail/RecommendedActiveChallenges';
+// eslint-disable-next-line max-len
+// import RecommendedActiveChallenges from 'components/challenge-detail/RecommendedActiveChallenges';
import Terms from 'containers/Terms';
import termsActions from 'actions/terms';
import ChallengeCheckpoints from 'components/challenge-detail/Checkpoints';
@@ -41,10 +42,10 @@ import {
import { config, MetaTags } from 'topcoder-react-utils';
import { actions } from 'topcoder-react-lib';
import { getService } from 'services/contentful';
-import {
- getDisplayRecommendedChallenges,
- getRecommendedTags,
-} from 'utils/challenge-detail/helper';
+// import {
+// getDisplayRecommendedChallenges,
+// getRecommendedTags,
+// } from 'utils/challenge-detail/helper';
import ogWireframe from
'../../../assets/images/open-graph/challenges/01-wireframe.jpg';
@@ -205,11 +206,11 @@ class ChallengeDetailPageContainer extends React.Component {
const {
challengeId,
reloadChallengeDetails,
- getAllRecommendedChallenges,
- recommendedChallenges,
- auth,
+ // getAllRecommendedChallenges,
+ // recommendedChallenges,
+ // auth,
challenge,
- loadingRecommendedChallengesUUID,
+ // loadingRecommendedChallengesUUID,
history,
} = this.props;
@@ -218,21 +219,21 @@ class ChallengeDetailPageContainer extends React.Component {
history.push(history.location.pathname, history.state);
}
- const recommendedTechnology = getRecommendedTags(challenge);
- if (
- challenge
- && challenge.id === challengeId
- && !loadingRecommendedChallengesUUID
- && (
- !recommendedChallenges[recommendedTechnology]
- || (
- Date.now() - recommendedChallenges[recommendedTechnology].lastUpdateOfActiveChallenges
- > 10 * MIN
- )
- )
- ) {
- getAllRecommendedChallenges(auth.tokenV3, recommendedTechnology);
- }
+ // const recommendedTechnology = getRecommendedTags(challenge);
+ // if (
+ // challenge
+ // && challenge.id === challengeId
+ // && !loadingRecommendedChallengesUUID
+ // && (
+ // !recommendedChallenges[recommendedTechnology]
+ // || (
+ // Date.now() - recommendedChallenges[recommendedTechnology].lastUpdateOfActiveChallenges
+ // > 10 * MIN
+ // )
+ // )
+ // ) {
+ // getAllRecommendedChallenges(auth.tokenV3, recommendedTechnology);
+ // }
const { thriveArticles } = this.state;
const userId = _.get(this, 'props.auth.user.userId');
@@ -244,7 +245,7 @@ class ChallengeDetailPageContainer extends React.Component {
}
const { track } = nextProps.challenge;
- if (track !== COMPETITION_TRACKS.DESIGN && thriveArticles.length === 0) {
+ if (track !== COMPETITION_TRACKS.DES && thriveArticles.length === 0) {
// filter all tags with value 'Other'
const tags = _.filter(nextProps.challenge.tags, tag => tag !== 'Other');
if (tags.length > 0) {
@@ -255,9 +256,9 @@ class ChallengeDetailPageContainer extends React.Component {
}).then((content) => {
// format image file data
_.forEach(content.Article.items, (item) => {
- const asset = _.find(content.Article.includes.Asset,
- a => a.sys.id === item.fields.featuredImage.sys.id);
- _.assign(item.fields.featuredImage, { file: asset.fields.file });
+ // eslint-disable-next-line max-len
+ const asset = _.find(content.Article.includes.Asset, a => item.fields.featuredImage !== null && a.sys.id === item.fields.featuredImage.sys.id);
+ if (asset) _.assign(item.fields.featuredImage, { file: asset.fields.file });
});
this.setState({
thriveArticles: content.Article.items,
@@ -330,20 +331,20 @@ class ChallengeDetailPageContainer extends React.Component {
isLoadingSubmissionInformation,
submissionInformation,
loadSubmissionInformation,
- selectChallengeDetailsTab,
- prizeMode,
- recommendedChallenges,
- expandedTags,
- expandTag,
+ // selectChallengeDetailsTab,
+ // prizeMode,
+ // recommendedChallenges,
+ // expandedTags,
+ // expandTag,
mySubmissions,
reviewTypes,
} = this.props;
- const displayRecommendedChallenges = getDisplayRecommendedChallenges(
- challenge,
- recommendedChallenges,
- auth,
- );
+ // const displayRecommendedChallenges = getDisplayRecommendedChallenges(
+ // challenge,
+ // recommendedChallenges,
+ // auth,
+ // );
const {
thriveArticles,
@@ -455,7 +456,7 @@ class ChallengeDetailPageContainer extends React.Component {
registerForChallenge={this.registerForChallenge}
registering={registering}
selectedView={selectedTab}
- hasRecommendedChallenges={displayRecommendedChallenges.length > 0}
+ // hasRecommendedChallenges={displayRecommendedChallenges.length > 0}
hasThriveArticles={thriveArticles.length > 0}
setChallengeListingFilter={setChallengeListingFilter}
unregisterFromChallenge={() => unregisterFromChallenge(auth, challengeId)
@@ -594,7 +595,7 @@ class ChallengeDetailPageContainer extends React.Component {
}}
/>
)}
- {
+ {/* {
!isEmpty && displayRecommendedChallenges.length ? (
) : null
- }
+ } */}
{
!isEmpty && thriveArticles.length ? (
@@ -639,7 +640,7 @@ ChallengeDetailPageContainer.defaultProps = {
mySubmissions: [],
isLoadingSubmissionInformation: false,
submissionInformation: null,
- prizeMode: 'money-usd',
+ // prizeMode: 'money-usd',
};
ChallengeDetailPageContainer.propTypes = {
@@ -652,7 +653,7 @@ ChallengeDetailPageContainer.propTypes = {
checkpointResults: PT.arrayOf(PT.shape()),
checkpointResultsUi: PT.shape().isRequired,
checkpoints: PT.shape(),
- recommendedChallenges: PT.shape().isRequired,
+ // recommendedChallenges: PT.shape().isRequired,
communityId: PT.string,
communitiesList: PT.shape({
data: PT.arrayOf(PT.object).isRequired,
@@ -696,12 +697,12 @@ ChallengeDetailPageContainer.propTypes = {
isLoadingSubmissionInformation: PT.bool,
submissionInformation: PT.shape(),
loadSubmissionInformation: PT.func.isRequired,
- selectChallengeDetailsTab: PT.func.isRequired,
- getAllRecommendedChallenges: PT.func.isRequired,
- prizeMode: PT.string,
- expandedTags: PT.arrayOf(PT.number).isRequired,
- expandTag: PT.func.isRequired,
- loadingRecommendedChallengesUUID: PT.string.isRequired,
+ // selectChallengeDetailsTab: PT.func.isRequired,
+ // getAllRecommendedChallenges: PT.func.isRequired,
+ // prizeMode: PT.string,
+ // expandedTags: PT.arrayOf(PT.number).isRequired,
+ // expandTag: PT.func.isRequired,
+ // loadingRecommendedChallengesUUID: PT.string.isRequired,
history: PT.shape().isRequired,
};
@@ -765,8 +766,8 @@ function mapStateToProps(state, props) {
auth: state.auth,
challenge,
challengeTypes: cl.challengeTypes,
- recommendedChallenges: cl.recommendedChallenges,
- loadingRecommendedChallengesUUID: cl.loadingRecommendedChallengesUUID,
+ // recommendedChallenges: cl.recommendedChallenges,
+ // loadingRecommendedChallengesUUID: cl.loadingRecommendedChallengesUUID,
expandedTags: cl.expandedTags,
challengeId: String(props.match.params.challengeId),
challengesUrl: props.challengesUrl,
@@ -811,16 +812,16 @@ const mapDispatchToProps = (dispatch) => {
const ca = communityActions.tcCommunity;
const lookupActions = actions.lookup;
return {
- getAllRecommendedChallenges: (tokenV3, recommendedTechnology) => {
- const uuid = shortId();
- const cl = challengeListingActions.challengeListing;
- dispatch(cl.getAllRecommendedChallengesInit(uuid));
- dispatch(
- cl.getAllRecommendedChallengesDone(
- uuid, tokenV3, recommendedTechnology,
- ),
- );
- },
+ // getAllRecommendedChallenges: (tokenV3, recommendedTechnology) => {
+ // const uuid = shortId();
+ // const cl = challengeListingActions.challengeListing;
+ // dispatch(cl.getAllRecommendedChallengesInit(uuid));
+ // dispatch(
+ // cl.getAllRecommendedChallengesDone(
+ // uuid, tokenV3, recommendedTechnology,
+ // ),
+ // );
+ // },
getCommunitiesList: (auth) => {
const uuid = shortId();
dispatch(ca.getListInit(uuid));
@@ -840,7 +841,7 @@ const mapDispatchToProps = (dispatch) => {
dispatch(a.getDetailsDone(challengeId, tokens.tokenV3, tokens.tokenV2))
.then((res) => {
const ch = res.payload;
- if (ch.track === COMPETITION_TRACKS.DESIGN) {
+ if (ch.track === COMPETITION_TRACKS.DES) {
const p = ch.phases || []
.filter(x => x.name === 'Checkpoint Review');
if (p.length && !p[0].isOpen) {
@@ -864,7 +865,7 @@ const mapDispatchToProps = (dispatch) => {
const a = actions.challenge;
dispatch(a.getDetailsDone(challengeId, tokens.tokenV3, tokens.tokenV2))
.then((challengeDetails) => {
- if (challengeDetails.track === COMPETITION_TRACKS.DESIGN) {
+ if (challengeDetails.track === COMPETITION_TRACKS.DES) {
const p = challengeDetails.phases || []
.filter(x => x.name === 'Checkpoint Review');
if (p.length && !p[0].isOpen) {
diff --git a/src/shared/containers/challenge-listing/FilterPanel.jsx b/src/shared/containers/challenge-listing/FilterPanel.jsx
index df1a09565d..c83d7d1277 100644
--- a/src/shared/containers/challenge-listing/FilterPanel.jsx
+++ b/src/shared/containers/challenge-listing/FilterPanel.jsx
@@ -10,16 +10,19 @@ import shortId from 'shortid';
import FilterPanel from 'components/challenge-listing/Filters/ChallengeFilters';
import PT from 'prop-types';
import React from 'react';
-import sidebarActions from 'actions/challenge-listing/sidebar';
-import { BUCKETS, isReviewOpportunitiesBucket } from 'utils/challenge-listing/buckets';
+// import localStorage from 'localStorage';
+// import sidebarActions from 'actions/challenge-listing/sidebar';
+// import { BUCKETS, isReviewOpportunitiesBucket } from 'utils/challenge-listing/buckets';
+import { isReviewOpportunitiesBucket } from 'utils/challenge-listing/buckets';
import { bindActionCreators } from 'redux';
import { connect } from 'react-redux';
import qs from 'qs';
+import _ from 'lodash';
/* The default name for user-saved challenge filters. An integer
* number will be appended to it, when necessary, to keep filter
* names unique. */
-const DEFAULT_SAVED_FILTER_NAME = 'My Filter';
+// const DEFAULT_SAVED_FILTER_NAME = 'My Filter';
const MIN = 60 * 1000;
/**
@@ -27,16 +30,16 @@ const MIN = 60 * 1000;
* @param {Object} state Redux state.
* @return {String}
*/
-function getAvailableFilterName(savedFilters) {
- let res = DEFAULT_SAVED_FILTER_NAME;
- let id = 0;
- savedFilters.forEach((f) => {
- while (res === f.name) {
- res = `${DEFAULT_SAVED_FILTER_NAME} ${id += 1}`;
- }
- });
- return res;
-}
+// function getAvailableFilterName(savedFilters) {
+// let res = DEFAULT_SAVED_FILTER_NAME;
+// let id = 0;
+// savedFilters.forEach((f) => {
+// while (res === f.name) {
+// res = `${DEFAULT_SAVED_FILTER_NAME} ${id += 1}`;
+// }
+// });
+// return res;
+// }
export class Container extends React.Component {
componentDidMount() {
@@ -61,23 +64,29 @@ export class Container extends React.Component {
const query = qs.parse(window.location.search.slice(1));
- if (query.filter && !filterState.track) {
- setFilterState(query.filter);
+ if (!_.isEmpty(query) && !filterState.track) {
+ setFilterState(query);
}
+ // const trackStatus = localStorage.getItem('trackStatus');
+ // const filterObj = trackStatus ? JSON.parse(trackStatus) : null;
+ // if (filterObj) {
+ // setFilterState(filterObj);
+ // }
+ // }
}
render() {
const {
activeBucket,
communityFilters,
- filterState,
- isSavingFilter,
- saveFilter,
- savedFilters,
- selectBucket,
- selectedCommunityId,
+ // filterState,
+ // isSavingFilter,
+ // saveFilter,
+ // savedFilters,
+ // selectBucket,
+ // selectedCommunityId,
setFilterState,
- tokenV2,
+ // tokenV2,
} = this.props;
const communityFilters2 = [
{
@@ -94,36 +103,37 @@ export class Container extends React.Component {
{
- const name = getAvailableFilterName(savedFilters);
- const filter = {
- ...filterState,
- communityId: selectedCommunityId,
- };
+ // saveFilter={() => {
+ // const name = getAvailableFilterName(savedFilters);
+ // const filter = {
+ // ...filterState,
+ // communityId: selectedCommunityId,
+ // };
- if (isForReviewOpportunities) filter.isForReviewOpportunities = true;
+ // if (isForReviewOpportunities) filter.isForReviewOpportunities = true;
- saveFilter(name, filter, tokenV2);
- }}
+ // saveFilter(name, filter, tokenV2);
+ // }}
setFilterState={(state) => {
setFilterState(state);
- if (activeBucket === BUCKETS.SAVED_FILTER) {
- selectBucket(BUCKETS.ALL);
- } else if (activeBucket === BUCKETS.SAVED_REVIEW_OPPORTUNITIES_FILTER) {
- selectBucket(BUCKETS.REVIEW_OPPORTUNITIES);
- }
+ // if (activeBucket === BUCKETS.SAVED_FILTER) {
+ // selectBucket(BUCKETS.ALL);
+ // } else if (activeBucket === BUCKETS.SAVED_REVIEW_OPPORTUNITIES_FILTER) {
+ // selectBucket(BUCKETS.REVIEW_OPPORTUNITIES);
+ // }
}}
- isSavingFilter={isSavingFilter}
+ // isSavingFilter={isSavingFilter}
isReviewOpportunitiesBucket={isForReviewOpportunities}
+ activeBucket={activeBucket}
/>
);
}
}
Container.defaultProps = {
- isSavingFilter: false,
+ // isSavingFilter: false,
tokenV2: '',
- challenges: [],
+ // challenges: [],
};
Container.propTypes = {
@@ -140,16 +150,16 @@ Container.propTypes = {
timestamp: PT.number.isRequired,
}).isRequired,
filterState: PT.shape().isRequired,
- challenges: PT.arrayOf(PT.shape()),
+ // challenges: PT.arrayOf(PT.shape()),
selectedCommunityId: PT.string.isRequired,
getKeywords: PT.func.isRequired,
getTypes: PT.func.isRequired,
- isSavingFilter: PT.bool,
- savedFilters: PT.arrayOf(PT.shape()).isRequired,
+ // isSavingFilter: PT.bool,
+ // savedFilters: PT.arrayOf(PT.shape()).isRequired,
loadingKeywords: PT.bool.isRequired,
loadingTypes: PT.bool.isRequired,
- saveFilter: PT.func.isRequired,
- selectBucket: PT.func.isRequired,
+ // saveFilter: PT.func.isRequired,
+ // selectBucket: PT.func.isRequired,
setFilterState: PT.func.isRequired,
auth: PT.shape().isRequired,
tokenV2: PT.string,
@@ -158,7 +168,7 @@ Container.propTypes = {
function mapDispatchToProps(dispatch) {
const a = actions.challengeListing.filterPanel;
const cla = challengeListingActions.challengeListing;
- const sa = sidebarActions.challengeListing.sidebar;
+ // const sa = sidebarActions.challengeListing.sidebar;
return {
...bindActionCreators(a, dispatch),
getTypes: () => {
@@ -174,11 +184,11 @@ function mapDispatchToProps(dispatch) {
dispatch(cla.getChallengeTagsInit());
dispatch(cla.getChallengeTagsDone());
},
- saveFilter: (...rest) => {
- dispatch(sa.saveFilterInit());
- dispatch(sa.saveFilterDone(...rest));
- },
- selectBucket: bucket => dispatch(sa.selectBucket(bucket)),
+ // saveFilter: (...rest) => {
+ // dispatch(sa.saveFilterInit());
+ // dispatch(sa.saveFilterDone(...rest));
+ // },
+ // selectBucket: bucket => dispatch(sa.selectBucket(bucket)),
selectCommunity: id => dispatch(cla.selectCommunity(id)),
setFilterState: s => dispatch(cla.setFilter(s)),
};
@@ -202,8 +212,8 @@ function mapStateToProps(state, ownProps) {
selectedCommunityId: cl.selectedCommunityId,
auth: state.auth,
tokenV2: state.auth.tokenV2,
- isSavingFilter: cl.sidebar.isSavingFilter,
- savedFilters: cl.sidebar.savedFilters,
+ // isSavingFilter: cl.sidebar.isSavingFilter,
+ // savedFilters: cl.sidebar.savedFilters,
};
}
diff --git a/src/shared/containers/challenge-listing/Listing/index.jsx b/src/shared/containers/challenge-listing/Listing/index.jsx
index 5d8a6b09fb..c045ee844d 100644
--- a/src/shared/containers/challenge-listing/Listing/index.jsx
+++ b/src/shared/containers/challenge-listing/Listing/index.jsx
@@ -23,7 +23,8 @@ import ChallengeListing from 'components/challenge-listing';
import Banner from 'components/tc-communities/Banner';
import sidebarActions from 'actions/challenge-listing/sidebar';
import communityActions from 'actions/tc-communities';
-import { BUCKETS } from 'utils/challenge-listing/buckets';
+// import SORT from 'utils/challenge-listing/sort';
+import { BUCKETS, filterChanged, sortChangedBucket } from 'utils/challenge-listing/buckets';
import { MetaTags } from 'topcoder-react-utils';
import { USER_GROUP_MAXAGE } from 'config';
import { updateChallengeType } from 'utils/challenge';
@@ -31,7 +32,8 @@ import { updateChallengeType } from 'utils/challenge';
import ogImage from '../../../../assets/images/og_image.jpg';
import style from './styles.scss';
-const { combine, mapToBackend } = challengeUtils.filter;
+// const { combine, mapToBackend } = challengeUtils.filter;
+const { mapToBackend } = challengeUtils.filter;
let mounted = false;
@@ -42,6 +44,7 @@ export class ListingContainer extends React.Component {
const {
activeBucket,
auth,
+ // dropChallenges,
communitiesList,
communityId,
getCommunitiesList,
@@ -70,43 +73,120 @@ export class ListingContainer extends React.Component {
logger.error('Attempt to mount multiple instances of ChallengeListingPageContainer at the same time!');
} else mounted = true;
- if (BUCKETS.PAST !== activeBucket) this.loadChallenges();
+ // if (BUCKETS.PAST !== activeBucket) {
+ // dropChallenges();
+ // this.loadChallenges();
+ this.reloadChallenges();
+ // }
}
componentDidUpdate(prevProps) {
const {
- activeBucket,
+ // activeBucket,
auth,
- dropChallenges,
+ // dropChallenges,
getCommunitiesList,
- allActiveChallengesLoaded,
- getRestActiveChallenges,
- meta,
- loadingActiveChallengesUUID,
+ // allActiveChallengesLoaded,
+ // getRestActiveChallenges,
+ // meta,
+ // loadingActiveChallengesUUID,
selectBucketDone,
+ filter,
+ sorts,
+ dropMyChallenges,
+ getMyChallenges,
+ dropAllChallenges,
+ getAllChallenges,
+ getOpenForRegistrationChallenges,
+ getActiveChallenges,
+ dropActiveChallenges,
+ dropOpenForRegistrationChallenges,
+ // dropPastChallenges,
+ // getPastChallenges,
} = this.props;
const oldUserId = _.get(prevProps, 'auth.user.userId');
const userId = _.get(this.props, 'auth.user.userId');
if (userId !== oldUserId) {
getCommunitiesList(auth);
}
-
- const { profile } = auth;
- if (profile) {
- if (!prevProps.auth.profile) setImmediate(() => this.loadChallenges());
- } else if (prevProps.auth.profile) {
- setImmediate(() => {
- dropChallenges();
- this.loadChallenges();
- });
+ // console.log(prevProps);
+ // const { profile } = auth;
+ // if (profile) {
+ // if (!prevProps.auth.profile) setImmediate(() => this.loadChallenges());
+ // } else if (prevProps.auth.profile) {
+ // setImmediate(() => {
+ // this.reloadChallenges();
+ // });
+ // }
+
+ // if (!loadingActiveChallengesUUID && !_.isEmpty(meta) && !allActiveChallengesLoaded
+ // && BUCKETS.PAST !== activeBucket) {
+ // const f = this.getBackendFilter();
+ // getRestActiveChallenges(auth.tokenV3, f.back);
+ // }
+ const bucket = sortChangedBucket(sorts, prevProps.sorts);
+ const f = this.getBackendFilter();
+ if (bucket) {
+ switch (bucket) {
+ case BUCKETS.MY: {
+ dropMyChallenges();
+ getMyChallenges(
+ 0,
+ f.back,
+ auth.tokenV3,
+ f.front,
+ );
+ break;
+ }
+ case BUCKETS.OPEN_FOR_REGISTRATION: {
+ dropOpenForRegistrationChallenges();
+ getOpenForRegistrationChallenges(
+ 0,
+ f.back,
+ auth.tokenV3,
+ f.front,
+ );
+ break;
+ }
+ case BUCKETS.ONGOING: {
+ dropActiveChallenges();
+ getActiveChallenges(
+ 0,
+ f.back,
+ auth.tokenV3,
+ f.front,
+ );
+ break;
+ }
+ case BUCKETS.ALL: {
+ dropAllChallenges();
+ getAllChallenges(
+ 0,
+ f.back,
+ auth.tokenV3,
+ f.front,
+ );
+ break;
+ }
+ // case BUCKETS.PAST: {
+ // dropPastChallenges();
+ // getPastChallenges(
+ // 0,
+ // f.back,
+ // auth.tokenV3,
+ // f.front,
+ // );
+ // break;
+ // }
+ default: {
+ break;
+ }
+ }
+ return;
}
-
- if (!loadingActiveChallengesUUID && !_.isEmpty(meta) && !allActiveChallengesLoaded
- && BUCKETS.PAST !== activeBucket) {
- const f = this.getBackendFilter();
- getRestActiveChallenges(auth.tokenV3, f.back);
+ if (filterChanged(filter, prevProps.filter)) {
+ this.reloadChallenges();
}
-
setTimeout(() => {
selectBucketDone();
}, 10);
@@ -124,54 +204,155 @@ export class ListingContainer extends React.Component {
* of the active frontend filters. */
getBackendFilter() {
const {
- communitiesList,
- selectedCommunityId,
- groupIds,
- communityId,
+ // communitiesList,
+ // selectedCommunityId,
+ // groupIds,
+ // communityId,
+ sorts,
+ filter,
} = this.props;
- let { filter } = this.props;
- let communityFilter = communitiesList.data.find(
- item => item.communityId === selectedCommunityId,
- );
- if (communityFilter) communityFilter = communityFilter.challengeFilter;
- if (communityFilter) filter = combine(filter, communityFilter);
- if (communityId && !_.isEmpty(groupIds)) {
- filter.groupIds = groupIds;
- }
+ const filterTemp = _.clone(filter);
+ // let communityFilter = communitiesList.data.find(
+ // item => item.communityId === selectedCommunityId,
+ // );
+ // if (communityFilter) communityFilter = communityFilter.challengeFilter;
+ // if (communityFilter) filter = combine(filter, communityFilter);
+ // if (communityId && !_.isEmpty(groupIds)) {
+ // filter.groups = groupIds;
+ // }
+ filterTemp.sorts = sorts;
+ // switch (bucket) {
+ // case BUCKETS.MY:
+ // case BUCKETS.OPEN_FOR_REGISTRATION:
+ // case BUCKETS.DROP_ACTIVE_CHALLENGES: {
+ // filter.sortBy = sorts[bucket];
+ // filter.sortOrder = SORT[sorts[bucket]];
+ // break;
+ // }
+ // default: {
+ // break;
+ // }
+ // }
return {
- back: mapToBackend(filter),
- front: filter,
+ back: mapToBackend(filterTemp),
+ front: filterTemp,
};
}
loadChallenges() {
const {
auth,
- getActiveChallenges,
- lastRequestedPageOfActiveChallenges,
- getUserChallenges,
+ // DISABLED: Until api receive fix community-app#5073
+ // getActiveChallenges,
+ getOpenForRegistrationChallenges,
+ getMyChallenges,
+ getAllChallenges,
+ // getPastChallenges,
+ // lastRequestedPageOfActiveChallenges,
+ // lastRequestedPageOfOpenForRegistrationChallenges,
+ // lastRequestedPageOfMyChallenges,
+ // lastRequestedPageOfPastChallenges,
+ // getUserChallenges,
+ getTotalChallengesCount,
} = this.props;
const f = this.getBackendFilter();
+ getAllChallenges(
+ 0,
+ f.back,
+ auth.tokenV3,
+ f.front,
+ );
+ // DISABLED: Until api receive fix community-app#5073
+ /*
getActiveChallenges(
- 1 + lastRequestedPageOfActiveChallenges,
+ 0,
+ f.back,
+ auth.tokenV3,
+ f.front,
+ );
+ */
+ getOpenForRegistrationChallenges(
+ 0,
f.back,
auth.tokenV3,
f.front,
);
- if (auth.tokenV3) {
- const userId = _.get(auth.user, 'userId');
- getUserChallenges(userId, auth.tokenV3);
+
+ // Only retrieve my challenge only when user has login
+ if (auth.user) {
+ getMyChallenges(
+ 0,
+ f.back,
+ auth.tokenV3,
+ f.front,
+ );
}
+ // getPastChallenges(
+ // 0,
+ // f.back,
+ // auth.tokenV3,
+ // f.front,
+ // );
+ getTotalChallengesCount(auth.tokenV3, f.front);
+ }
+
+ reloadChallenges() {
+ const {
+ dropChallenges,
+ } = this.props;
+ dropChallenges();
+ this.loadChallenges();
+ // switch (activeBucket) {
+ // case BUCKETS.MY: {
+ // dropMyChallenges();
+ // getMyChallenges(
+ // 0,
+ // f.back,
+ // auth.tokenV3,
+ // f.front,
+ // );
+ // break;
+ // }
+ // case BUCKETS.OPEN_FOR_REGISTRATION: {
+ // dropOpenForRegistrationChallenges();
+ // getOpenForRegistrationChallenges(
+ // 0,
+ // f.back,
+ // auth.tokenV3,
+ // f.front,
+ // );
+ // break;
+ // }
+ // case BUCKETS.DROP_ACTIVE_CHALLENGES: {
+ // dropActiveChallenges();
+ // getActiveChallenges(
+ // 0,
+ // f.back,
+ // auth.tokenV3,
+ // f.front,
+ // );
+ // break;
+ // }
+ // default: {
+ // dropChallenges();
+ // this.loadChallenges();
+ // break;
+ // }
+ // }
}
render() {
const {
auth,
- allPastChallengesLoaded,
+ // allPastChallengesLoaded,
allReviewOpportunitiesLoaded,
activeBucket,
ChallengeListingBanner,
challenges,
+ openForRegistrationChallenges,
+ myChallenges,
+ allChallenges,
+ // pastChallenges,
challengeTypes,
challengesUrl,
challengeTags,
@@ -179,20 +360,32 @@ export class ListingContainer extends React.Component {
communityId,
communityName,
defaultCommunityId,
+ expanding,
expandTag,
expandedTags,
- extraBucket,
+ // extraBucket,
filter,
groupIds,
- getPastChallenges,
+ getActiveChallenges,
+ getMyChallenges,
+ getAllChallenges,
+ getOpenForRegistrationChallenges,
+ // getPastChallenges,
getReviewOpportunities,
hideSrm,
keepPastPlaceholders,
- lastRequestedPageOfPastChallenges,
+ lastRequestedPageOfMyChallenges,
+ lastRequestedPageOfAllChallenges,
+ lastRequestedPageOfActiveChallenges,
+ lastRequestedPageOfOpenForRegistrationChallenges,
+ // lastRequestedPageOfPastChallenges,
lastRequestedPageOfReviewOpportunities,
- lastUpdateOfActiveChallenges,
+ // lastUpdateOfActiveChallenges,
loadingActiveChallengesUUID,
- loadingPastChallengesUUID,
+ loadingOpenForRegistrationChallengesUUID,
+ loadingMyChallengesUUID,
+ loadingAllChallengesUUID,
+ // loadingPastChallengesUUID,
loadingReviewOpportunitiesUUID,
listingOnly,
newChallengeDetails,
@@ -208,26 +401,77 @@ export class ListingContainer extends React.Component {
setSort,
sorts,
hideTcLinksInSidebarFooter,
- isBucketSwitching,
- userChallenges,
+ // isBucketSwitching,
+ // userChallenges,
+ meta,
} = this.props;
const { tokenV3 } = auth;
const isLoggedIn = !_.isEmpty(auth.tokenV3);
- let loadMorePast;
- if (!allPastChallengesLoaded) {
- loadMorePast = () => {
- const f = this.getBackendFilter();
- getPastChallenges(
- 1 + lastRequestedPageOfPastChallenges,
- f.back,
- tokenV3,
- f.front,
- );
- };
- }
+ // let loadMorePast;
+ // if (!allPastChallengesLoaded) {
+ // loadMorePast = () => {
+ // const f = this.getBackendFilter();
+ // getPastChallenges(
+ // 1 + lastRequestedPageOfPastChallenges,
+ // f.back,
+ // tokenV3,
+ // f.front,
+ // );
+ // };
+ // }
+
+ // const loadMorePast = () => {
+ // const f = this.getBackendFilter();
+ // getPastChallenges(
+ // 1 + lastRequestedPageOfPastChallenges,
+ // f.back,
+ // tokenV3,
+ // f.front,
+ // );
+ // };
+
+ const loadMoreMy = () => {
+ const f = this.getBackendFilter();
+ getMyChallenges(
+ 1 + lastRequestedPageOfMyChallenges,
+ f.back,
+ tokenV3,
+ f.front,
+ );
+ };
+
+ const loadMoreOpenForRegistration = () => {
+ const f = this.getBackendFilter();
+ getOpenForRegistrationChallenges(
+ 1 + lastRequestedPageOfOpenForRegistrationChallenges,
+ f.back,
+ tokenV3,
+ f.front,
+ );
+ };
+
+ const loadMoreOnGoing = () => {
+ const f = this.getBackendFilter();
+ getActiveChallenges(
+ 1 + lastRequestedPageOfActiveChallenges,
+ f.back,
+ tokenV3,
+ f.front,
+ );
+ };
+
+ const loadMoreAll = () => {
+ const f = this.getBackendFilter();
+ getAllChallenges(
+ 1 + lastRequestedPageOfAllChallenges,
+ f.back,
+ tokenV3,
+ f.front,
+ );
+ };
let loadMoreReviewOpportunities;
if (!allReviewOpportunitiesLoaded) {
@@ -271,22 +515,33 @@ export class ListingContainer extends React.Component {
{
setFilter(state);
- setSearchText(state.text || '');
- if (activeBucket === BUCKETS.SAVED_FILTER) {
- selectBucket(BUCKETS.ALL);
- } else if (activeBucket === BUCKETS.SAVED_REVIEW_OPPORTUNITIES_FILTER) {
- selectBucket(BUCKETS.REVIEW_OPPORTUNITIES);
- }
+ setSearchText(state.name || '');
+ // if (activeBucket === BUCKETS.SAVED_FILTER) {
+ // selectBucket(BUCKETS.ALL);
+ // } else if (activeBucket === BUCKETS.SAVED_REVIEW_OPPORTUNITIES_FILTER) {
+ // selectBucket(BUCKETS.REVIEW_OPPORTUNITIES);
+ // }
}}
setSort={setSort}
sorts={sorts}
groupIds={groupIds}
auth={auth}
- isBucketSwitching={isBucketSwitching}
- userChallenges={userChallenges}
+ // isBucketSwitching={isBucketSwitching}
+ // userChallenges={[]}
isLoggedIn={isLoggedIn}
+ meta={meta}
/>
);
@@ -323,8 +583,9 @@ export class ListingContainer extends React.Component {
ListingContainer.defaultProps = {
ChallengeListingBanner: null,
challengeTypes: [],
+ // pastChallenges: [],
defaultCommunityId: '',
- extraBucket: null,
+ // extraBucket: null,
hideSrm: false,
selectedCommunityId: '',
groupIds: [''],
@@ -339,8 +600,9 @@ ListingContainer.defaultProps = {
prizeMode: 'money-usd',
queryBucket: BUCKETS.ALL,
meta: {},
- isBucketSwitching: false,
- userChallenges: [],
+ expanding: false,
+ // isBucketSwitching: false,
+ // userChallenges: [],
};
ListingContainer.propTypes = {
@@ -349,11 +611,15 @@ ListingContainer.propTypes = {
tokenV3: PT.string,
user: PT.shape(),
}).isRequired,
- allActiveChallengesLoaded: PT.bool.isRequired,
- allPastChallengesLoaded: PT.bool.isRequired,
+ // allActiveChallengesLoaded: PT.bool.isRequired,
+ // allPastChallengesLoaded: PT.bool.isRequired,
allReviewOpportunitiesLoaded: PT.bool.isRequired,
ChallengeListingBanner: PT.node,
- challenges: PT.arrayOf(PT.shape({})).isRequired,
+ challenges: PT.arrayOf(PT.shape({})).isRequired, // active challenges.
+ openForRegistrationChallenges: PT.arrayOf(PT.shape({})).isRequired,
+ myChallenges: PT.arrayOf(PT.shape({})).isRequired,
+ allChallenges: PT.arrayOf(PT.shape({})).isRequired,
+ // pastChallenges: PT.arrayOf(PT.shape({})),
challengeTypes: PT.arrayOf(PT.shape()),
challengesUrl: PT.string,
challengeTags: PT.arrayOf(PT.string).isRequired,
@@ -367,25 +633,39 @@ ListingContainer.propTypes = {
}).isRequired,
defaultCommunityId: PT.string,
dropChallenges: PT.func.isRequired,
+ dropMyChallenges: PT.func.isRequired,
+ dropAllChallenges: PT.func.isRequired,
+ dropOpenForRegistrationChallenges: PT.func.isRequired,
+ dropActiveChallenges: PT.func.isRequired,
+ // dropPastChallenges: PT.func.isRequired,
filter: PT.shape().isRequired,
hideSrm: PT.bool,
hideTcLinksInSidebarFooter: PT.bool,
communityId: PT.string,
communityName: PT.string,
communityFilters: PT.arrayOf(PT.object).isRequired,
- extraBucket: PT.string,
+ // extraBucket: PT.string,
getActiveChallenges: PT.func.isRequired,
- getRestActiveChallenges: PT.func.isRequired,
+ getOpenForRegistrationChallenges: PT.func.isRequired,
+ getMyChallenges: PT.func.isRequired,
+ getAllChallenges: PT.func.isRequired,
+ // getRestActiveChallenges: PT.func.isRequired,
getCommunitiesList: PT.func.isRequired,
- getPastChallenges: PT.func.isRequired,
+ // getPastChallenges: PT.func.isRequired,
getReviewOpportunities: PT.func.isRequired,
keepPastPlaceholders: PT.bool.isRequired,
lastRequestedPageOfActiveChallenges: PT.number.isRequired,
- lastRequestedPageOfPastChallenges: PT.number.isRequired,
+ lastRequestedPageOfOpenForRegistrationChallenges: PT.number.isRequired,
+ lastRequestedPageOfMyChallenges: PT.number.isRequired,
+ lastRequestedPageOfAllChallenges: PT.number.isRequired,
+ // lastRequestedPageOfPastChallenges: PT.number.isRequired,
lastRequestedPageOfReviewOpportunities: PT.number.isRequired,
- lastUpdateOfActiveChallenges: PT.number.isRequired,
+ // lastUpdateOfActiveChallenges: PT.number.isRequired,
loadingActiveChallengesUUID: PT.string.isRequired,
- loadingPastChallengesUUID: PT.string.isRequired,
+ loadingOpenForRegistrationChallengesUUID: PT.string.isRequired,
+ loadingMyChallengesUUID: PT.string.isRequired,
+ loadingAllChallengesUUID: PT.string.isRequired,
+ // loadingPastChallengesUUID: PT.string.isRequired,
loadingReviewOpportunitiesUUID: PT.string.isRequired,
markHeaderMenu: PT.func.isRequired,
newChallengeDetails: PT.bool,
@@ -398,6 +678,7 @@ ListingContainer.propTypes = {
selectCommunity: PT.func.isRequired,
setFilter: PT.func.isRequired,
activeBucket: PT.string.isRequired,
+ expanding: PT.bool,
selectedCommunityId: PT.string,
sorts: PT.shape().isRequired,
setSearchText: PT.func.isRequired,
@@ -408,10 +689,11 @@ ListingContainer.propTypes = {
expandTag: PT.func.isRequired,
queryBucket: PT.string,
meta: PT.shape(),
- isBucketSwitching: PT.bool,
+ // isBucketSwitching: PT.bool,
selectBucketDone: PT.func.isRequired,
- userChallenges: PT.arrayOf(PT.string),
- getUserChallenges: PT.func.isRequired,
+ getTotalChallengesCount: PT.func.isRequired,
+ // userChallenges: PT.arrayOf(PT.string),
+ // getUserChallenges: PT.func.isRequired,
};
const mapStateToProps = (state, ownProps) => {
@@ -422,25 +704,36 @@ const mapStateToProps = (state, ownProps) => {
);
return {
auth: state.auth,
- allActiveChallengesLoaded: cl.allActiveChallengesLoaded,
- allPastChallengesLoaded: cl.allPastChallengesLoaded,
+ // allActiveChallengesLoaded: cl.allActiveChallengesLoaded,
+ // allPastChallengesLoaded: cl.allPastChallengesLoaded,
allReviewOpportunitiesLoaded: cl.allReviewOpportunitiesLoaded,
filter: cl.filter,
challenges: cl.challenges,
+ openForRegistrationChallenges: cl.openForRegistrationChallenges,
+ myChallenges: cl.myChallenges,
+ allChallenges: cl.allChallenges,
+ // pastChallenges: cl.pastChallenges,
challengeTypes: cl.challengeTypes,
challengeTags: cl.challengeTags,
communitiesList: tc.list,
communityFilters: tc.list.data,
domain: state.domain,
- extraBucket: ownProps.extraBucket,
+ // extraBucket: ownProps.extraBucket,
hideTcLinksInSidebarFooter: ownProps.hideTcLinksInSidebarFooter,
keepPastPlaceholders: cl.keepPastPlaceholders,
lastRequestedPageOfActiveChallenges: cl.lastRequestedPageOfActiveChallenges,
- lastRequestedPageOfPastChallenges: cl.lastRequestedPageOfPastChallenges,
+ // eslint-disable-next-line max-len
+ lastRequestedPageOfOpenForRegistrationChallenges: cl.lastRequestedPageOfOpenForRegistrationChallenges,
+ lastRequestedPageOfMyChallenges: cl.lastRequestedPageOfMyChallenges,
+ lastRequestedPageOfAllChallenges: cl.lastRequestedPageOfAllChallenges,
+ // lastRequestedPageOfPastChallenges: cl.lastRequestedPageOfPastChallenges,
lastRequestedPageOfReviewOpportunities: cl.lastRequestedPageOfReviewOpportunities,
- lastUpdateOfActiveChallenges: cl.lastUpdateOfActiveChallenges,
+ // lastUpdateOfActiveChallenges: cl.lastUpdateOfActiveChallenges,
loadingActiveChallengesUUID: cl.loadingActiveChallengesUUID,
- loadingPastChallengesUUID: cl.loadingPastChallengesUUID,
+ loadingOpenForRegistrationChallengesUUID: cl.loadingOpenForRegistrationChallengesUUID,
+ loadingMyChallengesUUID: cl.loadingMyChallengesUUID,
+ loadingAllChallengesUUID: cl.loadingAllChallengesUUID,
+ // loadingPastChallengesUUID: cl.loadingPastChallengesUUID,
loadingReviewOpportunitiesUUID: cl.loadingReviewOpportunitiesUUID,
loadingChallengeTypes: cl.loadingChallengeTypes,
loadingChallengeTags: cl.loadingChallengeTags,
@@ -452,10 +745,11 @@ const mapStateToProps = (state, ownProps) => {
selectedCommunityId: cl.selectedCommunityId,
sorts: cl.sorts,
activeBucket: cl.sidebar.activeBucket,
- isBucketSwitching: cl.sidebar.isBucketSwitching,
+ expanding: cl.sidebar.expanding,
+ // isBucketSwitching: cl.sidebar.isBucketSwitching,
expandedTags: cl.expandedTags,
meta: cl.meta,
- userChallenges: cl.userChallenges,
+ // userChallenges: cl.userChallenges,
};
};
@@ -472,27 +766,52 @@ function mapDispatchToProps(dispatch) {
dispatch(a.getActiveChallengesInit(uuid, page, frontFilter));
dispatch(a.getActiveChallengesDone(uuid, page, filter, token, frontFilter));
},
- getRestActiveChallenges: (token, filter) => {
+ dropActiveChallenges: () => dispatch(a.dropActiveChallenges()),
+ getOpenForRegistrationChallenges: (page, filter, token, frontFilter) => {
+ const uuid = shortId();
+ dispatch(a.getOpenForRegistrationChallengesInit(uuid, page, frontFilter));
+ dispatch(a.getOpenForRegistrationChallengesDone(uuid, page, filter, token, frontFilter));
+ },
+ dropOpenForRegistrationChallenges: () => dispatch(a.dropOpenForRegistrationChallenges()),
+ getMyChallenges: (page, filter, token, frontFilter) => {
const uuid = shortId();
- dispatch(a.getRestActiveChallengesInit(uuid));
- dispatch(a.getRestActiveChallengesDone(uuid, token, filter));
+ dispatch(a.getMyChallengesInit(uuid, page, frontFilter));
+ dispatch(a.getMyChallengesDone(uuid, page, filter, token, frontFilter));
},
+ dropMyChallenges: () => dispatch(a.dropMyChallenges()),
+ getAllChallenges: (page, filter, token, frontFilter) => {
+ const uuid = shortId();
+ dispatch(a.getAllChallengesInit(uuid, page, frontFilter));
+ dispatch(a.getAllChallengesDone(uuid, page, filter, token, frontFilter));
+ },
+ dropAllChallenges: () => dispatch(a.dropAllChallenges()),
+ getTotalChallengesCount: (token, frontFilter) => {
+ const uuid = shortId();
+ dispatch(a.getTotalChallengesCountInit(uuid));
+ dispatch(a.getTotalChallengesCountDone(uuid, token, frontFilter));
+ },
+ // getRestActiveChallenges: (token, filter) => {
+ // const uuid = shortId();
+ // dispatch(a.getRestActiveChallengesInit(uuid));
+ // dispatch(a.getRestActiveChallengesDone(uuid, token, filter));
+ // },
getCommunitiesList: (auth) => {
const uuid = shortId();
dispatch(ca.getListInit(uuid));
dispatch(ca.getListDone(uuid, auth));
},
- getPastChallenges: (page, filter, token, frontFilter) => {
- const uuid = shortId();
- dispatch(a.getPastChallengesInit(uuid, page, frontFilter));
- dispatch(a.getPastChallengesDone(uuid, page, filter, token, frontFilter));
- },
+ // dropPastChallenges: () => dispatch(a.dropPastChallenges()),
+ // getPastChallenges: (page, filter, token, frontFilter) => {
+ // const uuid = shortId();
+ // dispatch(a.getPastChallengesInit(uuid, page, frontFilter));
+ // dispatch(a.getPastChallengesDone(uuid, page, filter, token, frontFilter));
+ // },
getReviewOpportunities: (page, token) => {
const uuid = shortId();
dispatch(a.getReviewOpportunitiesInit(uuid, page));
dispatch(a.getReviewOpportunitiesDone(uuid, page, token));
},
- selectBucket: bucket => dispatch(sa.selectBucket(bucket)),
+ selectBucket: (bucket, expanding) => dispatch(sa.selectBucket(bucket, expanding)),
selectBucketDone: () => dispatch(sa.selectBucketDone()),
selectChallengeDetailsTab:
tab => dispatch(challengeDetailsActions.page.challengeDetails.selectTab(tab)),
@@ -502,11 +821,11 @@ function mapDispatchToProps(dispatch) {
setSort: (bucket, sort) => dispatch(a.setSort(bucket, sort)),
markHeaderMenu: () => dispatch(ah.setCurrentNav('Compete', 'All Challenges')),
expandTag: id => dispatch(a.expandTag(id)),
- getUserChallenges: (userId, tokenV3) => {
- const uuid = shortId();
- dispatch(a.getUserChallengesInit(uuid));
- dispatch(a.getUserChallengesDone(userId, tokenV3));
- },
+ // getUserChallenges: (userId, tokenV3) => {
+ // const uuid = shortId();
+ // dispatch(a.getUserChallengesInit(uuid));
+ // dispatch(a.getUserChallengesDone(userId, tokenV3));
+ // },
};
}
diff --git a/src/shared/containers/challenge-listing/Sidebar.jsx b/src/shared/containers/challenge-listing/Sidebar.jsx
index dd89d7795b..034024fbac 100644
--- a/src/shared/containers/challenge-listing/Sidebar.jsx
+++ b/src/shared/containers/challenge-listing/Sidebar.jsx
@@ -2,18 +2,18 @@
* Container for the Sidebar.
*/
-import _ from 'lodash';
+// import _ from 'lodash';
import actions from 'actions/challenge-listing/sidebar';
-import challengeListingActions from 'actions/challenge-listing';
-import { config } from 'topcoder-react-utils';
-import filterPanelActions from 'actions/challenge-listing/filter-panel';
+// import challengeListingActions from 'actions/challenge-listing';
+// import { config } from 'topcoder-react-utils';
+// import filterPanelActions from 'actions/challenge-listing/filter-panel';
import PT from 'prop-types';
import React from 'react';
import Sidebar from 'components/challenge-listing/Sidebar';
import { bindActionCreators } from 'redux';
import { connect } from 'react-redux';
-import { BUCKETS, getBuckets } from 'utils/challenge-listing/buckets';
-import { updateChallengeType } from 'utils/challenge';
+// import { BUCKETS, getBuckets } from 'utils/challenge-listing/buckets';
+// import { updateChallengeType } from 'utils/challenge';
export const SidebarPureComponent = Sidebar;
@@ -23,153 +23,156 @@ export const SidebarPureComponent = Sidebar;
* @param {Array} communityFilters
* @return {Array} cloned savedFilters with errors set if any detected
*/
-function checkFilterErrors(savedFilters, communityFilters) {
- const communityIds = _.keyBy(communityFilters, f => f.communityId);
-
- const savedFiltersClone = _.clone(savedFilters);
- savedFilters.forEach((f, index) => {
- if (f.filter.communityId && !communityIds[f.filter.communityId]) {
- savedFiltersClone[index] = {
- ...f,
- filterError: `Filter uses unknown community '${f.filter.communityId}'`,
- };
- }
- });
- return savedFiltersClone;
-}
+// function checkFilterErrors(savedFilters, communityFilters) {
+// const communityIds = _.keyBy(communityFilters, f => f.communityId);
+
+// const savedFiltersClone = _.clone(savedFilters);
+// savedFilters.forEach((f, index) => {
+// if (f.filter.communityId && !communityIds[f.filter.communityId]) {
+// savedFiltersClone[index] = {
+// ...f,
+// filterError: `Filter uses unknown community '${f.filter.communityId}'`,
+// };
+// }
+// });
+// return savedFiltersClone;
+// }
export class SidebarContainer extends React.Component {
componentDidMount() {
- const { tokenV2, getSavedFilters } = this.props;
- const token = tokenV2;
- if (config.USER_SETTINGS && token) getSavedFilters(token);
+ // const { tokenV2, getSavedFilters } = this.props;
+ // const token = tokenV2;
+ // if (config.USER_SETTINGS && token) getSavedFilters(token);
}
render() {
- const {
- communityFilters,
- deleteSavedFilter,
- extraBucket,
- savedFilters: origSavedFilters,
- selectCommunity,
- selectSavedFilter,
- selectedCommunityId,
- setFilter,
- setSearchText,
- tokenV2,
- updateAllSavedFilters,
- updateSavedFilter,
- userChallenges,
- } = this.props;
-
- const buckets = getBuckets(userChallenges);
-
- if (extraBucket) {
- buckets[extraBucket.name] = extraBucket;
- }
-
- const updatedCommunityFilters = [
- {
- communityId: '',
- communityName: 'All',
- challengeFilter: {},
- },
- ...communityFilters,
- ];
-
- let communityFilter = updatedCommunityFilters.find(
- item => item.communityId === selectedCommunityId,
- );
- if (communityFilter) communityFilter = communityFilter.challengeFilter;
-
- const savedFilters = checkFilterErrors(origSavedFilters, updatedCommunityFilters);
+ // const {
+ // activeBucket,
+ // communityFilters,
+ // deleteSavedFilter,
+ // extraBucket,
+ // savedFilters: origSavedFilters,
+ // selectCommunity,
+ // selectSavedFilter,
+ // selectedCommunityId,
+ // setFilter,
+ // setSearchText,
+ // tokenV2,
+ // updateAllSavedFilters,
+ // updateSavedFilter,
+ // userChallenges,
+ // } = this.props;
+
+ // const buckets = getBuckets(userChallenges);
+
+ // if (extraBucket) {
+ // buckets[extraBucket.name] = extraBucket;
+ // }
+
+ // const updatedCommunityFilters = [
+ // {
+ // communityId: '',
+ // communityName: 'All',
+ // challengeFilter: {},
+ // },
+ // ...communityFilters,
+ // ];
+
+ // let communityFilter = updatedCommunityFilters.find(
+ // item => item.communityId === selectedCommunityId,
+ // );
+ // if (communityFilter) communityFilter = communityFilter.challengeFilter;
+
+ // const savedFilters = checkFilterErrors(origSavedFilters, updatedCommunityFilters);
return (
deleteSavedFilter(id, tokenV2)}
- selectSavedFilter={(index) => {
- const { filter } = origSavedFilters[index];
- selectSavedFilter(index);
- setFilter(_.omit(filter, 'communityId'));
- setSearchText(filter.text || '');
- selectCommunity(filter.communityId || '');
- }}
- updateAllSavedFilters={() => updateAllSavedFilters(
- origSavedFilters,
- tokenV2,
- )
- }
- updateSavedFilter={filter => updateSavedFilter(filter, tokenV2)}
+ // bucket={activeBucket}
+ // extraBucket={extraBucket}
+ // savedFilters={savedFilters}
+ // communityFilter={communityFilter}
+ // deleteSavedFilter={id => deleteSavedFilter(id, tokenV2)}
+ // selectSavedFilter={(index) => {
+ // const { filter } = origSavedFilters[index];
+ // selectSavedFilter(index);
+ // setFilter(_.omit(filter, 'communityId'));
+ // setSearchText(filter.text || '');
+ // selectCommunity(filter.communityId || '');
+ // }}
+ // updateAllSavedFilters={() => updateAllSavedFilters(
+ // origSavedFilters,
+ // tokenV2,
+ // )
+ // }
+ // updateSavedFilter={filter => updateSavedFilter(filter, tokenV2)}
/>
);
}
}
SidebarContainer.defaultProps = {
- extraBucket: null,
- selectedCommunityId: '',
- tokenV2: null,
- user: null,
- userChallenges: [],
+ // extraBucket: null,
+ // selectedCommunityId: '',
+ // tokenV2: null,
+ // user: null,
+ // userChallenges: [],
};
SidebarContainer.propTypes = {
- communityFilters: PT.arrayOf(PT.shape({
- challengeFilter: PT.shape(),
- communityId: PT.string.isRequired,
- })).isRequired,
- deleteSavedFilter: PT.func.isRequired,
- extraBucket: PT.shape(),
- getSavedFilters: PT.func.isRequired,
- savedFilters: PT.arrayOf(PT.shape()).isRequired,
- selectedCommunityId: PT.string,
- selectSavedFilter: PT.func.isRequired,
- setFilter: PT.func.isRequired,
- selectCommunity: PT.func.isRequired,
- setSearchText: PT.func.isRequired,
- tokenV2: PT.string,
- updateAllSavedFilters: PT.func.isRequired,
- updateSavedFilter: PT.func.isRequired,
- user: PT.shape(),
- userChallenges: PT.arrayOf(PT.string),
+ activeBucket: PT.string.isRequired,
+ // communityFilters: PT.arrayOf(PT.shape({
+ // challengeFilter: PT.shape(),
+ // communityId: PT.string.isRequired,
+ // })).isRequired,
+ // deleteSavedFilter: PT.func.isRequired,
+ // extraBucket: PT.shape(),
+ // getSavedFilters: PT.func.isRequired,
+ // savedFilters: PT.arrayOf(PT.shape()).isRequired,
+ // selectedCommunityId: PT.string,
+ // selectSavedFilter: PT.func.isRequired,
+ // setFilter: PT.func.isRequired,
+ // selectCommunity: PT.func.isRequired,
+ // setSearchText: PT.func.isRequired,
+ // tokenV2: PT.string,
+ // updateAllSavedFilters: PT.func.isRequired,
+ // updateSavedFilter: PT.func.isRequired,
+ // user: PT.shape(),
+ // userChallenges: PT.arrayOf(PT.string),
};
function mapDispatchToProps(dispatch) {
const a = actions.challengeListing.sidebar;
- const cla = challengeListingActions.challengeListing;
- const fpa = filterPanelActions.challengeListing.filterPanel;
+ // const cla = challengeListingActions.challengeListing;
+ // const fpa = filterPanelActions.challengeListing.filterPanel;
return {
...bindActionCreators(a, dispatch),
- setFilter: filter => dispatch(cla.setFilter(filter)),
- selectCommunity: communityId => dispatch(cla.selectCommunity(communityId)),
- setSearchText: text => dispatch(fpa.setSearchText(text)),
+ // setFilter: filter => dispatch(cla.setFilter(filter)),
+ // selectCommunity: communityId => dispatch(cla.selectCommunity(communityId)),
+ // setSearchText: text => dispatch(fpa.setSearchText(text)),
};
}
function mapStateToProps(state, ownProps) {
- const { activeBucket } = state.challengeListing.sidebar;
- const pending = _.keys(state.challengeListing.pendingRequests);
- updateChallengeType(
- state.challengeListing.challenges, state.challengeListing.challengeTypesMap,
- );
+ // const { activeBucket } = state.challengeListing.sidebar;
+ // const pending = _.keys(state.challengeListing.pendingRequests);
+ // updateChallengeType(
+ // state.challengeListing.challenges, state.challengeListing.challengeTypesMap,
+ // );
return {
- ...state.challengeListing.sidebar,
- challenges: state.challengeListing.challenges,
- disabled: (activeBucket === BUCKETS.ALL) && Boolean(pending.length),
- extraBucket: ownProps.extraBucket,
+ activeBucket: state.challengeListing.sidebar.activeBucket,
+ // ...state.challengeListing.sidebar,
+ // challenges: state.challengeListing.challenges,
+ // disabled: (activeBucket === BUCKETS.ALL) && Boolean(pending.length),
+ // extraBucket: ownProps.extraBucket,
hideTcLinksInFooter: ownProps.hideTcLinksInFooter,
- filterState: state.challengeListing.filter,
+ // filterState: state.challengeListing.filter,
isAuth: Boolean(state.auth.user),
- communityFilters: state.tcCommunities.list.data,
- selectedCommunityId: state.challengeListing.selectedCommunityId,
- tokenV2: state.auth.tokenV2,
- user: state.auth.user,
- userChallenges: state.challengeListing.userChallenges,
+ // communityFilters: state.tcCommunities.list.data,
+ // selectedCommunityId: state.challengeListing.selectedCommunityId,
+ // tokenV2: state.auth.tokenV2,
+ // user: state.auth.user,
+ // userChallenges: state.challengeListing.userChallenges,
};
}
diff --git a/src/shared/reducers/challenge-listing/index.js b/src/shared/reducers/challenge-listing/index.js
index 6e83a9d969..fc656771f7 100644
--- a/src/shared/reducers/challenge-listing/index.js
+++ b/src/shared/reducers/challenge-listing/index.js
@@ -11,7 +11,7 @@ import moment from 'moment';
import {
logger,
errors,
- challenge as challengeUtils,
+ // challenge as challengeUtils,
actions as actionsUtils,
} from 'topcoder-react-lib';
@@ -19,56 +19,56 @@ import filterPanel from './filter-panel';
import sidebar, { factory as sidebarFactory } from './sidebar';
const { fireErrorMessage } = errors;
-const { filter: Filter } = challengeUtils;
+// const { filter: Filter } = challengeUtils;
/** TODO: Inspect if the 2 actions bellow can be removed?
* They do duplicate what is done in `getActiveChallengesDone` but fetch all challenges
* which was refactored in listing-improve
*/
-function onGetAllActiveChallengesInit(state, { payload }) {
- return { ...state, loadingActiveChallengesUUID: payload };
-}
-function onGetAllActiveChallengesDone(state, { error, payload }) {
- if (error) {
- logger.error(payload);
- return state;
- }
- const { uuid, challenges: loaded } = payload;
- if (uuid !== state.loadingActiveChallengesUUID) return state;
- /* Once all active challenges are fetched from the API, we remove from the
- * store any active challenges stored there previously, and also any
- * challenges with IDs matching any challenges loaded now as active. */
- const ids = new Set();
- loaded.forEach(item => ids.add(item.id));
- const challenges = state.challenges
- .filter(item => item.status !== 'Active' && !ids.has(item.id))
- .concat(loaded);
-
- return {
- ...state,
- challenges,
- lastUpdateOfActiveChallenges: Date.now(),
- loadingActiveChallengesUUID: '',
- };
-}
-
-function onGetAllUserChallengesInit(state, { payload }) {
- return { ...state, loadingActiveChallengesUUID: payload };
-}
-function onGetAllUserChallengesDone(state, { error, payload }) {
- if (error) {
- logger.error(payload);
- return state;
- }
- const { challenges } = payload || [];
-
- return {
- ...state,
- challenges,
- lastUpdateOfActiveChallenges: Date.now(),
- loadingActiveChallengesUUID: '',
- };
-}
+// function onGetAllActiveChallengesInit(state, { payload }) {
+// return { ...state, loadingActiveChallengesUUID: payload };
+// }
+// function onGetAllActiveChallengesDone(state, { error, payload }) {
+// if (error) {
+// logger.error(payload);
+// return state;
+// }
+// const { uuid, challenges: loaded } = payload;
+// if (uuid !== state.loadingActiveChallengesUUID) return state;
+// /* Once all active challenges are fetched from the API, we remove from the
+// * store any active challenges stored there previously, and also any
+// * challenges with IDs matching any challenges loaded now as active. */
+// const ids = new Set();
+// loaded.forEach(item => ids.add(item.id));
+// const challenges = state.challenges
+// .filter(item => item.status !== 'Active' && !ids.has(item.id))
+// .concat(loaded);
+
+// return {
+// ...state,
+// challenges,
+// lastUpdateOfActiveChallenges: Date.now(),
+// loadingActiveChallengesUUID: '',
+// };
+// }
+
+// function onGetAllUserChallengesInit(state, { payload }) {
+// return { ...state, loadingActiveChallengesUUID: payload };
+// }
+// function onGetAllUserChallengesDone(state, { error, payload }) {
+// if (error) {
+// logger.error(payload);
+// return state;
+// }
+// const { challenges } = payload || [];
+
+// return {
+// ...state,
+// challenges,
+// lastUpdateOfActiveChallenges: Date.now(),
+// loadingActiveChallengesUUID: '',
+// };
+// }
/**
* Called when 1st page of ative challenges is loaded from `/challenges` api
@@ -86,25 +86,29 @@ function onGetActiveChallengesDone(state, { error, payload }) {
/* Once all active challenges are fetched from the API, we remove from the
* store any active challenges stored there previously, and also any
* challenges with IDs matching any challenges loaded now as active. */
- const ids = new Set();
- loaded.forEach(item => ids.add(item.id));
+ // const ids = new Set();
+ // loaded.forEach(item => ids.add(item.id));
/* Fetching 0 page of active challenges also drops any active challenges
* loaded to the state before. */
- const filter = state.lastRequestedPageOfActiveChallenges
- ? item => !ids.has(item.id)
- : item => !ids.has(item.id) && item.status !== 'Active';
+ // const filter = state.lastRequestedPageOfActiveChallenges
+ // ? item => !ids.has(item.id)
+ // : item => !ids.has(item.id) && item.status !== 'Active';
const challenges = state.challenges
- .filter(filter)
+ // .filter(filter)
.concat(loaded);
return {
...state,
challenges,
- lastUpdateOfActiveChallenges: Date.now(),
+ // lastUpdateOfActiveChallenges: Date.now(),
loadingActiveChallengesUUID: '',
- meta: payload.meta,
+ allActiveChallengesLoaded: challenges.length >= payload.meta.allChallengesCount,
+ meta: {
+ ...state.meta,
+ ongoingChallengesCount: payload.meta.allChallengesCount,
+ },
};
}
@@ -120,83 +124,108 @@ function onGetActiveChallengesInit(state, { payload }) {
lastRequestedPageOfActiveChallenges: payload.page,
};
}
-function onGetRestActiveChallengesInit(state, { payload }) {
+
+function onGetOpenForRegistrationChallengesInit(state, { payload }) {
return {
...state,
- loadingRestActiveChallengesUUID: payload.uuid,
+ loadingOpenForRegistrationChallengesUUID: payload.uuid,
+ lastRequestedPageOfOpenForRegistrationChallenges: payload.page,
};
}
-/**
- * Called when all challenges are loaded
- * @param {*} state
- * @param {*} param1
- */
-function onGetRestActiveChallengesDone(state, { error, payload }) {
- if (error) {
- logger.error(payload);
- return state;
- }
- const { uuid, challenges: loaded } = payload;
- if (uuid !== state.loadingRestActiveChallengesUUID) return state;
-
- /* Once all active challenges are fetched from the API, we remove from the
- * store any active challenges stored there previously, and also any
- * challenges with IDs matching any challenges loaded now as active. */
- const ids = new Set();
- loaded.forEach(item => ids.add(item.id));
-
- /* Fetching 0 page of active challenges also drops any active challenges
- * loaded to the state before. */
- const filter = item => !ids.has(item.id);
-
- const challenges = state.challenges
- .filter(filter)
- .concat(loaded);
+function onGetMyChallengesInit(state, { payload }) {
+ return {
+ ...state,
+ loadingMyChallengesUUID: payload.uuid,
+ lastRequestedPageOfMyChallenges: payload.page,
+ };
+}
+function onGetAllChallengesInit(state, { payload }) {
return {
...state,
- challenges,
- allActiveChallengesLoaded: true,
- lastUpdateOfActiveChallenges: Date.now(),
- lastRequestedPageOfActiveChallenges: -1,
- loadingRestActiveChallengesUUID: '',
+ loadingAllChallengesUUID: payload.uuid,
+ lastRequestedPageOfAllChallenges: payload.page,
};
}
+// function onGetRestActiveChallengesInit(state, { payload }) {
+// return {
+// ...state,
+// loadingRestActiveChallengesUUID: payload.uuid,
+// };
+// }
+
/**
- * Before get all recommended challenges
- * @param {Object} state current state
- * @param {Object} param1 payload info
- */
-function onGetAllRecommendedChallengesInit(state, { payload }) {
- return { ...state, loadingRecommendedChallengesUUID: payload };
-}
+ * Called when all challenges are loaded
+ * @param {*} state
+ * @param {*} param1
+// */
+// function onGetRestActiveChallengesDone(state, { error, payload }) {
+// if (error) {
+// logger.error(payload);
+// return state;
+// }
+// const { uuid, challenges: loaded } = payload;
+// if (uuid !== state.loadingRestActiveChallengesUUID) return state;
+
+// /* Once all active challenges are fetched from the API, we remove from the
+// * store any active challenges stored there previously, and also any
+// * challenges with IDs matching any challenges loaded now as active. */
+// const ids = new Set();
+// loaded.forEach(item => ids.add(item.id));
+
+// /* Fetching 0 page of active challenges also drops any active challenges
+// * loaded to the state before. */
+// const filter = item => !ids.has(item.id);
+
+// const challenges = state.challenges
+// .filter(filter)
+// .concat(loaded);
+
+// return {
+// ...state,
+// challenges,
+// allActiveChallengesLoaded: true,
+// lastUpdateOfActiveChallenges: Date.now(),
+// lastRequestedPageOfActiveChallenges: -1,
+// loadingRestActiveChallengesUUID: '',
+// };
+// }
/**
- * Get all recommended challenges
+ * Before get all recommended challenges
* @param {Object} state current state
* @param {Object} param1 payload info
*/
-function onGetAllRecommendedChallengesDone(state, { error, payload }) {
- if (error) {
- logger.error(payload);
- return state;
- }
- const { uuid, challenges, tag } = payload;
- if (uuid !== state.loadingRecommendedChallengesUUID) return state;
- const { recommendedChallenges } = state;
- recommendedChallenges[tag] = {
- challenges,
- lastUpdateOfActiveChallenges: Date.now(),
- };
- return {
- ...state,
- recommendedChallenges,
- loadingRecommendedChallengesTechnologies: tag,
- loadingRecommendedChallengesUUID: '',
- };
-}
+// function onGetAllRecommendedChallengesInit(state, { payload }) {
+// return { ...state, loadingRecommendedChallengesUUID: payload };
+// }
+
+// /**
+// * Get all recommended challenges
+// * @param {Object} state current state
+// * @param {Object} param1 payload info
+// */
+// function onGetAllRecommendedChallengesDone(state, { error, payload }) {
+// if (error) {
+// logger.error(payload);
+// return state;
+// }
+// const { uuid, challenges, tag } = payload;
+// if (uuid !== state.loadingRecommendedChallengesUUID) return state;
+// const { recommendedChallenges } = state;
+// recommendedChallenges[tag] = {
+// challenges,
+// lastUpdateOfActiveChallenges: Date.now(),
+// };
+// return {
+// ...state,
+// recommendedChallenges,
+// loadingRecommendedChallengesTechnologies: tag,
+// loadingRecommendedChallengesUUID: '',
+// };
+// }
/**
* On register done
@@ -283,61 +312,73 @@ function onGetChallengeTagsDone(state, action) {
};
}
-function onGetPastChallengesInit(state, action) {
- const { frontFilter, page, uuid } = action.payload;
- const tracks = frontFilter && frontFilter.tracks;
- if (tracks && _.isEmpty(tracks)) {
- return {
- ...state,
- allPastChallengesLoaded: true,
- loadingPastChallengesUUID: '',
- };
- }
-
- return {
- ...state,
- lastRequestedPageOfPastChallenges: page,
- loadingPastChallengesUUID: uuid,
- };
-}
-
-function onGetPastChallengesDone(state, { error, payload }) {
- if (error) {
- logger.error(payload);
- return state;
- }
- const { uuid, challenges: loaded, frontFilter } = payload;
- if (uuid !== state.loadingPastChallengesUUID) return state;
-
- const ids = new Set();
- loaded.forEach(item => ids.add(item.id));
-
- /* Fetching 0 page of past challenges also drops any past challenges
- * loaded to the state before. */
- const filter = state.lastRequestedPageOfPastChallenges
- ? item => !ids.has(item.id)
- : item => !ids.has(item.id) && item.status !== 'COMPLETED' && item.status !== 'PAST';
-
- const challenges = state.challenges.filter(filter).concat(loaded);
-
- let keepPastPlaceholders = false;
- if (loaded.length) {
- const ff = Filter.getFilterFunction(frontFilter);
- keepPastPlaceholders = challenges.filter(ff).length - state.challenges.filter(ff).length < 10;
- }
-
- const pastSearchTimestamp = state.pastSearchTimestamp && state.pastSearchTimestamp > 0
- ? state.pastSearchTimestamp : Date.now();
-
- return {
- ...state,
- allPastChallengesLoaded: loaded.length === 0,
- challenges,
- keepPastPlaceholders,
- loadingPastChallengesUUID: '',
- pastSearchTimestamp,
- };
-}
+// function onGetPastChallengesInit(state, action) {
+// const { frontFilter, page, uuid } = action.payload;
+// const tracks = frontFilter && frontFilter.tracks;
+// if (tracks && _.isEmpty(tracks)) {
+// return {
+// ...state,
+// allPastChallengesLoaded: true,
+// loadingPastChallengesUUID: '',
+// };
+// }
+
+// return {
+// ...state,
+// lastRequestedPageOfPastChallenges: page,
+// loadingPastChallengesUUID: uuid,
+// };
+// }
+
+// function onGetPastChallengesDone(state, { error, payload }) {
+// if (error) {
+// logger.error(payload);
+// return state;
+// }
+// const { uuid, pastChallenges: loaded } = payload;
+// if (uuid !== state.loadingPastChallengesUUID) return state;
+// const challenges = state.pastChallenges.concat(loaded);
+// return {
+// ...state,
+// pastChallenges: challenges,
+// loadingPastChallengesUUID: '',
+// };
+// if (error) {
+// logger.error(payload);
+// return state;
+// }
+// const { uuid, challenges: loaded, frontFilter } = payload;
+// if (uuid !== state.loadingPastChallengesUUID) return state;
+
+// const ids = new Set();
+// loaded.forEach(item => ids.add(item.id));
+
+// /* Fetching 0 page of past challenges also drops any past challenges
+// * loaded to the state before. */
+// // const filter = state.lastRequestedPageOfPastChallenges
+// // ? item => !ids.has(item.id)
+// // : item => !ids.has(item.id) && item.status !== 'COMPLETED' && item.status !== 'PAST';
+
+// const challenges = state.challenges.filter(filter).concat(loaded);
+
+// // let keepPastPlaceholders = false;
+// // if (loaded.length) {
+// // const ff = Filter.getFilterFunction(frontFilter);
+// keepPastPlaceholders = challenges.filter(ff).length - state.challenges.filter(ff).length < 10;
+// // }
+
+// // const pastSearchTimestamp = state.pastSearchTimestamp && state.pastSearchTimestamp > 0
+// // ? state.pastSearchTimestamp : Date.now();
+
+// return {
+// ...state,
+// allPastChallengesLoaded: loaded.length === 0,
+// challenges,
+// // keepPastPlaceholders,
+// loadingPastChallengesUUID: '',
+// // pastSearchTimestamp,
+// };
+// }
function onSelectCommunity(state, { payload }) {
updateQuery({ communityId: payload || undefined });
@@ -349,9 +390,9 @@ function onSelectCommunity(state, { payload }) {
* the code simple we just reset them each time a filter is modified.
* (This community selection defines community-specific filter for
* challenges). */
- allPastChallengesLoaded: false,
- lastRequestedPageOfPastChallenges: -1,
- pastSearchTimestamp: -1,
+ // allPastChallengesLoaded: false,
+ // lastRequestedPageOfPastChallenges: -1,
+ // pastSearchTimestamp: -1,
};
}
@@ -361,34 +402,42 @@ function onSelectCommunity(state, { payload }) {
* @return {Object}
*/
function onSetFilter(state, { payload }) {
+ // console.log(`bbbbbb`);
+ // console.log(payload);
/* Validation of filter parameters: they may come from URL query, thus
* validation is not a bad idea. As you may note, at the moment we do not
* do it very carefuly (many params are not validated). */
- const filter = _.clone(payload);
- if (_.isPlainObject(filter.tags)) {
- filter.tags = _.values(filter.tags);
- }
- if (_.isPlainObject(filter.subtracks)) {
- filter.subtracks = _.values(filter.subtracks);
- }
- if (filter.startDate && !moment(filter.startDate).isValid()) {
- delete filter.startDate;
+ const filter = _.pickBy(_.pick(
+ payload,
+ ['tags', 'types', 'name', 'startDateEnd', 'endDateStart', 'groups', 'events', 'tracks'],
+ ), value => (!_.isArray(value) && value && value !== '') || (_.isArray(value) && value.length > 0));
+ // if (_.isPlainObject(filter.tags)) {
+ // filter.tags = _.values(filter.tags);
+ // }
+ // if (_.isPlainObject(filter.subtracks)) {
+ // filter.subtracks = _.values(filter.subtracks);
+ // }
+ if (filter.startDateEnd && !moment(filter.startDateEnd).isValid()) {
+ delete filter.startDateEnd;
}
- if (filter.endDate && !moment(filter.endDate).isValid()) {
- delete filter.endDate;
+ if (filter.endDateStart && !moment(filter.endDateStart).isValid()) {
+ delete filter.endDateStart;
}
-
+ // console.log(`aaaaa`);
+ // console.log(filter);
/* Update of URL and generation of the state. */
- updateQuery({ filter });
+ updateQuery(filter);
+ // console.log(payload);
+ // console.log(`======`);
return {
...state,
- filter,
+ filter: _.assign({}, state.filter, payload),
/* Page numbers of past/upcoming challenges depend on the filters. To keep
* the code simple we just reset them each time a filter is modified. */
- allPastChallengesLoaded: false,
- lastRequestedPageOfPastChallenges: -1,
- pastSearchTimestamp: -1,
+ // allPastChallengesLoaded: false,
+ // lastRequestedPageOfPastChallenges: -1,
+ // pastSearchTimestamp: -1,
};
}
@@ -421,6 +470,8 @@ function onGetReviewOpportunitiesDone(state, { payload, error }) {
uuid,
loaded,
} = payload;
+ // console.log(`=====> review oppo`);
+ // console.log(loaded);
if (uuid !== state.loadingReviewOpportunitiesUUID) return state;
@@ -484,12 +535,12 @@ function onGetSrmsDone(state, { error, payload }) {
* @param {Object} state
* @return {Object} New state.
*/
-function onGetUserChallengesInit(state) {
- return {
- ...state,
- userChallenges: [],
- };
-}
+// function onGetUserChallengesInit(state) {
+// return {
+// ...state,
+// userChallenges: [],
+// };
+// }
/**
* Handles CHALLENGE_LISTING/GET_USER_CHALLENGES_DONE action
@@ -497,10 +548,94 @@ function onGetUserChallengesInit(state) {
* @param {Object} payload
* @return {Object} New state.
*/
-function onGetUserChallengesDone(state, { payload }) {
+// function onGetUserChallengesDone(state, { payload }) {
+// return {
+// ...state,
+// userChallenges: payload,
+// };
+// }
+
+function onGetOpenForRegistrationChallengesDone(state, { error, payload }) {
+ if (error) {
+ logger.error(payload);
+ return state;
+ }
+ const { uuid, openForRegistrationChallenges: loaded } = payload;
+ if (uuid !== state.loadingOpenForRegistrationChallengesUUID) return state;
+ const challenges = state.openForRegistrationChallenges.concat(loaded);
+ return {
+ ...state,
+ openForRegistrationChallenges: challenges,
+ loadingOpenForRegistrationChallengesUUID: '',
+ allOpenForRegistrationChallengesLoaded: challenges.length >= payload.meta.allChallengesCount,
+ meta: {
+ ...state.meta,
+ openChallengesCount: payload.meta.allChallengesCount,
+ },
+ };
+}
+
+function onGetMyChallengesDone(state, { error, payload }) {
+ if (error) {
+ logger.error(payload);
+ return state;
+ }
+ const { uuid, myChallenges: loaded } = payload;
+ if (uuid !== state.loadingMyChallengesUUID) return state;
+ const challenges = state.myChallenges.concat(loaded);
+ return {
+ ...state,
+ myChallenges: challenges,
+ loadingMyChallengesUUID: '',
+ allMyChallengesLoaded: challenges.length >= payload.meta.allChallengesCount,
+ meta: {
+ ...state.meta,
+ myChallengesCount: payload.meta.allChallengesCount,
+ },
+ };
+}
+
+function onGetAllChallengesDone(state, { error, payload }) {
+ if (error) {
+ logger.error(payload);
+ return state;
+ }
+ const { uuid, allChallenges: loaded } = payload;
+ if (uuid !== state.loadingAllChallengesUUID) return state;
+ const challenges = state.allChallenges.concat(loaded);
+ return {
+ ...state,
+ allChallenges: challenges,
+ loadingAllChallengesUUID: '',
+ allChallengesLoaded: challenges.length >= payload.meta.allChallengesCount,
+ meta: {
+ ...state.meta,
+ allChallengesCount: payload.meta.allChallengesCount,
+ },
+ };
+}
+
+function onGetTotalChallengesCountInit(state, { payload }) {
return {
...state,
- userChallenges: payload,
+ loadingTotalChallengesCountUUID: payload.uuid,
+ };
+}
+
+function onGetTotalChallengesCountDone(state, { error, payload }) {
+ if (error) {
+ logger.error(payload);
+ return state;
+ }
+ const { uuid } = payload;
+ if (uuid !== state.loadingTotalChallengesCountUUID) return state;
+ return {
+ ...state,
+ loadingTotalChallengesCountUUID: '',
+ meta: {
+ ...state.meta,
+ allChallengesCount: payload.meta.allChallengesCount,
+ },
};
}
@@ -516,40 +651,97 @@ function create(initialState) {
[a.dropChallenges]: state => ({
...state,
allActiveChallengesLoaded: false,
- allPastChallengesLoaded: false,
- allReviewOpportunitiesLoaded: false,
+ allMyChallengesLoaded: false,
+ allChallengesLoaded: false,
+ allOpenForRegistrationChallengesLoaded: false,
+ // allPastChallengesLoaded: false,
+ // allReviewOpportunitiesLoaded: false,
challenges: [],
+ allChallenges: [],
+ myChallenges: [],
+ openForRegistrationChallenges: [],
+ // pastChallenges: [],
lastRequestedPageOfActiveChallenges: -1,
- lastRequestedPageOfPastChallenges: -1,
- lastRequestedPageOfReviewOpportunities: -1,
- lastUpdateOfActiveChallenges: 0,
+ lastRequestedPageOfOpenForRegistrationChallenges: -1,
+ lastRequestedPageOfMyChallenges: -1,
+ lastRequestedPageOfAllChallenges: -1,
+ // lastRequestedPageOfPastChallenges: -1,
+ // lastRequestedPageOfReviewOpportunities: -1,
+ // lastUpdateOfActiveChallenges: 0,
loadingActiveChallengesUUID: '',
- loadingRestActiveChallengesUUID: '',
- loadingPastChallengesUUID: '',
- loadingReviewOpportunitiesUUID: '',
- reviewOpportunities: [],
- meta: {
- allChallengesCount: 0,
- myChallengesCount: 0,
- ongoingChallengesCount: 0,
- openChallengesCount: 0,
- totalCount: 0,
- },
+ loadingOpenForRegistrationChallengesUUID: '',
+ loadingMyChallengesUUID: '',
+ // loadingRestActiveChallengesUUID: '',
+ // loadingPastChallengesUUID: '',
+ // loadingReviewOpportunitiesUUID: '',
+
+ loadingTotalChallengesCountUUID: '',
+ // reviewOpportunities: [],
+ // filter: {
+ // tracks: {
+ // Dev: true,
+ // Des: true,
+ // DS: true,
+ // QA: true,
+ // },
+ // name: '',
+ // tags: [],
+ // types: [],
+ // communityId: 'All',
+ // startDateStart: '',
+ // endDateEnd: '',
+ // },
+ // meta: {
+ // allChallengesCount: 0,
+ // myChallengesCount: 0,
+ // ongoingChallengesCount: 0,
+ // openChallengesCount: 0,
+ // totalCount: 0,
+ // },
}),
-
+ [a.dropActiveChallenges]: state => ({
+ ...state,
+ challenges: [],
+ lastRequestedPageOfActiveChallenges: -1,
+ loadingActiveChallengesUUID: '',
+ }),
+ [a.dropOpenForRegistrationChallenges]: state => ({
+ ...state,
+ openForRegistrationChallenges: [],
+ lastRequestedPageOfOpenForRegistrationChallenges: -1,
+ loadingOpenForRegistrationChallengesUUID: '',
+ }),
+ [a.dropMyChallenges]: state => ({
+ ...state,
+ myChallenges: [],
+ lastRequestedPageOfMyChallenges: -1,
+ loadingMyChallengesUUID: '',
+ }),
+ [a.dropAllChallenges]: state => ({
+ ...state,
+ allChallenges: [],
+ lastRequestedPageOfAllChallenges: -1,
+ loadingAllChallengesUUID: '',
+ }),
+ // [a.dropPastChallenges]: state => ({
+ // ...state,
+ // pastChallenges: [],
+ // lastRequestedPageOfPastChallenges: -1,
+ // loadingPastChallengesUUID: '',
+ // }),
[a.expandTag]: (state, { payload }) => ({
...state,
expandedTags: [...state.expandedTags, payload],
}),
- [a.getAllActiveChallengesInit]: onGetAllActiveChallengesInit,
- [a.getAllActiveChallengesDone]: onGetAllActiveChallengesDone,
+ // [a.getAllActiveChallengesInit]: onGetAllActiveChallengesInit,
+ // [a.getAllActiveChallengesDone]: onGetAllActiveChallengesDone,
- [a.getAllUserChallengesInit]: onGetAllUserChallengesInit,
- [a.getAllUserChallengesDone]: onGetAllUserChallengesDone,
+ // [a.getAllUserChallengesInit]: onGetAllUserChallengesInit,
+ // [a.getAllUserChallengesDone]: onGetAllUserChallengesDone,
- [a.getAllRecommendedChallengesInit]: onGetAllRecommendedChallengesInit,
- [a.getAllRecommendedChallengesDone]: onGetAllRecommendedChallengesDone,
+ // [a.getAllRecommendedChallengesInit]: onGetAllRecommendedChallengesInit,
+ // [a.getAllRecommendedChallengesDone]: onGetAllRecommendedChallengesDone,
[actionChallenge.registerDone]: onRegisterDone,
[actionChallenge.unregisterDone]: onUnregisterDone,
@@ -557,8 +749,20 @@ function create(initialState) {
[a.getActiveChallengesInit]: onGetActiveChallengesInit,
[a.getActiveChallengesDone]: onGetActiveChallengesDone,
- [a.getRestActiveChallengesInit]: onGetRestActiveChallengesInit,
- [a.getRestActiveChallengesDone]: onGetRestActiveChallengesDone,
+ [a.getOpenForRegistrationChallengesInit]: onGetOpenForRegistrationChallengesInit,
+ [a.getOpenForRegistrationChallengesDone]: onGetOpenForRegistrationChallengesDone,
+
+ [a.getMyChallengesInit]: onGetMyChallengesInit,
+ [a.getMyChallengesDone]: onGetMyChallengesDone,
+
+ [a.getAllChallengesInit]: onGetAllChallengesInit,
+ [a.getAllChallengesDone]: onGetAllChallengesDone,
+
+ [a.getTotalChallengesCountInit]: onGetTotalChallengesCountInit,
+ [a.getTotalChallengesCountDone]: onGetTotalChallengesCountDone,
+
+ // [a.getRestActiveChallengesInit]: onGetRestActiveChallengesInit,
+ // [a.getRestActiveChallengesDone]: onGetRestActiveChallengesDone,
[a.getChallengeTypesInit]: state => ({
...state,
@@ -572,8 +776,8 @@ function create(initialState) {
}),
[a.getChallengeTagsDone]: onGetChallengeTagsDone,
- [a.getPastChallengesInit]: onGetPastChallengesInit,
- [a.getPastChallengesDone]: onGetPastChallengesDone,
+ // [a.getPastChallengesInit]: onGetPastChallengesInit,
+ // [a.getPastChallengesDone]: onGetPastChallengesDone,
[a.getReviewOpportunitiesInit]: onGetReviewOpportunitiesInit,
[a.getReviewOpportunitiesDone]: onGetReviewOpportunitiesDone,
@@ -581,8 +785,8 @@ function create(initialState) {
[a.getSrmsInit]: onGetSrmsInit,
[a.getSrmsDone]: onGetSrmsDone,
- [a.getUserChallengesInit]: onGetUserChallengesInit,
- [a.getUserChallengesDone]: onGetUserChallengesDone,
+ // [a.getUserChallengesInit]: onGetUserChallengesInit,
+ // [a.getUserChallengesDone]: onGetUserChallengesDone,
[a.selectCommunity]: onSelectCommunity,
@@ -596,10 +800,17 @@ function create(initialState) {
}),
}, _.defaults(_.clone(initialState) || {}, {
allActiveChallengesLoaded: false,
- allPastChallengesLoaded: false,
+ allMyChallengesLoaded: false,
+ allOpenForRegistrationChallengesLoaded: false,
+ allChallengesLoaded: false,
+ // allPastChallengesLoaded: false,
allReviewOpportunitiesLoaded: false,
challenges: [],
+ allChallenges: [],
+ myChallenges: [],
+ openForRegistrationChallenges: [],
+ // pastChallenges: [],
recommendedChallenges: {},
challengeTypes: [],
challengeTypesMap: {},
@@ -607,30 +818,58 @@ function create(initialState) {
expandedTags: [],
- filter: {},
-
keepPastPlaceholders: false,
lastRequestedPageOfActiveChallenges: -1,
- lastRequestedPageOfPastChallenges: -1,
+ lastRequestedPageOfOpenForRegistrationChallenges: -1,
+ lastRequestedPageOfMyChallenges: -1,
+ lastRequestedPageOfAllChallenges: -1,
+ // lastRequestedPageOfPastChallenges: -1,
lastRequestedPageOfReviewOpportunities: -1,
- lastUpdateOfActiveChallenges: 0,
+ // lastUpdateOfActiveChallenges: 0,
loadingActiveChallengesUUID: '',
+ loadingOpenForRegistrationChallengesUUID: '',
+ loadingMyChallengesUUID: '',
+ loadingAllChallengesUUID: '',
loadingRecommendedChallengesUUID: '',
- loadingRestActiveChallengesUUID: '',
+ // loadingRestActiveChallengesUUID: '',
loadingRecommendedChallengesTechnologies: '',
- loadingPastChallengesUUID: '',
+ loadingTotalChallengesCountUUID: '',
+ // loadingPastChallengesUUID: '',
loadingReviewOpportunitiesUUID: '',
loadingChallengeTypes: false,
loadingChallengeTags: false,
reviewOpportunities: [],
+ filter: {
+ tracks: {
+ Dev: true,
+ Des: true,
+ DS: true,
+ QA: true,
+ },
+ name: '',
+ tags: [],
+ types: [],
+ groups: [],
+ events: [],
+ startDateEnd: null,
+ endDateStart: null,
+ status: 'Active',
+ },
- selectedCommunityId: '',
+ selectedCommunityId: 'All',
- sorts: {},
+ sorts: {
+ ongoing: 'startDate',
+ openForRegistration: 'startDate',
+ my: 'startDate',
+ all: 'startDate',
+ // past: 'updated',
+ reviewOpportunities: 'review-opportunities-start-date',
+ },
srms: {
data: [],
@@ -646,7 +885,7 @@ function create(initialState) {
totalCount: 0,
},
- pastSearchTimestamp: -1,
+ // pastSearchTimestamp: -1,
}));
}
diff --git a/src/shared/reducers/challenge-listing/sidebar.js b/src/shared/reducers/challenge-listing/sidebar.js
index 3c9edfb758..e12ddd13b1 100644
--- a/src/shared/reducers/challenge-listing/sidebar.js
+++ b/src/shared/reducers/challenge-listing/sidebar.js
@@ -7,98 +7,98 @@
import _ from 'lodash';
import actions from 'actions/challenge-listing/sidebar';
-import { logger } from 'topcoder-react-lib';
+// import { logger } from 'topcoder-react-lib';
import { BUCKETS } from 'utils/challenge-listing/buckets';
import { handleActions } from 'redux-actions';
import { updateQuery } from 'utils/url';
-const MAX_FILTER_NAME_LENGTH = 35;
+// const MAX_FILTER_NAME_LENGTH = 35;
/**
* Handles changeFilterName action.
* @param {Object} state
* @param {Object} action
*/
-function onChangeFilterName(state, { payload: { index, name } }) {
- const savedFilters = _.clone(state.savedFilters);
- savedFilters[index] = {
- ...savedFilters[index],
- error: name.trim() ? '' : 'Filter name must not be empty',
- name: name.slice(0, MAX_FILTER_NAME_LENGTH),
- };
- if (_.isUndefined(savedFilters[index].savedName)) {
- savedFilters[index].savedName = state.savedFilters[index].name;
- }
- return { ...state, savedFilters };
-}
-
-/**
- * Handles outcome of the deleteSavedFilter action.
- * @param {Object} state
- * @param {Object} action
- * @return {Object}
- */
-function onDeleteSavedFilter(state, action) {
- if (action.error) {
- logger.error(action.payload);
- return state;
- }
- const id = action.payload;
- return {
- ...state,
- savedFilters: state.savedFilters.filter(item => item.id !== id),
- };
-}
-
-function onDragSavedFilterMove(state, action) {
- const dragState = _.clone(action.payload);
- if (dragState.currentIndex < 0) dragState.currentIndex = 0;
- else if (dragState.currentIndex >= state.savedFilters.length) {
- dragState.currentIndex = state.savedFilters.length - 1;
- }
- const savedFilters = _.clone(state.savedFilters);
- const [filter] = savedFilters.splice(state.dragState.currentIndex, 1);
- savedFilters.splice(dragState.currentIndex, 0, filter);
- return {
- ...state,
- dragState,
- savedFilters,
- };
-}
-
-function onDragSavedFilterStart(state, action) {
- return { ...state, dragState: action.payload };
-}
+// function onChangeFilterName(state, { payload: { index, name } }) {
+// const savedFilters = _.clone(state.savedFilters);
+// savedFilters[index] = {
+// ...savedFilters[index],
+// error: name.trim() ? '' : 'Filter name must not be empty',
+// name: name.slice(0, MAX_FILTER_NAME_LENGTH),
+// };
+// if (_.isUndefined(savedFilters[index].savedName)) {
+// savedFilters[index].savedName = state.savedFilters[index].name;
+// }
+// return { ...state, savedFilters };
+// }
+
+// /**
+// * Handles outcome of the deleteSavedFilter action.
+// * @param {Object} state
+// * @param {Object} action
+// * @return {Object}
+// */
+// function onDeleteSavedFilter(state, action) {
+// if (action.error) {
+// logger.error(action.payload);
+// return state;
+// }
+// const id = action.payload;
+// return {
+// ...state,
+// savedFilters: state.savedFilters.filter(item => item.id !== id),
+// };
+// }
+
+// function onDragSavedFilterMove(state, action) {
+// const dragState = _.clone(action.payload);
+// if (dragState.currentIndex < 0) dragState.currentIndex = 0;
+// else if (dragState.currentIndex >= state.savedFilters.length) {
+// dragState.currentIndex = state.savedFilters.length - 1;
+// }
+// const savedFilters = _.clone(state.savedFilters);
+// const [filter] = savedFilters.splice(state.dragState.currentIndex, 1);
+// savedFilters.splice(dragState.currentIndex, 0, filter);
+// return {
+// ...state,
+// dragState,
+// savedFilters,
+// };
+// }
+
+// function onDragSavedFilterStart(state, action) {
+// return { ...state, dragState: action.payload };
+// }
/**
* Handles outcome of saveFilter action.
* @param {Object} state
* @param {Object} action
*/
-function onFilterSaved(state, action) {
- if (action.error) {
- logger.error(action.payload);
- alert('Failed to save the filter!');
- return {
- ...state,
- isSavingFilter: false,
- };
- }
-
- const newSavedFilter = {
- ...action.payload,
- filter: JSON.parse(action.payload.filter),
- };
-
- return {
- ...state,
- activeBucket: newSavedFilter.filter.isForReviewOpportunities
- ? BUCKETS.SAVED_REVIEW_OPPORTUNITIES_FILTER : BUCKETS.SAVED_FILTER,
- activeSavedFilter: state.savedFilters.length,
- savedFilters: state.savedFilters.concat(newSavedFilter),
- isSavingFilter: false,
- };
-}
+// function onFilterSaved(state, action) {
+// if (action.error) {
+// logger.error(action.payload);
+// alert('Failed to save the filter!');
+// return {
+// ...state,
+// isSavingFilter: false,
+// };
+// }
+
+// const newSavedFilter = {
+// ...action.payload,
+// filter: JSON.parse(action.payload.filter),
+// };
+
+// return {
+// ...state,
+// activeBucket: newSavedFilter.filter.isForReviewOpportunities
+// ? BUCKETS.SAVED_REVIEW_OPPORTUNITIES_FILTER : BUCKETS.SAVED_FILTER,
+// activeSavedFilter: state.savedFilters.length,
+// savedFilters: state.savedFilters.concat(newSavedFilter),
+// isSavingFilter: false,
+// };
+// }
/**
* Resets filter name to the last one saved to the API.
@@ -106,32 +106,33 @@ function onFilterSaved(state, action) {
* @param {Object} action
* @return {Object}
*/
-function onResetFilterName(state, action) {
- const index = action.payload;
- if (_.isUndefined(state.savedFilters[index].savedName)) return state;
- const savedFilters = _.clone(state.savedFilters);
- savedFilters[index] = {
- ...savedFilters[index],
- error: '',
- name: savedFilters[index].savedName,
- };
- delete savedFilters[index].savedName;
- return { ...state, savedFilters };
-}
+// function onResetFilterName(state, action) {
+// const index = action.payload;
+// if (_.isUndefined(state.savedFilters[index].savedName)) return state;
+// const savedFilters = _.clone(state.savedFilters);
+// savedFilters[index] = {
+// ...savedFilters[index],
+// error: '',
+// name: savedFilters[index].savedName,
+// };
+// delete savedFilters[index].savedName;
+// return { ...state, savedFilters };
+// }
function onSelectBucket(state, { payload }) {
- switch (payload) {
+ switch (payload.bucket) {
case BUCKETS.ALL:
- case BUCKETS.SAVED_FILTER:
- updateQuery({ bucket: undefined });
+ // case BUCKETS.SAVED_FILTER:
+ updateQuery({ bucket: payload.bucket });
break;
default:
- updateQuery({ bucket: payload });
+ updateQuery({ bucket: payload.expanding ? undefined : payload.bucket });
break;
}
return {
...state,
- activeBucket: payload,
+ activeBucket: payload.bucket,
+ expanding: payload.expanding,
isBucketSwitching: true,
};
}
@@ -143,68 +144,68 @@ function onSelectBucketDone(state) {
};
}
-function onSelectSavedFilter(state, { payload }) {
- const { isForReviewOpportunities } = state.savedFilters[payload].filter;
- updateQuery({
- bucket: isForReviewOpportunities ? BUCKETS.SAVED_REVIEW_OPPORTUNITIES_FILTER : undefined,
- });
- return {
- ...state,
- activeBucket: isForReviewOpportunities
- ? BUCKETS.SAVED_REVIEW_OPPORTUNITIES_FILTER : BUCKETS.SAVED_FILTER,
- activeSavedFilter: payload,
- };
-}
+// function onSelectSavedFilter(state, { payload }) {
+// const { isForReviewOpportunities } = state.savedFilters[payload].filter;
+// updateQuery({
+// bucket: isForReviewOpportunities ? BUCKETS.SAVED_REVIEW_OPPORTUNITIES_FILTER : undefined,
+// });
+// return {
+// ...state,
+// activeBucket: isForReviewOpportunities
+// ? BUCKETS.SAVED_REVIEW_OPPORTUNITIES_FILTER : BUCKETS.SAVED_FILTER,
+// activeSavedFilter: payload,
+// };
+// }
/**
* Handles outcome of the updateSavedFilterAction.
* @param {Object} state
* @param {Object} action
*/
-function onUpdateSavedFilter(state, action) {
- if (action.error) {
- logger.error(action.payload);
- return state;
- }
- const filter = action.payload;
- const index = _.findIndex(state.savedFilters, item => item.id === filter.id);
- const savedFilters = _.clone(state.savedFilters);
- savedFilters[index] = filter;
- savedFilters[index].filter = JSON.parse(filter.filter);
- return { ...state, savedFilters };
-}
+// function onUpdateSavedFilter(state, action) {
+// if (action.error) {
+// logger.error(action.payload);
+// return state;
+// }
+// const filter = action.payload;
+// const index = _.findIndex(state.savedFilters, item => item.id === filter.id);
+// const savedFilters = _.clone(state.savedFilters);
+// savedFilters[index] = filter;
+// savedFilters[index].filter = JSON.parse(filter.filter);
+// return { ...state, savedFilters };
+// }
function create(initialState = {}) {
const a = actions.challengeListing.sidebar;
return handleActions({
- [a.changeFilterName]: onChangeFilterName,
- [a.deleteSavedFilter]: onDeleteSavedFilter,
- [a.dragSavedFilterMove]: onDragSavedFilterMove,
- [a.dragSavedFilterStart]: onDragSavedFilterStart,
- [a.getSavedFilters]: (state, action) => ({
- ...state,
- savedFilters: action.error ? [] : action.payload,
- }),
- [a.resetFilterName]: onResetFilterName,
- [a.saveFilterDone]: onFilterSaved,
- [a.saveFilterInit]: state => ({
- ...state,
- isSavingFilter: true,
- }),
+ // [a.changeFilterName]: onChangeFilterName,
+ // [a.deleteSavedFilter]: onDeleteSavedFilter,
+ // [a.dragSavedFilterMove]: onDragSavedFilterMove,
+ // [a.dragSavedFilterStart]: onDragSavedFilterStart,
+ // [a.getSavedFilters]: (state, action) => ({
+ // ...state,
+ // savedFilters: action.error ? [] : action.payload,
+ // }),
+ // [a.resetFilterName]: onResetFilterName,
+ // [a.saveFilterDone]: onFilterSaved,
+ // [a.saveFilterInit]: state => ({
+ // ...state,
+ // isSavingFilter: true,
+ // }),
[a.selectBucket]: onSelectBucket,
[a.selectBucketDone]: onSelectBucketDone,
- [a.selectSavedFilter]: onSelectSavedFilter,
- [a.setEditSavedFiltersMode]: (state, { payload }) => ({
- ...state,
- editSavedFiltersMode: payload,
- }),
- [a.updateSavedFilter]: onUpdateSavedFilter,
+ // [a.selectSavedFilter]: onSelectSavedFilter,
+ // [a.setEditSavedFiltersMode]: (state, { payload }) => ({
+ // ...state,
+ // editSavedFiltersMode: payload,
+ // }),
+ // [a.updateSavedFilter]: onUpdateSavedFilter,
}, _.defaults(initialState, {
activeBucket: BUCKETS.ALL,
- activeSavedFilter: 0,
- editSavedFiltersMode: false,
- savedFilters: [],
- isSavingFilter: false,
+ // activeSavedFilter: 0,
+ // editSavedFiltersMode: false,
+ // savedFilters: [],
+ // isSavingFilter: false,
}));
}
diff --git a/src/shared/utils/challenge-listing/buckets.js b/src/shared/utils/challenge-listing/buckets.js
index 225203bc7b..207fc92118 100644
--- a/src/shared/utils/challenge-listing/buckets.js
+++ b/src/shared/utils/challenge-listing/buckets.js
@@ -10,98 +10,101 @@ export const BUCKETS = {
MY: 'my',
OPEN_FOR_REGISTRATION: 'openForRegistration',
ONGOING: 'ongoing',
- PAST: 'past',
- SAVED_FILTER: 'saved-filter',
- UPCOMING: 'upcoming',
+ // PAST: 'past',
+ // SAVED_FILTER: 'saved-filter',
+ // UPCOMING: 'upcoming',
REVIEW_OPPORTUNITIES: 'reviewOpportunities',
- SAVED_REVIEW_OPPORTUNITIES_FILTER: 'savedReviewOpportunitiesFilter',
+ // SAVED_REVIEW_OPPORTUNITIES_FILTER: 'savedReviewOpportunitiesFilter',
};
-const BUCKET_DATA = {
+export const BUCKET_DATA = {
[BUCKETS.ALL]: {
- filter: {
- started: true,
- status: ['Active'],
- },
- hideCount: false,
+ // filter: {
+ // started: true,
+ // status: ['Active'],
+ // },
+ // hideCount: false,
name: 'All Challenges',
- sorts: [],
+ sorts: [
+ SORTS.MOST_RECENT_START_DATE,
+ SORTS.TITLE_A_TO_Z,
+ ],
},
[BUCKETS.MY]: {
- filter: {
- status: ['Active'],
- // users: [userHandle],
- },
- hideCount: false,
+ // filter: {
+ // status: ['Active'],
+ // // users: [userHandle],
+ // },
+ // hideCount: false,
name: 'My Challenges',
sorts: [
- SORTS.MOST_RECENT,
- SORTS.TIME_TO_SUBMIT,
- SORTS.NUM_REGISTRANTS,
- SORTS.NUM_SUBMISSIONS,
- SORTS.PRIZE_HIGH_TO_LOW,
+ SORTS.MOST_RECENT_START_DATE,
+ // SORTS.TIME_TO_SUBMIT,
+ // SORTS.NUM_REGISTRANTS,
+ // SORTS.NUM_SUBMISSIONS,
+ // SORTS.PRIZE_HIGH_TO_LOW,
SORTS.TITLE_A_TO_Z,
],
},
[BUCKETS.OPEN_FOR_REGISTRATION]: {
- filter: {
- registrationOpen: true,
- started: true,
- status: ['Active'],
- },
- hideCount: false,
+ // filter: {
+ // registrationOpen: true,
+ // started: true,
+ // status: ['Active'],
+ // },
+ // hideCount: false,
name: 'Open for registration',
sorts: [
- SORTS.MOST_RECENT,
- SORTS.TIME_TO_REGISTER,
- SORTS.TIME_TO_SUBMIT,
- SORTS.NUM_REGISTRANTS,
- SORTS.NUM_SUBMISSIONS,
- SORTS.PRIZE_HIGH_TO_LOW,
+ SORTS.MOST_RECENT_START_DATE,
+ // SORTS.TIME_TO_REGISTER,
+ // SORTS.TIME_TO_SUBMIT,
+ // SORTS.NUM_REGISTRANTS,
+ // SORTS.NUM_SUBMISSIONS,
+ // SORTS.PRIZE_HIGH_TO_LOW,
SORTS.TITLE_A_TO_Z,
],
},
[BUCKETS.ONGOING]: {
- filter: {
- registrationOpen: false,
- started: true,
- ongoing: true,
- status: ['Active'],
- },
- hideCount: false,
+ // filter: {
+ // registrationOpen: false,
+ // started: true,
+ // ongoing: true,
+ // status: ['Active'],
+ // },
+ // hideCount: false,
name: 'Ongoing challenges',
sorts: [
- SORTS.MOST_RECENT,
- SORTS.CURRENT_PHASE,
+ SORTS.MOST_RECENT_START_DATE,
+ // SORTS.CURRENT_PHASE,
SORTS.TITLE_A_TO_Z,
- SORTS.PRIZE_HIGH_TO_LOW,
+ // SORTS.PRIZE_HIGH_TO_LOW,
],
},
[BUCKETS.UPCOMING]: {
- filter: {
- upcoming: true,
- },
- hideCount: true,
+ // filter: {
+ // upcoming: true,
+ // },
+ // hideCount: true,
name: 'Upcoming challenges',
sorts: [
SORTS.MOST_RECENT,
- SORTS.PRIZE_HIGH_TO_LOW,
- SORTS.TITLE_A_TO_Z,
- ],
- },
- [BUCKETS.PAST]: {
- filter: { status: ['Completed', 'PAST'] },
- hideCount: true,
- name: 'Past challenges',
- sorts: [
- SORTS.MOST_RECENT,
- SORTS.PRIZE_HIGH_TO_LOW,
+ // SORTS.PRIZE_HIGH_TO_LOW,
SORTS.TITLE_A_TO_Z,
],
},
+ // [BUCKETS.PAST]: {
+ // // filter: { status: ['Completed', 'PAST'] },
+ // // hideCount: true,
+ // name: 'Past challenges',
+ // sorts: [
+ // SORTS.MOST_RECENT,
+ // // SORTS.PRIZE_HIGH_TO_LOW,
+ // SORTS.TITLE_A_TO_Z,
+ // ],
+ // },
[BUCKETS.REVIEW_OPPORTUNITIES]: {
filter: {},
- hideCount: true,
+ // hideCount: true,
name: 'Open for review',
sorts: [
SORTS.REVIEW_OPPORTUNITIES_START_DATE,
@@ -109,14 +112,14 @@ const BUCKET_DATA = {
SORTS.REVIEW_OPPORTUNITIES_TITLE_A_TO_Z,
],
},
- [BUCKETS.SAVED_REVIEW_OPPORTUNITIES_FILTER]: {
- filter: {},
- sorts: [
- SORTS.REVIEW_OPPORTUNITIES_START_DATE,
- SORTS.REVIEW_OPPORTUNITIES_PAYMENT,
- SORTS.REVIEW_OPPORTUNITIES_TITLE_A_TO_Z,
- ],
- },
+ // [BUCKETS.SAVED_REVIEW_OPPORTUNITIES_FILTER]: {
+ // // filter: {},
+ // sorts: [
+ // // SORTS.REVIEW_OPPORTUNITIES_START_DATE,
+ // // SORTS.REVIEW_OPPORTUNITIES_PAYMENT,
+ // // SORTS.REVIEW_OPPORTUNITIES_TITLE_A_TO_Z,
+ // ],
+ // },
};
export const NO_LIVE_CHALLENGES_CONFIG = {
@@ -124,9 +127,9 @@ export const NO_LIVE_CHALLENGES_CONFIG = {
[BUCKETS.MY]: 'No challenges found in My Challenges',
[BUCKETS.OPEN_FOR_REGISTRATION]: 'No challenges found in Open for Registration Challenges',
[BUCKETS.ONGOING]: 'No challenges found in Ongoing Challenges',
- [BUCKETS.PAST]: 'No challenges found in Past Challenges',
- [BUCKETS.SAVED_FILTER]: 'No challenges found in Saved filter Challenges',
- [BUCKETS.UPCOMING]: 'No challenges found in Upcoming Challenges',
+ // [BUCKETS.PAST]: 'No challenges found in Past Challenges',
+ // [BUCKETS.SAVED_FILTER]: 'No challenges found in Saved filter Challenges',
+ // [BUCKETS.UPCOMING]: 'No challenges found in Upcoming Challenges',
};
/**
@@ -146,7 +149,8 @@ export function getBuckets(userChallenges) {
* @return {Boolean} True if the bucket contains Review Opportunities
*/
export const isReviewOpportunitiesBucket = bucket => (
- bucket === BUCKETS.REVIEW_OPPORTUNITIES || bucket === BUCKETS.SAVED_REVIEW_OPPORTUNITIES_FILTER);
+// bucket === BUCKETS.REVIEW_OPPORTUNITIES || bucket === BUCKETS.SAVED_REVIEW_OPPORTUNITIES_FILTER);
+ bucket === BUCKETS.REVIEW_OPPORTUNITIES);
/**
* Registers a new bucket.
@@ -161,4 +165,51 @@ export function registerBucket(id, bucket) {
BUCKET_DATA[id] = bucket;
}
+
+export function filterChanged(filter, prevFilter) {
+ if (!filter || !prevFilter) {
+ return true;
+ }
+ return (!_.isEqual(filter.tracks, prevFilter.tracks))
+ || (filter.name !== prevFilter.name)
+ || (filter.status !== prevFilter.status)
+ || (filter.startDateEnd !== prevFilter.startDateEnd)
+ || (filter.endDateStart !== prevFilter.endDateStart)
+ // eslint-disable-next-line max-len
+ || (!_.isEqual(filter.groups, prevFilter.groups))
+ || (!_.isEqual(filter.events, prevFilter.events))
+ || _.filter(filter.tags, val => _.indexOf(prevFilter.tags, val) < 0).length > 0
+ || _.filter(prevFilter.tags, val => _.indexOf(filter.tags, val) < 0).length > 0
+ || _.filter(filter.types, val => _.indexOf(prevFilter.types, val) < 0).length > 0
+ || _.filter(prevFilter.types, val => _.indexOf(filter.types, val) < 0).length > 0;
+}
+
+export function sortChangedBucket(sorts, prevSorts) {
+ if (sorts.ongoing !== prevSorts.ongoing) return 'ongoing';
+ if (sorts.my !== prevSorts.my) return 'my';
+ if (sorts.all !== prevSorts.all) return 'all';
+ if (sorts.openForRegistration !== prevSorts.openForRegistration) return 'openForRegistration';
+ // if (sorts.past !== prevSorts.past) return 'past';
+ return '';
+}
+
+export function isFilterEmpty(filter) {
+ return _.isEqual(filter, {
+ tracks: {
+ Dev: true,
+ Des: true,
+ DS: true,
+ QA: true,
+ },
+ name: '',
+ tags: [],
+ types: [],
+ groups: [],
+ events: [],
+ startDateStart: null,
+ endDateEnd: null,
+ status: 'Active',
+ });
+}
+
export default undefined;
diff --git a/src/shared/utils/challenge-listing/sort.js b/src/shared/utils/challenge-listing/sort.js
index 80b6d695d9..ce537b2ac5 100644
--- a/src/shared/utils/challenge-listing/sort.js
+++ b/src/shared/utils/challenge-listing/sort.js
@@ -3,147 +3,87 @@
*/
import moment from 'moment';
-import { find, sumBy, isEmpty } from 'lodash';
-import { phaseStartDate, phaseEndDate } from './helper';
+import { sumBy } from 'lodash';
+// import { phaseStartDate, phaseEndDate } from './helper';
export const SORTS = {
- CURRENT_PHASE: 'current-phase',
- MOST_RECENT: 'most-recent',
- NUM_REGISTRANTS: 'num-registrants',
- NUM_SUBMISSIONS: 'num-submissions',
- PRIZE_HIGH_TO_LOW: 'prize-high-to-low',
- TIME_TO_REGISTER: 'time-to-register',
- TIME_TO_SUBMIT: 'time-to-submit',
- TITLE_A_TO_Z: 'title-a-to-z',
+ // CURRENT_PHASE: 'current-phase',
+ MOST_RECENT: 'updated',
+ MOST_RECENT_START_DATE: 'startDate',
+ // NUM_REGISTRANTS: 'num-registrants',
+ // NUM_SUBMISSIONS: 'num-submissions',
+ // PRIZE_HIGH_TO_LOW: 'prize-high-to-low',
+ // TIME_TO_REGISTER: 'time-to-register',
+ // TIME_TO_SUBMIT: 'time-to-submit',
+ TITLE_A_TO_Z: 'name',
REVIEW_OPPORTUNITIES_TITLE_A_TO_Z: 'review-opportunities-title-a-to-z',
REVIEW_OPPORTUNITIES_PAYMENT: 'review-opportunities-payment',
REVIEW_OPPORTUNITIES_START_DATE: 'review-opportunities-start-date',
};
export default {
- [SORTS.CURRENT_PHASE]: {
- func: (a, b) => {
- const aPhases = a.phases || [];
- const bPhases = b.phases || [];
- const aPhase = aPhases
- .filter(p => p.name !== 'Registration' && p.isOpen)
- .sort((p1, p2) => moment(p1.scheduledEndDate).diff(p2.scheduledEndDate))[0];
- const bPhase = bPhases
- .filter(p => p.name !== 'Registration' && p.isOpen)
- .sort((p1, p2) => moment(p1.scheduledEndDate).diff(p2.scheduledEndDate))[0];
-
- let aPhaseName = 'Stalled';
- let bPhaseName = 'Stalled';
- if (!aPhase && a.type === 'First2Finish' && aPhases.length) {
- aPhaseName = 'Submission';
- }
- if (!bPhase && b.type === 'First2Finish' && bPhases.length) {
- bPhaseName = 'Submission';
- }
-
- if (aPhase) aPhaseName = aPhase.name;
- else if (a.status === 'Draft') aPhaseName = 'Draft';
-
- if (bPhase) bPhaseName = bPhase.name;
- else if (b.status === 'Draft') bPhaseName = 'Draft';
-
- return aPhaseName.localeCompare(bPhaseName);
- },
- name: 'Current phase',
- },
+ // [SORTS.CURRENT_PHASE]: {
+ // func: (a, b) => a.status.localeCompare(b.status),
+ // name: 'Current phase',
+ // },
[SORTS.MOST_RECENT]: {
- func: (a, b) => {
- const getChallengeStartDate = (challenge) => {
- // extract the phases from `challenge.phases`,
- // as `challenge.registrationStartDate` returned from API is not reliable
- const registrationPhase = find(challenge.phases, p => p.name === 'Registration') || {};
- const submissionPhase = find(challenge.phases, p => p.name === 'Submission') || {};
- // registration phase exists
- if (!isEmpty(registrationPhase)) {
- return moment(phaseStartDate(registrationPhase));
- }
- // registration phase doesnt exist, This is possibly a F2F or TSK. Take submission phase
- return moment(phaseStartDate(submissionPhase));
- };
- const aChallengeStartDate = getChallengeStartDate(a);
- const bChallengeStartDate = getChallengeStartDate(b);
- return bChallengeStartDate.diff(aChallengeStartDate);
- },
+ // func: (a, b) => moment(b.registrationStartDate).diff(a.registrationStartDate),
name: 'Most recent',
+ order: 'desc',
},
- [SORTS.NUM_REGISTRANTS]: {
- func: (a, b) => b.numOfRegistrants - a.numOfRegistrants,
- name: '# of registrants',
- },
- [SORTS.NUM_SUBMISSIONS]: {
- func: (a, b) => b.numOfSubmissions - a.numOfSubmissions,
- name: '# of submissions',
- },
- [SORTS.PRIZE_HIGH_TO_LOW]: {
- func: (a, b) => b.totalPrize - a.totalPrize,
- name: 'Prize high to low',
+ [SORTS.MOST_RECENT_START_DATE]: {
+ name: 'Most recent',
+ order: 'desc',
},
- [SORTS.TIME_TO_REGISTER]: {
- func: (a, b) => {
- const getRegistrationEndDate = (challenge) => {
- // extract the registration phase from `challenge.phases`,
- // as `challenge.registrationEndDate` returned from API is not reliable
- const registrationPhase = find(challenge.phases, p => p.name === 'Registration');
- const submissionPhase = find(challenge.phases, p => p.name === 'Submission');
- // case 1: registration phase exists
- if (registrationPhase) {
- return moment(phaseEndDate(registrationPhase));
- }
- // case 2: registration phase doesn't exist. Take submission phase instead.
- return moment(phaseEndDate(submissionPhase));
- };
+ // [SORTS.NUM_REGISTRANTS]: {
+ // func: (a, b) => b.numOfRegistrants - a.numOfRegistrants,
+ // name: '# of registrants',
+ // },
+ // [SORTS.NUM_SUBMISSIONS]: {
+ // func: (a, b) => b.numOfSubmissions - a.numOfSubmissions,
+ // name: '# of submissions',
+ // },
+ // [SORTS.PRIZE_HIGH_TO_LOW]: {
+ // func: (a, b) => b.totalPrize - a.totalPrize,
+ // name: 'Prize high to low',
+ // },
+ // [SORTS.TIME_TO_REGISTER]: {
+ // func: (a, b) => {
+ // const aDate = moment(a.registrationEndDate || a.submissionEndTimestamp);
+ // const bDate = moment(b.registrationEndDate || b.submissionEndTimestamp);
- const aDate = getRegistrationEndDate(a);
- const bDate = getRegistrationEndDate(b);
+ // if (aDate.isBefore() && bDate.isAfter()) return 1;
+ // if (aDate.isAfter() && bDate.isBefore()) return -1;
+ // if (aDate.isBefore() && bDate.isBefore()) return bDate.diff(aDate);
- if (aDate.isBefore() && bDate.isAfter()) return 1;
- if (aDate.isAfter() && bDate.isBefore()) return -1;
- if (aDate.isBefore() && bDate.isBefore()) return bDate.diff(aDate);
+ // return aDate.diff(bDate);
+ // },
+ // name: 'Time to register',
+ // },
+ // [SORTS.TIME_TO_SUBMIT]: {
+ // func: (a, b) => {
+ // function nextSubEndDate(o) {
+ // if (o.checkpointSubmissionEndDate && moment(o.checkpointSubmissionEndDate).isAfter()) {
+ // return moment(o.checkpointSubmissionEndDate);
+ // }
+ // return moment(o.submissionEndTimestamp);
+ // }
- return aDate.diff(bDate);
- },
- name: 'Time to register',
- },
- [SORTS.TIME_TO_SUBMIT]: {
- func: (a, b) => {
- function nextSubEndDate(challenge) {
- // extract the submission and checkpoint (if any) phases from `challenge.phases`,
- // as `challenge.submissionEndDate` returned from API is not reliable
- const checkpointPhase = find(challenge.phases, p => p.name === 'Checkpoint Submission');
- const submissionPhase = find(challenge.phases, p => p.name === 'Submission');
- // Case 1: challenge has checkpoint submission phase
- if (!!checkpointPhase === true) {
- // Case 1.1: checkpoint submission phase is still open.
- // then take the `scheduledEndDate` of this phase.
- // Case 1.2: checkpoint submission phase is closed
- // but its `scheduledStartDate` is a future date.
- // This means this phase is not yet started. Take the `scheduledEndDate` of this phase.
- if (checkpointPhase.isOpen || moment(checkpointPhase.scheduledStartDate).isAfter()) {
- return moment(checkpointPhase.scheduledEndDate);
- }
- }
- return moment(phaseEndDate(submissionPhase));
- }
+ // const aDate = nextSubEndDate(a);
+ // const bDate = nextSubEndDate(b);
- const aDate = nextSubEndDate(a);
- const bDate = nextSubEndDate(b);
+ // if (aDate.isBefore() && bDate.isAfter()) return 1;
+ // if (aDate.isAfter() && bDate.isBefore()) return -1;
+ // if (aDate.isBefore() && bDate.isBefore()) return bDate.diff(aDate);
- if (aDate.isBefore() && bDate.isAfter()) return 1;
- if (aDate.isAfter() && bDate.isBefore()) return -1;
- if (aDate.isBefore() && bDate.isBefore()) return bDate.diff(aDate);
-
- return aDate.diff(bDate);
- },
- name: 'Time to submit',
- },
+ // return aDate.diff(bDate);
+ // },
+ // name: 'Time to submit',
+ // },
[SORTS.TITLE_A_TO_Z]: {
- func: (a, b) => a.name.localeCompare(b.name),
+ // func: (a, b) => a.name.localeCompare(b.name),
name: 'Title A-Z',
+ order: 'asc',
},
[SORTS.REVIEW_OPPORTUNITIES_TITLE_A_TO_Z]: {
func: (a, b) => a.challenge.title.localeCompare(b.challenge.title),
diff --git a/src/shared/utils/url.js b/src/shared/utils/url.js
index dc2a90d0ac..f7c76b3da9 100644
--- a/src/shared/utils/url.js
+++ b/src/shared/utils/url.js
@@ -7,7 +7,7 @@
import _ from 'lodash';
import qs from 'qs';
import { isomorphy } from 'topcoder-react-utils';
-
+import { BUCKETS } from 'utils/challenge-listing/buckets';
/**
* Get current URL hash parameters as object
*/
@@ -37,17 +37,54 @@ export function getQuery() {
export function updateQuery(update) {
if (isomorphy.isServerSide()) return;
- let query = qs.parse(window.location.search.slice(1));
+ let filterObj = {};
+ // check if bucket is selected
+ if (update.bucket) {
+ // fetching everything else from url except bucket
+ filterObj = {
+ ...qs.parse(window.location.search.slice(1)),
+ ...update,
+ };
+ if (update.bucket === BUCKETS.ALL) {
+ delete filterObj.bucket; // delete bucket field for all challenges
+ }
+ } else {
+ // fetch only bucket from url
+ const query = qs.parse(window.location.search.slice(1));
+ filterObj = {
+ ...(query.bucket && { bucket: query.bucket }), // fetch only bucket from url
+ ...update,
+ };
+ }
+ let query = '?';
const { hash } = window.location;
+ const filterArray = [];
/* _.merge won't work here, because it just ignores the fields explicitely
* set as undefined in the objects to be merged, rather than deleting such
* fields in the target object. */
- _.forIn(update, (value, key) => {
- if (_.isUndefined(value)) delete query[key];
- else query[key] = value;
+ _.forIn(filterObj, (value, key) => {
+ if (_.isArray(value) && value.length > 0) filterArray.push(value.map(item => `${key}[]=${item}`).join('&'));
+ // eslint-disable-next-line max-len
+ else if (_.isUndefined(value) || _.isEmpty(value) || (_.isArray(value) && value.length === 0)) delete query[key];
+ else if (typeof value === 'object') {
+ const separator = query === '?' ? '' : '&';
+ query += `${separator}${qs.stringify({ tracks: value }, { encodeValuesOnly: true })}`;
+ } else {
+ const separator = query === '?' ? '' : '&';
+ query += `${separator}${key}=${value}`;
+ }
});
- query = `?${qs.stringify(query, { encodeValuesOnly: true })}`;
+ if (query === '?') {
+ if (filterArray.length > 0) {
+ query += `${filterArray.join('&')}`;
+ }
+ } else {
+ // eslint-disable-next-line no-lonely-if
+ if (filterArray.length > 0) {
+ query += `&${filterArray.join('&')}`;
+ }
+ }
if (hash) {
query += hash;
}
|