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

@@ -11,6 +11,7 @@ import { logger } from "..";
import { useQueryClient } from "@tanstack/react-query";
import { tournamentQueries } from "@/features/tournaments/queries";
import { DateTimePicker } from "@mantine/dates";
import { useCallback } from "react";
interface TournamentFormProps {
close: () => void;
@@ -48,7 +49,7 @@ const TournamentForm = ({ close, initialValues, tournamentId }: TournamentFormPr
const isPending = createPending || updatePending;
const handleSubmit = async (values: TournamentFormInput) => {
const handleSubmit = useCallback(async (values: TournamentFormInput) => {
const { logo, ...tournamentData } = values;
const mutation = isEditMode ? updateTournament : createTournament;
@@ -100,7 +101,7 @@ const TournamentForm = ({ close, initialValues, tournamentId }: TournamentFormPr
logger.error(`Tournament ${isEditMode ? 'update' : 'create'} error`, error);
}
});
}
}, [isEditMode, createTournament, updateTournament, queryClient]);
return (
<SlidePanel

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 { Tournament } from "../types";
import { useCallback } from "react";
interface TournamentListProps {
tournaments: Tournament[];
@@ -10,6 +11,9 @@ interface TournamentListProps {
const TournamentList = ({ tournaments, loading = false }: TournamentListProps) => {
const navigate = useNavigate();
const handleClick = useCallback((tournamentId: string) =>
navigate({ to: `/tournaments/${tournamentId}` }), [navigate]);
if (loading) return <List>
{Array.from({ length: 10 }).map((_, i) => (
@@ -27,9 +31,7 @@ const TournamentList = ({ tournaments, loading = false }: TournamentListProps) =
py='xs'
icon={<Avatar radius='xs' size={40} name={`${tournament.name}`} src={`/api/files/tournaments/${tournament.id}/${tournament.logo}`} />}
style={{ cursor: 'pointer' }}
onClick={() => {
navigate({ to: `/tournaments/${tournament.id}` });
}}
onClick={() => handleClick(tournament.id)}
>
<Text fw={500}>{`${tournament.name}`}</Text>
</ListItem>