more optimizations

This commit is contained in:
yohlo
2025-08-27 11:04:04 -05:00
parent e5f3bbe095
commit b7de2e7af3
7 changed files with 49 additions and 23 deletions

View File

@@ -2,6 +2,7 @@ import { List, ListItem, Skeleton, Text } from "@mantine/core";
import { useNavigate } from "@tanstack/react-router";
import Avatar from "@/components/avatar";
import { Player } from "@/features/players/types";
import { useCallback } from "react";
interface PlayerListProps {
players: Player[];
@@ -10,6 +11,9 @@ interface PlayerListProps {
const PlayerList = ({ players, loading = false }: PlayerListProps) => {
const navigate = useNavigate();
const handleClick = useCallback((playerId: string) =>
navigate({ to: `/profile/${playerId} `}), [navigate]);
if (loading) return <List>
{Array.from({ length: 10 }).map((_, i) => (
@@ -27,9 +31,7 @@ const PlayerList = ({ players, loading = false }: PlayerListProps) => {
py='xs'
icon={<Avatar size={40} name={`${player.first_name} ${player.last_name}`} />}
style={{ cursor: 'pointer' }}
onClick={() => {
navigate({ to: `/profile/${player.id}` });
}}
onClick={() => handleClick(player.id)}
>
<Text fw={500}>{`${player.first_name} ${player.last_name}`}</Text>
</ListItem>