Feat: Show startnumber and improove style
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Dorian Zedler 2022-07-29 13:31:00 +02:00
parent db4365351a
commit 62f9d3c5d9
Signed by: dorian
GPG key ID: 989DE36109AFA354
2 changed files with 87 additions and 25 deletions

View file

@ -5,6 +5,7 @@ export interface ParticipantFromApi {
PerId: string; PerId: string;
firstname: string; firstname: string;
lastname: string; lastname: string;
start_number: string;
result_rank?: number; result_rank?: number;
['result_rank0']?: string; ['result_rank0']?: string;
['result_rank1']?: string; ['result_rank1']?: string;
@ -21,6 +22,7 @@ export interface Participant {
lastName: string; lastName: string;
results: Result[]; results: Result[];
overallRank?: number; overallRank?: number;
startNumber: number;
} }
export interface Result { export interface Result {
@ -73,5 +75,6 @@ export function participantFromApiParticipant(
lastName: fromApi.lastname, lastName: fromApi.lastname,
results: results, results: results,
overallRank: fromApi.result_rank, overallRank: fromApi.result_rank,
startNumber: parseInt(fromApi.start_number),
}; };
} }

View file

@ -4,14 +4,19 @@ import { useParams } from 'react-router-dom';
import { import {
convertResultsToSpeedFlowchartResult, convertResultsToSpeedFlowchartResult,
SpeedFlowchartResult, SpeedFlowchartResult,
SpeedLane,
SpeedRoundPair, SpeedRoundPair,
} from '../data/SpeedFlowchart'; } from '../data/SpeedFlowchart';
import { Card, CardContent, Grid, Skeleton, Typography } from '@mui/material'; import {
Card,
CardContent,
Chip,
Grid,
Skeleton,
Typography,
} from '@mui/material';
import { theme } from '../utils/Theme'; import { theme } from '../utils/Theme';
import { QRCode } from 'react-qrcode-logo'; import { QRCode } from 'react-qrcode-logo';
import { bgcolor } from '@mui/system';
import '../css/SpeedFlowchartPage.css';
interface SpeedRoundPairDummy extends SpeedRoundPair { interface SpeedRoundPairDummy extends SpeedRoundPair {
dummy: boolean; dummy: boolean;
} }
@ -137,27 +142,81 @@ export default function SpeedFlowchartPage() {
: undefined, : undefined,
}} }}
> >
<CardContent> <CardContent
<Typography
sx={{ sx={{
fontWeight: pair.winner === 'A' ? 'bold' : 'plain', padding: '10px !important',
color: pair.winner === 'A' ? '#4CAF50' : '',
}} }}
> >
A: {pair.laneA?.participant.firstName}{' '} <Grid container spacing={2}>
{pair.laneA?.participant.lastName}:{' '} {[
{pair.laneA?.result?.result} ['A', pair.laneA],
['B', pair.laneB],
].map(([letter, lane]) => {
lane = lane as SpeedLane;
const textStyle = {
fontWeight:
pair.winner === letter ? 'bold' : 'plain',
color: pair.winner === letter ? '#4CAF50' : '',
fontSize: '25px',
};
const gridItemStyle = {
paddingTop:
letter === 'B' ? '0 !important' : undefined,
};
return (
<>
<Grid sx={gridItemStyle} xs={1} item>
<Typography sx={textStyle}>
{lane?.participant.results[0].rank}{' '}
</Typography> </Typography>
</Grid>
<Grid
sx={{ ...gridItemStyle, display: 'flex' }}
xs={8.5}
item
>
<Typography <Typography
sx={{ sx={{
fontWeight: pair.winner === 'B' ? 'bold' : 'plain', ...textStyle,
color: pair.winner === 'B' ? '#4CAF50' : '', overflow: 'clip',
whiteSpace: 'nowrap',
maxWidth: '80%',
textOverflow: 'ellipsis',
}} }}
> >
B: {pair.laneB?.participant.firstName}{' '} {lane?.participant.firstName}{' '}
{pair.laneB?.participant.lastName}:{' '} {lane?.participant.lastName}
{pair.laneB?.result?.result}
</Typography> </Typography>
<Chip
label={lane?.participant.startNumber}
sx={{
height: '26px',
marginLeft: '10px',
}}
variant='outlined'
/>
</Grid>
<Grid sx={gridItemStyle} xs={2} item>
<Typography sx={textStyle}>
{' '}
{lane?.result?.result}
</Typography>
</Grid>
{letter === 'A' && (
<Grid
xs={12}
item
sx={{ height: 0, paddingTop: '0 !important' }}
></Grid>
)}
</>
);
})}
</Grid>
</CardContent> </CardContent>
</Card> </Card>
</Grid> </Grid>