Skip to content

Commit

Permalink
fix: 242 rules highscore request for current season fails (#326)
Browse files Browse the repository at this point in the history
Co-authored-by: Malin <[email protected]>
  • Loading branch information
wadholm and wadholm authored Oct 3, 2023
1 parent 90a5da7 commit c945304
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 55 deletions.
5 changes: 4 additions & 1 deletion packages/frontend/src/components/HighScoreTable.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
import { FC, memo } from 'react';
import { useHighScore } from '../hooks/useHighScore';
import { Spinner } from './Spinner';
import { Table } from './Table';

type HighScoreProps = {
seasonId: string;
};

export const HighScoreTable: FC<HighScoreProps> = memo((props) => {
const { seasonId } = props;

if (!seasonId) {
return <Spinner />;
}
const highscore = useHighScore(seasonId);
return (
<Table
Expand Down
22 changes: 9 additions & 13 deletions packages/frontend/src/components/SideMenu/SideMenu.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { BotGameObjectProperties } from '@etimo/diamonds2-types';
import React, { FC, memo, useState } from 'react';
import { useCurrentSeason } from '../../hooks/useCurrentSeason';
import useFetch from '../../hooks/useFetch';
import { BoardPicker } from '../BoardPicker';
import { HighScoreTable } from '../HighScoreTable';
import { PlayerTable } from '../PlayerTable';
Expand All @@ -15,11 +15,10 @@ type SideMenuProps = {

export const SideMenu: FC<SideMenuProps> = memo((props) => {
const { boardId, onBoardChange, bots } = props;
const currentSeason = useCurrentSeason();
const { response: currentSeason } = useFetch('api/seasons/current', '0');
const offSeasonId = '00000000-0000-0000-0000-000000000000';

const [seasonId, setSeasonId] = useState<string>(
'00000000-0000-0000-0000-000000000000',
);
const [seasonId, setSeasonId] = useState<string>(offSeasonId);
const [rulesVisible, setRulesVisible] = useState<boolean>(false);

const onSeasonChange = (event: React.ChangeEvent<HTMLSelectElement>) => {
Expand All @@ -30,6 +29,8 @@ export const SideMenu: FC<SideMenuProps> = memo((props) => {
setRulesVisible(false);
};

const selectedSeasonId = seasonId !== '0' ? seasonId : currentSeason.id;

return (
<div className="border border-gray-200 dark:border-slate-400 rounded-lg overflow-y-auto flex flex-col p-4">
<div className="mb-6">
Expand All @@ -41,10 +42,7 @@ export const SideMenu: FC<SideMenuProps> = memo((props) => {
</div>

<div className="my-6">
<SeasonPicker
seasonId={seasonId != '0' ? seasonId : currentSeason.id}
onChange={onSeasonChange}
/>
<SeasonPicker seasonId={selectedSeasonId} onChange={onSeasonChange} />

<div className="mt-2">
<button
Expand All @@ -57,15 +55,13 @@ export const SideMenu: FC<SideMenuProps> = memo((props) => {
</div>

<div>
<HighScoreTable
seasonId={seasonId != '0' ? seasonId : currentSeason.id}
/>
<HighScoreTable seasonId={selectedSeasonId} />
</div>

<Rules
onClose={closeRules}
visible={rulesVisible}
seasonId={seasonId != '0' ? seasonId : currentSeason.id}
seasonId={selectedSeasonId}
/>
</div>
);
Expand Down
11 changes: 5 additions & 6 deletions packages/frontend/src/components/Teams.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
import { ISeasonDto } from '@etimo/diamonds2-types';
import { ITeamDto } from '@etimo/diamonds2-types';
import useFetch from '../hooks/useFetch';
import useTeams from '../hooks/useTeams';
import { HighScoreTable } from './HighScoreTable';
import { MovingBot } from './MovingBot';
import { Table } from './Table';

export const Teams = () => {
const teams = useTeams();
const { response: currentSeason } = useFetch('api/seasons/current', '0') as {
response: ISeasonDto;
};
const teams: ITeamDto[] = useTeams();
const { response: currentSeason } = useFetch('api/seasons/current', '0');
const offSeasonId = '00000000-0000-0000-0000-000000000000';

return (
<>
Expand All @@ -28,7 +27,7 @@ export const Teams = () => {
})}
/>
</div>
<HighScoreTable seasonId={currentSeason.id} />
<HighScoreTable seasonId={currentSeason.id ?? offSeasonId} />
</div>
</div>
<div className="mt-20">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export const SparklesComponent: FC = () => {
<path
id="large"
d="M41.25,40 L42.5,10 L43.75,40 L45,41.25 L75,42.5 L45,43.75 L43.75,45 L42.5,75 L41.25,45 L40,43.75 L10,42.5 L40,41.25z"
fill="white"
fill="#badbff"
></path>
</g>
<g className="large-2" transform="rotate(45)">
Expand Down
23 changes: 0 additions & 23 deletions packages/frontend/src/hooks/useCurrentSeason.ts

This file was deleted.

12 changes: 1 addition & 11 deletions packages/frontend/src/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,6 @@
animation-timing-function: linear;
}

/* .sparkles {
transform: translate(-50%, -50%);
width: 70%;
} */

img.diamond {
max-width: 100%; /* Ensure the image fits within its container */
height: auto;
Expand All @@ -107,12 +102,7 @@ img.diamond {
width: 100%; /* Set the width to 100% to match the image width */
height: 100%; /* Set the height to 100% to match the image height */
pointer-events: none; /* Allow mouse events to pass through the sparkles */
z-index: 1; /* Ensure the sparkles appear above the image */
}

.star {
text-shadow: 0 0 white, -115px -75px white;
animation: shine 1.8s alternate linear infinite;
z-index: 2; /* Ensure the sparkles appear above the image */
}

svg#one {
Expand Down

0 comments on commit c945304

Please sign in to comment.