Skip to content

feat: past challenges implementation #5070

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ exports[`Matches shallow shapshot 1 shapshot 1 1`] = `
expanding={false}
filterState={Object {}}
loadMoreActive={null}
loadMoreAll={null}
loadMoreMy={null}
loadMoreOnGoing={null}
loadMoreOpenForRegistration={null}
Expand Down Expand Up @@ -93,6 +94,7 @@ exports[`Matches shallow shapshot 2 shapshot 2 1`] = `
expanding={false}
filterState={Object {}}
loadMoreActive={null}
loadMoreAll={null}
loadMoreMy={null}
loadMoreOnGoing={null}
loadMoreOpenForRegistration={null}
Expand Down
33 changes: 33 additions & 0 deletions src/shared/actions/challenge-listing/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ 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
Expand Down Expand Up @@ -270,6 +274,31 @@ function getMyChallengesDone(uuid, page, backendFilter, tokenV3, 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;
}
const service = getService(tokenV3);
return service.getChallenges(filter).then(ch => ({
uuid,
allChallenges: ch.challenges,
meta: ch.meta,
frontFilter,
}));
}

function getTotalChallengesCountInit(uuid) {
return { uuid };
}
Expand Down Expand Up @@ -463,6 +492,7 @@ export default createActions({
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,
Expand All @@ -474,6 +504,9 @@ export default createActions({
// 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,

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export default function ChallengeFilters({
auth,
// isCardTypeSet,
isReviewOpportunitiesBucket,
activeBucket,
// saveFilter,
searchText,
selectCommunity,
Expand Down Expand Up @@ -170,6 +171,7 @@ export default function ChallengeFilters({
isAuth={isAuth}
auth={auth}
isReviewOpportunitiesBucket={isReviewOpportunitiesBucket}
activeBucket={activeBucket}
filterState={filterState}
onClose={() => setExpanded(false)}
// onSaveFilter={saveFilter}
Expand Down Expand Up @@ -211,6 +213,7 @@ ChallengeFilters.propTypes = {
communityFilters: PT.arrayOf(PT.shape()).isRequired,
communityName: PT.string,
defaultCommunityId: PT.string.isRequired,
activeBucket: PT.string.isRequired,
// challenges: PT.arrayOf(PT.shape()),
expanded: PT.bool.isRequired,
filterState: PT.shape().isRequired,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import Tooltip from 'components/Tooltip';
import { config, Link } from 'topcoder-react-utils';
import { COMPOSE, PRIORITY } from 'react-css-super-themr';
import { REVIEW_OPPORTUNITY_TYPES } from 'utils/tc';
import { isFilterEmpty } from 'utils/challenge-listing/buckets';
import { BUCKETS, isFilterEmpty } from 'utils/challenge-listing/buckets';
import CheckmarkIcon from './CheckmarkIcon';
import DateRangePicker from '../DateRangePicker';
import style from './style.scss';
Expand All @@ -49,6 +49,7 @@ export default function FiltersPanel({
isAuth,
auth,
isReviewOpportunitiesBucket,
activeBucket,
onClose,
// onSaveFilter,
selectCommunity,
Expand All @@ -66,6 +67,8 @@ export default function FiltersPanel({
_.intersection(visitorGroupIds, communityGroupIds).length,
);

const isAllBucket = activeBucket === BUCKETS.ALL;

const getLabel = (community) => {
const { communityName } = community;
if (!isAuth) {
Expand Down Expand Up @@ -304,6 +307,28 @@ export default function FiltersPanel({
</div>
) : null
}
{/* Only shown when the All Challenges bucket is selected */}
{ isAllBucket
? (
<div styleName="filter status">
<label htmlFor="status-select" styleName="left-label">
Status
<input type="hidden" />
</label>
<Select
placeholder="Select Status"
id="status-select"
onChange={(value) => {
const status = value;
setFilterState({ ..._.clone(filterState), status });
}}
options={['Active', 'Completed', 'All'].map(mapOps)}
simpleValue
value={filterState.status || 'Active'}
/>
</div>
) : null
}
<div styleName="filter dates hidetwomonthdatepicker">
<label htmlFor="date-range-picker-one-month">
Date range
Expand Down Expand Up @@ -412,6 +437,7 @@ FiltersPanel.propTypes = {
communityName: PT.string.isRequired,
})).isRequired,
defaultCommunityId: PT.string.isRequired,
activeBucket: PT.string.isRequired,
filterState: PT.shape().isRequired,
// challenges: PT.arrayOf(PT.shape()),
hidden: PT.bool,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}
}

Expand Down
24 changes: 21 additions & 3 deletions src/shared/components/challenge-listing/Listing/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,12 @@ function Listing({
auth,
allActiveChallengesLoaded,
allMyChallengesLoaded,
allChallengesLoaded,
allOpenForRegistrationChallengesLoaded,
challenges,
openForRegistrationChallenges,
myChallenges,
allChallenges,
// pastChallenges,
challengeTypes,
// userChallenges,
Expand All @@ -39,6 +41,8 @@ function Listing({
loadingReviewOpportunities,
loadingMyChallenges,
loadMoreMy,
loadingAllChallenges,
loadMoreAll,
loadingOpenForRegistrationChallenges,
loadMoreOpenForRegistration,
loadingOnGoingChallenges,
Expand Down Expand Up @@ -108,6 +112,12 @@ function Listing({
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;
}
Expand Down Expand Up @@ -199,14 +209,15 @@ function Listing({
|| loadingOpenForRegistrationChallenges
|| loadingOnGoingChallenges;
const placeholders = [];
if (challenges.length > 0) {
if (challenges.length > 0 || (activeBucket === BUCKETS.ALL && allChallenges.length > 0)) {
return (
<div styleName="challengeCardContainer">
{preListingMsg}
{(auth.user && myChallenges.length > 0) ? getBucket(BUCKETS.MY) : null}
{/* (auth.user && myChallenges.length > 0) ? getBucket(BUCKETS.MY) : null */}
{/* {extraBucket ? getBucket(extraBucket) : null} */}
{openForRegistrationChallenges.length > 0 && getBucket(BUCKETS.OPEN_FOR_REGISTRATION)}
{/* openForRegistrationChallenges.length > 0 && getBucket(BUCKETS.OPEN_FOR_REGISTRATION) */}
{/* {getBucket(BUCKETS.ONGOING)} */}
{getBucket(BUCKETS.ALL)}
</div>
);
}
Expand All @@ -233,6 +244,7 @@ Listing.defaultProps = {
challenges: [],
openForRegistrationChallenges: [],
myChallenges: [],
allChallenges: [],
// pastChallenges: [],
challengeTypes: [],
communityName: null,
Expand All @@ -244,6 +256,7 @@ Listing.defaultProps = {
// loadMorePast: null,
loadMoreReviewOpportunities: null,
loadMoreMy: null,
loadMoreAll: null,
loadMoreOpenForRegistration: null,
loadMoreOnGoing: null,
preListingMsg: null,
Expand All @@ -267,10 +280,12 @@ Listing.propTypes = {
}).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,
Expand All @@ -282,10 +297,12 @@ Listing.propTypes = {
keepPastPlaceholders: 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,
loadMoreMy: PT.func,
loadMoreAll: PT.func,
loadMoreOnGoing: PT.func,
loadMoreOpenForRegistration: PT.func,
// loadMorePast: PT.func,
Expand Down Expand Up @@ -313,6 +330,7 @@ const mapStateToProps = (state) => {
// allActiveChallengesLoaded: cl.allActiveChallengesLoaded,
allActiveChallengesLoaded: cl.allActiveChallengesLoaded,
allMyChallengesLoaded: cl.allMyChallengesLoaded,
allChallengesLoaded: cl.allChallengesLoaded,
allOpenForRegistrationChallengesLoaded: cl.allOpenForRegistrationChallengesLoaded,
// pastSearchTimestamp: cl.pastSearchTimestamp,
challengeTypes: cl.challengeTypes,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ function Bucket({
return (
<div styleName="active bucket">
{BUCKET_DATA[bucket].name}
{countEl}
{bucket !== BUCKETS.ALL && countEl}
{/* {error} */}
</div>
);
Expand All @@ -83,7 +83,7 @@ function Bucket({
tabIndex={0}
>
{BUCKET_DATA[bucket].name}
{countEl}
{bucket !== BUCKETS.ALL && countEl}
{/* {error} */}
</div>
);
Expand Down
8 changes: 8 additions & 0 deletions src/shared/components/challenge-listing/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export default function ChallengeListing(props) {
challenges,
openForRegistrationChallenges,
myChallenges,
allChallenges,
// pastChallenges,
// communityFilter,
communityName,
Expand Down Expand Up @@ -100,6 +101,7 @@ export default function ChallengeListing(props) {
challenges={challenges}
openForRegistrationChallenges={openForRegistrationChallenges}
myChallenges={myChallenges}
allChallenges={allChallenges}
// pastChallenges={pastChallenges}
challengesUrl={props.challengesUrl}
communityName={props.communityName}
Expand All @@ -110,10 +112,12 @@ export default function ChallengeListing(props) {
keepPastPlaceholders={keepPastPlaceholders}
// loadingPastChallenges={props.loadingPastChallenges}
loadingMyChallenges={props.loadingMyChallenges}
loadingAllChallenges={props.loadingAllChallenges}
loadingOpenForRegistrationChallenges={props.loadingOpenForRegistrationChallenges}
loadingOnGoingChallenges={props.loadingOnGoingChallenges}
loadingReviewOpportunities={props.loadingReviewOpportunities}
loadMoreMy={props.loadMoreMy}
loadMoreAll={props.loadMoreAll}
loadMoreOpenForRegistration={props.loadMoreOpenForRegistration}
loadMoreOnGoing={props.loadMoreOnGoing}
// loadMorePast={props.loadMorePast}
Expand Down Expand Up @@ -180,6 +184,7 @@ ChallengeListing.defaultProps = {
// extraBucket: null,
hideTcLinksInFooter: false,
loadMoreMy: null,
loadMoreAll: null,
loadMoreOpenForRegistration: null,
loadMoreOnGoing: null,
// loadMorePast: null,
Expand All @@ -203,6 +208,7 @@ ChallengeListing.propTypes = {
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(),
Expand All @@ -218,11 +224,13 @@ ChallengeListing.propTypes = {
// 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,
loadMoreMy: PT.func,
loadMoreAll: PT.func,
loadMoreOpenForRegistration: PT.func,
loadMoreOnGoing: PT.func,
// loadMorePast: PT.func,
Expand Down
1 change: 1 addition & 0 deletions src/shared/containers/challenge-listing/FilterPanel.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ export class Container extends React.Component {
}}
// isSavingFilter={isSavingFilter}
isReviewOpportunitiesBucket={isForReviewOpportunities}
activeBucket={activeBucket}
/>
);
}
Expand Down
Loading