update page switch log
All checks were successful
deploy / deploy (push) Successful in 1m2s

This commit is contained in:
Lee 2023-10-22 03:37:37 +01:00
parent 59fbad3b7c
commit a54b3d64fe
2 changed files with 11 additions and 19 deletions

@ -21,10 +21,17 @@ type PlayerInfo = {
const DEFAULT_SORT_TYPE = SortTypes.top;
export default function Player({ params }: { params: { id: string } }) {
const [mounted, setMounted] = useState(false);
const searchParams = useSearchParams();
const [mounted, setMounted] = useState(false);
const [error, setError] = useState(false);
const [errorMessage, setErrorMessage] = useState("");
const [player, setPlayer] = useState<PlayerInfo>({
loading: true,
player: undefined,
});
let page;
const pageString = searchParams.get("page");
if (pageString == null) {
@ -42,23 +49,8 @@ export default function Player({ params }: { params: { id: string } }) {
sortType = SortTypes[sortTypeString] || DEFAULT_SORT_TYPE;
}
const [error, setError] = useState(false);
const [errorMessage, setErrorMessage] = useState("");
const [player, setPlayer] = useState<PlayerInfo>({
loading: true,
player: undefined,
});
useEffect(() => {
setMounted(true);
if (!params.id) {
setError(true);
setErrorMessage("No player id");
setPlayer({ ...player, loading: false });
return;
}
if (error || !player.loading) {
return;
}
@ -70,7 +62,7 @@ export default function Player({ params }: { params: { id: string } }) {
getPlayerInfo(params.id).then((playerResponse) => {
if (!playerResponse) {
setError(true);
setErrorMessage("Failed to fetch player");
setErrorMessage("Failed to fetch player. Is the ID correct?");
setPlayer({ ...player, loading: false });
return;
}

@ -42,7 +42,7 @@ export default function Scores({ playerData, page, sortType }: ScoresProps) {
const updateScoresPage = useCallback(
(sortType: SortType, page: any) => {
console.log("Switching page to", page);
console.log(`Switching page to ${page} with sort ${sortType.value}`);
fetchScores(playerId, page, sortType.value, 10).then((scoresResponse) => {
if (!scoresResponse) {
setError(true);