Sort players alphabetically

This commit is contained in:
Timothy Armes
2023-09-19 16:39:49 +02:00
parent 1509881d9b
commit 4d7a2ed151
+6 -3
View File
@@ -3,7 +3,7 @@
import { useState } from "react";
import { zodResolver } from "@hookform/resolvers/zod";
import { isEmpty } from "lodash";
import { isEmpty, sortBy } from "lodash";
import { useTranslations } from "next-intl";
import Link from "next/link";
import { FormProvider, useForm } from "react-hook-form";
@@ -54,10 +54,13 @@ export default function Elo() {
},
);
const playerOptions = (allResults ?? []).map((player) => ({
const playerOptions = sortBy(
(allResults ?? []).map((player) => ({
value: player.id,
label: player.name,
}));
})),
"label",
);
const form = useForm<FetchResultsFormValues>({
resolver: zodResolver(fetchTournamentResultsSchema),