From 78441459d644a0ae6c1d74683902f8e9099c3692 Mon Sep 17 00:00:00 2001 From: Owen Date: Fri, 12 Dec 2025 14:41:28 +0100 Subject: [PATCH] refactor elo array creation --- src/app/[locale]/(main)/match/MatchForm.tsx | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/app/[locale]/(main)/match/MatchForm.tsx b/src/app/[locale]/(main)/match/MatchForm.tsx index eda1d53..ef7384e 100644 --- a/src/app/[locale]/(main)/match/MatchForm.tsx +++ b/src/app/[locale]/(main)/match/MatchForm.tsx @@ -50,13 +50,14 @@ const MatchForm = ({ clubs }: IProps) => { return true; } - const team1Elos = team1Players - .filter((player) => player.elo !== "") - .map((player) => Number(player.elo?.split(" ")[0])); + function getEloArray(players: BoardPlayer[]) { + return players + .filter((player) => player.elo !== "") + .map((player) => Number(player.elo?.split(" ")[0])); + } - const team2Elos = team2Players - .filter((player) => player.elo !== "") - .map((player) => Number(player.elo?.split(" ")[0])); + const team1Elos = getEloArray(team1Players); + const team2Elos = getEloArray(team2Players); return !(!checkOrder(team1Elos) || !checkOrder(team2Elos)); };