nvm
This commit is contained in:
parent
62b61630c9
commit
0b4d96402a
|
@ -1,4 +1,4 @@
|
||||||
import { useMemo, useState } from "react";
|
import { useState } from "react";
|
||||||
|
|
||||||
export function County({ county }) {
|
export function County({ county }) {
|
||||||
const [sort, setSort] = useState({
|
const [sort, setSort] = useState({
|
||||||
|
@ -6,31 +6,6 @@ export function County({ county }) {
|
||||||
type: "desc",
|
type: "desc",
|
||||||
});
|
});
|
||||||
|
|
||||||
const sortMemo = useMemo(
|
|
||||||
() =>
|
|
||||||
county.players.sort((a, b) => {
|
|
||||||
if (sort.field === "rank")
|
|
||||||
return sort.type === "desc"
|
|
||||||
? parseInt(a.rank) - parseInt(b.rank)
|
|
||||||
: parseInt(b.rank) - parseInt(a.rank);
|
|
||||||
if (sort.field === "score")
|
|
||||||
return sort.type === "desc" ? a.score - b.score : b.score - a.score;
|
|
||||||
if (sort.field === "SS")
|
|
||||||
return sort.type === "desc"
|
|
||||||
? a.SSranks - b.SSranks
|
|
||||||
: b.SSranks - a.SSranks;
|
|
||||||
if (sort.field === "S")
|
|
||||||
return sort.type === "desc"
|
|
||||||
? a.Sranks - b.Sranks
|
|
||||||
: b.Sranks - a.Sranks;
|
|
||||||
if (sort.field === "A")
|
|
||||||
return sort.type === "desc"
|
|
||||||
? a.Aranks - b.Aranks
|
|
||||||
: b.Aranks - a.Aranks;
|
|
||||||
}),
|
|
||||||
[sort.field, sort.type, county.players]
|
|
||||||
);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<li
|
<li
|
||||||
className="mx-0 my-4 flex w-full max-w-3xl flex-shrink-0 flex-col space-y-4 overflow-auto
|
className="mx-0 my-4 flex w-full max-w-3xl flex-shrink-0 flex-col space-y-4 overflow-auto
|
||||||
|
@ -152,41 +127,64 @@ export function County({ county }) {
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{sortMemo.map((player, index) => (
|
{county.players
|
||||||
<tr
|
.sort((a, b) => {
|
||||||
key={player.id}
|
if (sort.field === "rank")
|
||||||
className="divide-x-2 divide-ctp-surface0 border border-ctp-surface2 odd:bg-ctp-crust even:bg-ctp-mantle"
|
return sort.type === "desc"
|
||||||
>
|
? parseInt(a.rank) - parseInt(b.rank)
|
||||||
<td className="whitespace-nowrap p-2 font-bold text-ctp-subtext1">
|
: parseInt(b.rank) - parseInt(a.rank);
|
||||||
{index + 1}.
|
if (sort.field === "score")
|
||||||
</td>
|
return sort.type === "desc"
|
||||||
<td className="whitespace-nowrap p-2 text-ctp-subtext1">
|
? a.score - b.score
|
||||||
<a
|
: b.score - a.score;
|
||||||
className="text-ctp-subtext1 hover:text-ctp-text hover:underline"
|
if (sort.field === "SS")
|
||||||
href={`https://osu.ppy.sh/u/${player.playerName}`}
|
return sort.type === "desc"
|
||||||
referrerPolicy="no-referrer"
|
? a.SSranks - b.SSranks
|
||||||
target="_blank"
|
: b.SSranks - a.SSranks;
|
||||||
>
|
if (sort.field === "S")
|
||||||
{player.playerName}
|
return sort.type === "desc"
|
||||||
</a>
|
? a.Sranks - b.Sranks
|
||||||
</td>
|
: b.Sranks - a.Sranks;
|
||||||
<td className="whitespace-nowrap p-2 text-ctp-subtext1">
|
if (sort.field === "A")
|
||||||
{player.rank ? `#${player.rank}` : "-"}
|
return sort.type === "desc"
|
||||||
</td>
|
? a.Aranks - b.Aranks
|
||||||
<td className="whitespace-nowrap p-2 tracking-wide text-ctp-subtext1">
|
: b.Aranks - a.Aranks;
|
||||||
{new Intl.NumberFormat().format(player.score)}
|
})
|
||||||
</td>
|
.map((player, index) => (
|
||||||
<td className="whitespace-nowrap p-2 text-ctp-subtext1">
|
<tr
|
||||||
{player.SSranks}
|
key={player.id}
|
||||||
</td>
|
className="divide-x-2 divide-ctp-surface0 border border-ctp-surface2 odd:bg-ctp-crust even:bg-ctp-mantle"
|
||||||
<td className="whitespace-nowrap p-2 text-ctp-subtext1">
|
>
|
||||||
{player.Sranks}
|
<td className="whitespace-nowrap p-2 font-bold text-ctp-subtext1">
|
||||||
</td>
|
{index + 1}.
|
||||||
<td className="whitespace-nowrap p-2 text-ctp-subtext1">
|
</td>
|
||||||
{player.Aranks}
|
<td className="whitespace-nowrap p-2 text-ctp-subtext1">
|
||||||
</td>
|
<a
|
||||||
</tr>
|
className="text-ctp-subtext1 hover:text-ctp-text hover:underline"
|
||||||
))}
|
href={`https://osu.ppy.sh/u/${player.playerName}`}
|
||||||
|
referrerPolicy="no-referrer"
|
||||||
|
target="_blank"
|
||||||
|
>
|
||||||
|
{player.playerName}
|
||||||
|
</a>
|
||||||
|
</td>
|
||||||
|
<td className="whitespace-nowrap p-2 text-ctp-subtext1">
|
||||||
|
{player.rank ? `#${player.rank}` : "-"}
|
||||||
|
</td>
|
||||||
|
<td className="whitespace-nowrap p-2 tracking-wide text-ctp-subtext1">
|
||||||
|
{new Intl.NumberFormat().format(player.score)}
|
||||||
|
</td>
|
||||||
|
<td className="whitespace-nowrap p-2 text-ctp-subtext1">
|
||||||
|
{player.SSranks}
|
||||||
|
</td>
|
||||||
|
<td className="whitespace-nowrap p-2 text-ctp-subtext1">
|
||||||
|
{player.Sranks}
|
||||||
|
</td>
|
||||||
|
<td className="whitespace-nowrap p-2 text-ctp-subtext1">
|
||||||
|
{player.Aranks}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
))}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
) : (
|
) : (
|
||||||
|
|
Loading…
Reference in New Issue