style : fix chess com input
This commit is contained in:
@@ -19,7 +19,7 @@ export const getUserRecentGames = async (
|
|||||||
|
|
||||||
const games: ChessComGame[] = data?.games ?? [];
|
const games: ChessComGame[] = data?.games ?? [];
|
||||||
|
|
||||||
if (games.length < 20) {
|
if (games.length < 50) {
|
||||||
const previousMonth = month === 1 ? 12 : month - 1;
|
const previousMonth = month === 1 ? 12 : month - 1;
|
||||||
const previousPaddedMonth = getPaddedMonth(previousMonth);
|
const previousPaddedMonth = getPaddedMonth(previousMonth);
|
||||||
const yearToFetch = previousMonth === 12 ? year - 1 : year;
|
const yearToFetch = previousMonth === 12 ? year - 1 : year;
|
||||||
@@ -33,9 +33,9 @@ export const getUserRecentGames = async (
|
|||||||
games.push(...(dataPreviousMonth?.games ?? []));
|
games.push(...(dataPreviousMonth?.games ?? []));
|
||||||
}
|
}
|
||||||
|
|
||||||
games.sort((a, b) => {
|
const gamesToReturn = games.slice(0, 50).sort((a, b) => {
|
||||||
return b.end_time - a.end_time;
|
return b.end_time - a.end_time;
|
||||||
});
|
});
|
||||||
|
|
||||||
return games;
|
return gamesToReturn;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ export default function ChessComInput({ pgn, setPgn }: Props) {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<FormControl sx={{ m: 1, width: 300 }}>
|
<FormControl sx={{ m: 1, width: 600 }}>
|
||||||
<TextField
|
<TextField
|
||||||
label="Enter your Chess.com username..."
|
label="Enter your Chess.com username..."
|
||||||
variant="outlined"
|
variant="outlined"
|
||||||
@@ -56,38 +56,40 @@ export default function ChessComInput({ pgn, setPgn }: Props) {
|
|||||||
/>
|
/>
|
||||||
</FormControl>
|
</FormControl>
|
||||||
|
|
||||||
<Grid
|
{games.length > 0 && (
|
||||||
container
|
<Grid
|
||||||
item
|
container
|
||||||
xs={12}
|
item
|
||||||
gap={2}
|
xs={12}
|
||||||
justifyContent="center"
|
gap={2}
|
||||||
alignContent="center"
|
justifyContent="center"
|
||||||
>
|
alignContent="center"
|
||||||
{games.map((game) => (
|
>
|
||||||
<ListItemButton
|
{games.map((game) => (
|
||||||
onClick={() => setPgn(game.pgn)}
|
<ListItemButton
|
||||||
selected={pgn === game.pgn}
|
onClick={() => setPgn(game.pgn)}
|
||||||
style={{ width: 350, maxWidth: 350 }}
|
selected={pgn === game.pgn}
|
||||||
key={game.uuid}
|
style={{ width: 350, maxWidth: 350 }}
|
||||||
>
|
key={game.uuid}
|
||||||
<ListItemText
|
>
|
||||||
primary={`${capitalize(game.white.username) || "White"} (${
|
<ListItemText
|
||||||
game.white.rating || "?"
|
primary={`${capitalize(game.white.username) || "White"} (${
|
||||||
}) vs ${capitalize(game.black.username) || "Black"} (${
|
game.white.rating || "?"
|
||||||
game.black.rating || "?"
|
}) vs ${capitalize(game.black.username) || "Black"} (${
|
||||||
})`}
|
game.black.rating || "?"
|
||||||
secondary={`${capitalize(game.time_class)} played at ${new Date(
|
})`}
|
||||||
game.end_time * 1000
|
secondary={`${capitalize(game.time_class)} played at ${new Date(
|
||||||
)
|
game.end_time * 1000
|
||||||
.toLocaleString()
|
)
|
||||||
.slice(0, -3)}`}
|
.toLocaleString()
|
||||||
primaryTypographyProps={{ noWrap: true }}
|
.slice(0, -3)}`}
|
||||||
secondaryTypographyProps={{ noWrap: true }}
|
primaryTypographyProps={{ noWrap: true }}
|
||||||
/>
|
secondaryTypographyProps={{ noWrap: true }}
|
||||||
</ListItemButton>
|
/>
|
||||||
))}
|
</ListItemButton>
|
||||||
</Grid>
|
))}
|
||||||
|
</Grid>
|
||||||
|
)}
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user