|
| 1 | +import React from 'react'; |
| 2 | + |
| 3 | +import cn from 'classnames'; |
| 4 | +import capitalize from 'lodash/capitalize'; |
| 5 | + |
| 6 | +import { getRankingPoints, getTasksCount, grades } from '@/config/grades'; |
| 7 | + |
| 8 | +const getGradeDescriptionClassName = highlight => ( |
| 9 | + cn( |
| 10 | + 'd-flex flex-column flex-lg-row flex-md-row flex-sm-row justify-content-between', |
| 11 | + { |
| 12 | + 'text-monospace': highlight, |
| 13 | + }, |
| 14 | + ) |
| 15 | +); |
| 16 | + |
| 17 | +const GradeInfo = ({ grade, selected }) => ( |
| 18 | + <div className={getGradeDescriptionClassName(grade === selected)}> |
| 19 | + <span className={grade === selected ? 'text-white' : ''}> |
| 20 | + {capitalize(grade)} |
| 21 | + {grade === selected && '(*)'} |
| 22 | + </span> |
| 23 | + <span className={cn('pl-3', { 'text-white': grade === selected })}> |
| 24 | + [ |
| 25 | + {getRankingPoints(grade).join(', ')} |
| 26 | + ] |
| 27 | + </span> |
| 28 | + </div> |
| 29 | +); |
| 30 | + |
| 31 | +const TournamentDescription = ({ |
| 32 | + className, |
| 33 | + tournament, |
| 34 | +}) => ( |
| 35 | + <div className={className}> |
| 36 | + {tournament.grade !== grades.open ? ( |
| 37 | + <> |
| 38 | + <span className="text-white">Tournament Highlights:</span> |
| 39 | + <div className="d-flex flex-column"> |
| 40 | + <span>Prizes: Codebattle T-shirt merch for a top-tier of League</span> |
| 41 | + <span>{`Challenges: ${getTasksCount(tournament.grade)} unique algorithm problems`}</span> |
| 42 | + <span>Impact: Advancing in the Codebattle programmer rankings</span> |
| 43 | + </div> |
| 44 | + <div className="d-flex justify-content-center w-100"> |
| 45 | + <div className="card cb-card mt-2"> |
| 46 | + <div className="card-header text-center">View League Ranking Points System</div> |
| 47 | + <div className="card-body"> |
| 48 | + {[grades.rookie, grades.challenger, grades.pro, grades.elite, grades.masters, grades.grandSlam].map(grade => ( |
| 49 | + <GradeInfo grade={grade} selected={tournament.grade} /> |
| 50 | + ))} |
| 51 | + </div> |
| 52 | + </div> |
| 53 | + </div> |
| 54 | + </> |
| 55 | + ) : ( |
| 56 | + <> |
| 57 | + <span className="text-white">Tournament Description:</span> |
| 58 | + {tournament.description} |
| 59 | + </> |
| 60 | + )} |
| 61 | + </div> |
| 62 | +); |
| 63 | + |
| 64 | +export default TournamentDescription; |
0 commit comments