Skip to content

Commit 7ba11ac

Browse files
committed
Sorting and filtering bugs
1 parent f7252f4 commit 7ba11ac

File tree

7 files changed

+30
-19
lines changed

7 files changed

+30
-19
lines changed

src/components/ChallengesComponent/ChallengeCard/index.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -95,16 +95,18 @@ const hoverComponents = (challenge, onUpdateLaunch, deleteModalLaunch) => {
9595
}
9696

9797
const renderStatus = (status, getStatusText) => {
98-
switch (status) {
98+
const statusMessage = status.split(' ')[0]
99+
switch (statusMessage) {
99100
case CHALLENGE_STATUS.ACTIVE:
100101
case CHALLENGE_STATUS.APPROVED:
101102
case CHALLENGE_STATUS.NEW:
102103
case CHALLENGE_STATUS.DRAFT:
103104
case CHALLENGE_STATUS.COMPLETED:
104-
const statusText = getStatusText ? getStatusText(status) : status
105-
return (<ChallengeStatus status={status} statusText={statusText} />)
105+
case CHALLENGE_STATUS.CANCELLED:
106+
const statusText = getStatusText ? getStatusText(statusMessage) : statusMessage
107+
return (<ChallengeStatus status={statusMessage} statusText={statusText} />)
106108
default:
107-
return (<span className={styles.statusText}>{statusText}</span>)
109+
return (<span className={styles.statusText}>{status}</span>)
108110
}
109111
}
110112

@@ -204,7 +206,7 @@ class ChallengeCard extends React.Component {
204206
const deleteMessage = isCheckChalengePermission
205207
? 'Checking permissions...'
206208
: `Do you want to delete "${challenge.name}"?`
207-
const directUrl = `${DIRECT_PROJECT_URL}/contest/detail?projectId=${challenge.legacyId}`
209+
const orUrl = `${ONLINE_REVIEW_URL}/review/actions/ViewProjectDetails?pid=${challenge.legacyId}`
208210
const communityAppUrl = `${COMMUNITY_APP_URL}/challenges/${challenge.id}`
209211

210212
return (
@@ -279,7 +281,7 @@ class ChallengeCard extends React.Component {
279281
{(disableHover ? <Link className={styles.link} to={`/projects/${challenge.projectId}/challenges/${challenge.id}/edit`}>Edit</Link> : hoverComponents(challenge, this.onUpdateLaunch, this.deleteModalLaunch))}
280282
</div>
281283
<div className={styles.col6}>
282-
<a className={styles.link} href={directUrl} target='_blank'>OR</a>
284+
<a className={styles.link} href={orUrl} target='_blank'>OR</a>
283285
</div>
284286
<div className={styles.col6}>
285287
<a className={styles.link} href={communityAppUrl} target='_blank'>CA</a>

src/components/ChallengesComponent/ChallengeList/index.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import PropTypes from 'prop-types'
77
import { DebounceInput } from 'react-debounce-input'
88
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
99
import { faFile, faUser } from '@fortawesome/free-solid-svg-icons'
10+
import isAfter from 'date-fns/isAfter'
1011
import DateTime from '@nateradebaugh/react-datetime'
1112
import Pagination from 'react-js-pagination'
1213
import cn from 'classnames'
@@ -298,19 +299,10 @@ class ChallengeList extends Component {
298299
value: _.capitalize(item)
299300
}))
300301

301-
statusOptions.unshift({
302-
label: 'All Challenge Status',
303-
value: null
304-
})
305-
306302
const challengeTypesOptions = challengeTypes.map(item => ({
307303
label: item.name,
308304
value: item.abbreviation
309305
}))
310-
challengeTypesOptions.unshift({
311-
label: 'All Challenge Types',
312-
value: null
313-
})
314306

315307
let selectedTab = 0
316308
switch (status) {
@@ -467,12 +459,13 @@ class ChallengeList extends Component {
467459
onChange={e =>
468460
this.updateSearchParam(
469461
searchText,
470-
e.value,
462+
e ? e.value : null,
471463
challengeType,
472464
challengeDate,
473465
projectOption
474466
)
475467
}
468+
isClearable
476469
/>
477470
</div>
478471
</div>
@@ -509,6 +502,9 @@ class ChallengeList extends Component {
509502
value={
510503
challengeDate.startDateEnd ? challengeDate.startDateEnd : null
511504
}
505+
isValidDate={(current) => {
506+
return isAfter(current, challengeDate.startDateStart)
507+
}}
512508
onChange={e =>
513509
this.updateSearchParam(
514510
searchText,
@@ -545,6 +541,7 @@ class ChallengeList extends Component {
545541
projectOption
546542
)
547543
}
544+
isClearable
548545
/>
549546
</div>
550547
</div>
@@ -580,6 +577,9 @@ class ChallengeList extends Component {
580577
value={
581578
challengeDate.endDateEnd ? challengeDate.endDateEnd : null
582579
}
580+
isValidDate={(current) => {
581+
return isAfter(current, challengeDate.endDateStart)
582+
}}
583583
onChange={e =>
584584
this.updateSearchParam(
585585
searchText,

src/components/ChallengesComponent/ChallengeStatus/ChallengeStatus.module.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,9 @@
3737
&.yellow {
3838
background-color: $status-yellow;
3939
}
40+
41+
&.red {
42+
background-color: $tc-red;
43+
}
4044
}
4145

src/components/ChallengesComponent/ChallengeStatus/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ const statuses = {
1515
[CHALLENGE_STATUS.APPROVED]: styles.yellow,
1616
[CHALLENGE_STATUS.NEW]: styles.yellow,
1717
[CHALLENGE_STATUS.DRAFT]: styles.gray,
18-
[CHALLENGE_STATUS.COMPLETED]: styles.blue
18+
[CHALLENGE_STATUS.COMPLETED]: styles.blue,
19+
[CHALLENGE_STATUS.CANCELLED]: styles.red
1920
}
2021

2122
const ChallengeStatus = ({ status, statusText }) => {

src/components/ChallengesComponent/ChallengeTag/ChallengeTag.module.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@ $corner-radius: 2px;
5858
background: $track-code-grey;
5959
}
6060

61+
&.MA {
62+
background: $track-code-grey;
63+
}
64+
6165
&.withTco {
6266
border-bottom-left-radius: 0;
6367
border-bottom-right-radius: 0;

src/components/ChallengesComponent/ChallengeTag/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export default function ChallengeTag ({
88
type, challengeTypes
99
}) {
1010
let abbreviation = getChallengeTypeAbbr(type, challengeTypes)
11-
if (['CH', 'F2F', 'TSK', 'MM', 'RDM', 'SKL', 'SRM', 'PC'].indexOf(abbreviation) < 0) {
11+
if (['CH', 'F2F', 'TSK', 'MM', 'RDM', 'SKL', 'MA', 'SRM', 'PC'].indexOf(abbreviation) < 0) {
1212
abbreviation = ''
1313
}
1414
return (

src/containers/Challenges/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ class Challenges extends Component {
5757
window.localStorage.setItem('projectLoading', 'true')
5858
this.props.loadProject(projectId)
5959
}
60-
this.reloadChallenges(this.props)
60+
this.reloadChallenges(this.props, true)
6161
}
6262
}
6363

0 commit comments

Comments
 (0)