|
1 | 1 | import {
|
2 |
| - CrisisAlertOutlined, |
3 |
| - DescriptionOutlined, |
4 |
| - EmojiEventsOutlined, |
5 |
| - OutlinedFlagOutlined, |
6 | 2 | SlowMotionVideoOutlined,
|
7 |
| - SportsScoreOutlined, |
8 | 3 | VisibilityOutlined,
|
9 | 4 | } from '@mui/icons-material';
|
10 |
| -import { Avatar, Button, Card, CardContent, CardHeader, Chip, GridLegacy, IconButton, Tooltip } from '@mui/material'; |
| 5 | +import { Button, IconButton, Tooltip } from '@mui/material'; |
| 6 | +import { useTheme } from '@mui/material/styles'; |
11 | 7 | import { useContext } from 'react';
|
12 | 8 | import { Link } from 'react-router';
|
13 | 9 | import { makeStyles } from 'tss-react/mui';
|
14 | 10 |
|
15 | 11 | import Empty from '../../../../components/Empty';
|
16 |
| -import ExpandableMarkdown from '../../../../components/ExpandableMarkdown'; |
17 | 12 | import { useFormatter } from '../../../../components/i18n';
|
18 | 13 | import useSearchAnFilter from '../../../../utils/SortingFiltering';
|
19 | 14 | import { ChallengeContext } from '../Context';
|
| 15 | +import ChallengeCard from './ChallengeCard.js'; |
20 | 16 |
|
21 | 17 | const useStyles = makeStyles()(() => ({
|
22 | 18 | flag: {
|
@@ -45,6 +41,7 @@ const ContextualChallenges = ({ challenges, linkToInjects }) => {
|
45 | 41 | // Standard hooks
|
46 | 42 | const { classes } = useStyles();
|
47 | 43 | const { t } = useFormatter();
|
| 44 | + const theme = useTheme(); |
48 | 45 |
|
49 | 46 | // Context
|
50 | 47 | const { previewChallengeUrl } = useContext(ChallengeContext);
|
@@ -95,81 +92,14 @@ const ContextualChallenges = ({ challenges, linkToInjects }) => {
|
95 | 92 | )}
|
96 | 93 | />
|
97 | 94 | )}
|
98 |
| - <GridLegacy container={true} spacing={3}> |
99 |
| - {sortedChallenges.map((challenge, index) => { |
100 |
| - return ( |
101 |
| - <GridLegacy key={challenge.challenge_id} item={true} xs={4} style={index < 3 ? { paddingTop: 0 } : undefined}> |
102 |
| - <Card |
103 |
| - variant="outlined" |
104 |
| - classes={{ root: classes.card }} |
105 |
| - sx={{ |
106 |
| - width: '100%', |
107 |
| - height: '100%', |
108 |
| - }} |
109 |
| - > |
110 |
| - <CardHeader |
111 |
| - avatar={( |
112 |
| - <Avatar sx={{ bgcolor: '#e91e63' }}> |
113 |
| - <EmojiEventsOutlined /> |
114 |
| - </Avatar> |
115 |
| - )} |
116 |
| - title={challenge.challenge_name} |
117 |
| - subheader={challenge.challenge_category} |
118 |
| - /> |
119 |
| - <CardContent style={{ margin: '-20px 0 30px 0' }}> |
120 |
| - <ExpandableMarkdown |
121 |
| - source={challenge.challenge_content} |
122 |
| - limit={500} |
123 |
| - controlled={true} |
124 |
| - /> |
125 |
| - <div className={classes.footer}> |
126 |
| - <div style={{ float: 'left' }}> |
127 |
| - {challenge.challenge_flags.map((flag) => { |
128 |
| - return ( |
129 |
| - <Tooltip |
130 |
| - key={flag.flag_id} |
131 |
| - title={t(flag.flag_type)} |
132 |
| - > |
133 |
| - <Chip |
134 |
| - icon={<OutlinedFlagOutlined />} |
135 |
| - classes={{ root: classes.flag }} |
136 |
| - variant="outlined" |
137 |
| - label={t(flag.flag_type)} |
138 |
| - /> |
139 |
| - </Tooltip> |
140 |
| - ); |
141 |
| - })} |
142 |
| - </div> |
143 |
| - <div style={{ float: 'right' }}> |
144 |
| - <Button |
145 |
| - size="small" |
146 |
| - startIcon={<SportsScoreOutlined />} |
147 |
| - className={classes.button} |
148 |
| - > |
149 |
| - {challenge.challenge_score || 0} |
150 |
| - </Button> |
151 |
| - <Button |
152 |
| - size="small" |
153 |
| - startIcon={<CrisisAlertOutlined />} |
154 |
| - className={classes.button} |
155 |
| - > |
156 |
| - {challenge.challenge_max_attempts || 0} |
157 |
| - </Button> |
158 |
| - <Button |
159 |
| - size="small" |
160 |
| - startIcon={<DescriptionOutlined />} |
161 |
| - className={classes.button} |
162 |
| - > |
163 |
| - {challenge.challenge_documents.length || 0} |
164 |
| - </Button> |
165 |
| - </div> |
166 |
| - </div> |
167 |
| - </CardContent> |
168 |
| - </Card> |
169 |
| - </GridLegacy> |
170 |
| - ); |
171 |
| - })} |
172 |
| - </GridLegacy> |
| 95 | + <div style={{ |
| 96 | + display: 'grid', |
| 97 | + gridTemplateColumns: '1fr 1fr 1fr', |
| 98 | + gap: theme.spacing(3), |
| 99 | + }} |
| 100 | + > |
| 101 | + {sortedChallenges.map(challenge => <ChallengeCard showTags key={challenge.challenge_id} challenge={challenge} />)} |
| 102 | + </div> |
173 | 103 | </>
|
174 | 104 | );
|
175 | 105 | };
|
|
0 commit comments