Skip to content

Commit

Permalink
Merge pull request #4 from salvobonsma/compare-teams
Browse files Browse the repository at this point in the history
Compare teams
  • Loading branch information
salvobonsma authored Aug 25, 2024
2 parents 95a5bd0 + e3ec455 commit 02dde43
Show file tree
Hide file tree
Showing 8 changed files with 823 additions and 34 deletions.
14 changes: 12 additions & 2 deletions app/[eventId]/[teamNumber]/client-page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {zodResolver} from "@hookform/resolvers/zod";
import {useForm} from "react-hook-form";
import {Form, FormField, FormItem, FormMessage} from "@/components/ui/form";
import UpdateTeamData from "@/lib/database/update-team-data";
import {Loader2, MoreVertical, ScanEye} from "lucide-react";
import {ArrowLeftRight, Loader2, MoreVertical, ScanEye} from "lucide-react";
import {cn} from "@/lib/utils";
import KeyBindListener from "@/components/key-bind-listener";
import {Tooltip, TooltipContent, TooltipTrigger} from "@/components/ui/tooltip";
Expand Down Expand Up @@ -154,6 +154,12 @@ export default function ClientPage({
View Overview
</DropdownMenuItem>
</a>
<a href={`/${event.id}/overview/compare?a=${team.number}`}>
<DropdownMenuItem>
<ArrowLeftRight className="mr-2 h-4 w-4"/>
Compare
</DropdownMenuItem>
</a>
</DropdownMenuContent>
</DropdownMenu>
</div>
Expand Down Expand Up @@ -232,7 +238,11 @@ export default function ClientPage({
<h1 className={"mt"}>Statistics</h1>
<Separator/>
{statistics}
<EPAOverTime matches={matches} events={eventsList}/>
{
matches.length != 0 && (
<div className={"mt-sm"}><EPAOverTime matches={matches} events={eventsList}/></div>
)
}
<h1 className={"mt"}>Events</h1>
<Separator/>
{events}
Expand Down
64 changes: 35 additions & 29 deletions app/[eventId]/overview/[teamNumber]/client-page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import StatusBadge from "@/components/status-badge";
import {TeamStatus} from "@/lib/database/set-team-statues";
import RichTextarea from "@/components/rich-textarea";
import React, {ReactNode} from "react";
import {ArrowDown, ArrowUp, Edit, Minus, MoreVertical} from "lucide-react";
import {ArrowDown, ArrowLeftRight, ArrowUp, Edit, Minus, MoreVertical} from "lucide-react";
import {percentile, withOrdinalSuffix} from "@/lib/utils";
import {DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger} from "@/components/ui/dropdown-menu";
import {Button} from "@/components/ui/button";
Expand Down Expand Up @@ -47,33 +47,6 @@ export default function ClientPage({
<EventCard key={value.eventKey} event={value}/>
));

function epaValue(epa: number, deviation: number) {
let arrow;
let placement;
if (deviation > 0.2) {
arrow = (<ArrowUp className={"w-5 h-5 self-center"}/>);
placement = "Above";
} else if (deviation > -0.2) {
arrow = (<Minus className={"w-5 h-5 self-center"}/>);
placement = "Around";
} else {
arrow = (<ArrowDown className={"w-5 h-5 self-center"}/>);
placement = "Below";
}

return (
<QuickTooltip
trigger={
<div className={"flex gap-0.5"}>
<p>{epa.toFixed(1)}</p>
{arrow}
</div>
}
content={`${placement} average; ${withOrdinalSuffix((percentile(deviation) * 100))} percentile`}
/>
);
}

return (
<>
<Back link={`/${event.id}/overview#teams`} display={"Event Overview"}/>
Expand All @@ -95,6 +68,12 @@ export default function ClientPage({
Make Changes
</DropdownMenuItem>
</a>
<a href={`/${event.id}/overview/compare?a=${team.number}`}>
<DropdownMenuItem>
<ArrowLeftRight className="mr-2 h-4 w-4"/>
Compare
</DropdownMenuItem>
</a>
</DropdownMenuContent>
</DropdownMenu>
</div>
Expand Down Expand Up @@ -254,9 +233,9 @@ export default function ClientPage({
</div>
</CardContent>
</Card>
<EPAOverTime matches={matches} events={events}/>
</div>
)}
<EPAOverTime matches={matches} events={events}/>
<h1 className={"mt"}>Events</h1>
<Separator/>
{
Expand All @@ -283,4 +262,31 @@ export default function ClientPage({
{previousSeasons}
</>
);
}

export function epaValue(epa: number, deviation: number) {
let arrow;
let placement;
if (deviation > 0.2) {
arrow = (<ArrowUp className={"w-5 h-5 self-center"}/>);
placement = "Above";
} else if (deviation > -0.2) {
arrow = (<Minus className={"w-5 h-5 self-center"}/>);
placement = "Around";
} else {
arrow = (<ArrowDown className={"w-5 h-5 self-center"}/>);
placement = "Below";
}

return (
<QuickTooltip
trigger={
<div className={"flex gap-0.5"}>
<p>{epa.toFixed(1)}</p>
{arrow}
</div>
}
content={`${placement} average; ${withOrdinalSuffix((percentile(deviation) * 100))} percentile`}
/>
);
}
Loading

0 comments on commit 02dde43

Please sign in to comment.