Skip to content

Commit

Permalink
fix: team logotype on highscore list
Browse files Browse the repository at this point in the history
  • Loading branch information
ForsbergPhilip committed Nov 15, 2024
1 parent 797683a commit 36ded8f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
18 changes: 12 additions & 6 deletions packages/frontend/src/components/HighScoreTable.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { IHighscoreDto } from '@etimo/diamonds2-types';
import { FC, memo } from 'react';
import { useHighScore } from '../hooks/useHighScore';
import { Spinner } from './Spinner';
Expand All @@ -9,6 +10,16 @@ type HighScoreProps = {
export const HighScoreTable: FC<HighScoreProps> = memo((props) => {
const { seasonId } = props;

const logotype = (item: IHighscoreDto) => {
if (item.teamLogotype) {
return <img src={item.teamLogotype} alt="school-logo" />;
}
if (item.team) {
return item.team;
}
return '';
};

if (!seasonId) {
return <Spinner />;
}
Expand All @@ -20,12 +31,7 @@ export const HighScoreTable: FC<HighScoreProps> = memo((props) => {
data={highscore.map((item) => {
return {
name: item.botName,
team:
item.teamLogotype !== '' ? (
<img src={item.teamLogotype} alt="school-logo" />
) : (
item.team
),
team: logotype(item),
score: item.score,
};
})}
Expand Down
2 changes: 1 addition & 1 deletion packages/types/src/dto/highscore-dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ export interface IHighscoreDto {
score: number;
seasonId: string;
team: string | null;
teamLogotype: string;
teamLogotype: string | null;
}

0 comments on commit 36ded8f

Please sign in to comment.