Skip to content

Commit

Permalink
Merge pull request #26 from RoBorregos/upload/team_data
Browse files Browse the repository at this point in the history
Upload/team data and stuff
  • Loading branch information
Oscar-gg authored Nov 2, 2024
2 parents cdb35bf + c47d434 commit 645979f
Show file tree
Hide file tree
Showing 18 changed files with 269 additions and 13 deletions.
7 changes: 7 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"@trpc/server": "^11.0.0-rc.446",
"class-variance-authority": "^0.7.0",
"clsx": "^2.1.1",
"csv-parse": "^5.5.6",
"formik": "^2.4.6",
"framer-motion": "^11.11.10",
"geist": "^1.3.0",
Expand Down
10 changes: 5 additions & 5 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -164,14 +164,14 @@ model ChallengeC {
team Team @relation(fields: [teamId], references: [id], onDelete: Cascade)
}

model config {
id Int @id @default(autoincrement())
freeze Boolean @default(true)
}

enum Role {
CONTESTANT
JUDGE
ADMIN
UNASSIGNED
}

model config {
id Int @id @default(autoincrement())
freeze Boolean @default(true)
}
24 changes: 24 additions & 0 deletions public/schedule.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
Nombre, R1_PistaA,R1_PistaB,R1_PistaC,R2_PistaA,R2_PistaB,R2_PistaC,R3_PistaA,R3_PistaB,R3_PistaC
Circuitbreakers,10:45,11:40,12:35,2:36,3:31,4:26,5:03,5:58,6:53
Las chichas superponedoras,12:35,10:45,11:40,4:26,2:36,3:31,6:53,5:03,5:58
Equestria Kids,11:40,12:35,10:45,3:31,4:26,2:36,5:58,6:53,5:03
Robotertulia,10:51,11:46,12:41,2:42,3:37,4:32,5:09,6:04,6:59
S. E. E. S.,12:41,10:51,11:46,4:32,2:42,3:37,6:59,5:09,6:04
La Mera Trompa del Tren,11:46,12:41,10:51,3:37,4:32,2:42,6:04,6:59,5:09
Syntax Algodones,10:57,11:52,12:47,2:48,3:43,4:38,5:15,6:10,7:05
Equipo 3,12:47,10:57,11:52,4:38,2:48,3:43,7:05,5:15,6:10
REBE,11:58,12:53,11:03,2:55,3:50,2:00,6:16,7:11,5:21
Atomix,11:09,12:04,12:59,2:06,3:01,3:56,5:27,6:22,7:17
Pollos Locos,12:59,11:09,12:04,3:56,2:06,3:01,7:17,5:27,6:22
JED,12:10,13:05,11:09,3:07,4:02,2:12,6:28,7:23,5:33
Spacekats ,11:15,12:10,13:05,2:12,3:07,4:02,5:33,6:28,7:23
The Best Team !,13:05,11:15,12:10,4:02,2:12,3:07,7:23,5:33,6:28
Tunas Terrier ,12:16,13:11,11:15,3:13,4:08,2:18,5:40,6:35,4:45
Capibot,11:21,12:16,13:11,2:18,3:13,4:08,4:45,5:40,6:35
Los mecxnicos del norte,13:11,11:21,12:16,4:08,2:18,3:13,6:35,4:45,5:40
Robonautas,12:22,13:17,11:21,3:19,4:14,2:24,5:46,6:41,4:51
Forexos,11:27,12:22,13:17,2:24,3:19,4:14,4:51,5:46,6:41
Paftron 3,13:17,11:27,12:22,4:14,2:24,3:19,6:41,4:51,5:46
Borregos Tim,12:28,13:23,11:27,3:25,4:20,2:30,5:52,6:47,4:57
MAZE,11:33,12:28,13:23,2:30,3:25,4:20,4:57,5:52,6:47
ByteBites,13:23,11:33,12:28,4:20,2:30,3:25,6:47,4:57,5:52
2 changes: 2 additions & 0 deletions public/test.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Nombre, R1_PistaA,R1_PistaB,R1_PistaC,R2_PistaA,R2_PistaB,R2_PistaC,R3_PistaA,R3_PistaB,R3_PistaC
RoBorregos,10:45,11:40,12:35,2:36,3:31,4:26,5:03,5:58,6:53
16 changes: 16 additions & 0 deletions src/app/_components/navDropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
SheetTitle,
SheetTrigger,
} from "r/components/ui/sheet";
import { Role } from "@prisma/client";

export default function NavDropdown({ session }: { session: Session | null }) {
return (
Expand Down Expand Up @@ -45,6 +46,21 @@ export default function NavDropdown({ session }: { session: Session | null }) {
Team
</Link>
</div>
{(session?.user.role === Role.ADMIN ||
session?.user.role === Role.JUDGE) && (
<div>
<Link href="/judge" className="w-full text-center text-lg">
Judge
</Link>
</div>
)}
{session?.user.role === Role.ADMIN && (
<div>
<Link href="/admin" className="w-full text-center text-lg">
Admin
</Link>
</div>
)}
<div>
<Link
href="https://www.roborregos.com"
Expand Down
3 changes: 2 additions & 1 deletion src/app/_components/navbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ export default async function Navbar() {
<Link href="/">Home</Link>
<Link href="scoreboard">Scoreboard</Link>
<Link href="team">Team</Link>
<Link href="https://www.roborregos.com">About us</Link>
{canJudge && <Link href="judge">Judge</Link>}
{session?.user.role === Role.ADMIN && <Link href="admin">Admin</Link>}
<Link href="https://www.roborregos.com">About us</Link>
</div>
<div className="hidden lg:block">
<SignInButton session={session} />
Expand Down
14 changes: 14 additions & 0 deletions src/app/admin/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { Role } from "@prisma/client";
import { redirect } from "next/navigation";
import { getServerAuthSession } from "rbrgs/server/auth";

export default async function RootLayout({
children,
}: Readonly<{ children: React.ReactNode }>) {
const session = await getServerAuthSession();

if (session?.user.role !== Role.ADMIN) {
redirect("/");
}
return children;
}
35 changes: 35 additions & 0 deletions src/app/admin/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
"use client";

import Header from "rbrgs/app/_components/header";

import { api } from "~/trpc/react";
import { toast } from "sonner";

export default function AdminPage() {
const createEvaluation = api.admin.uploadTeamData.useMutation({
onSuccess() {
toast("Data uploaded.");
},
onError(error) {
toast("Error. Check console");
console.error(error);
},
});
return (
<main className="mt-[4rem] h-96 bg-black text-sm text-white md:text-base">
<div className="md:pb-20">
<Header title="Admin" subtitle="" />
</div>
<div className="p-2">
<button
onClick={() => {
createEvaluation.mutate();
}}
className="mt-9 rounded-lg bg-roboblue p-2"
>
Upload team data
</button>
</div>
</main>
);
}
2 changes: 1 addition & 1 deletion src/app/forms/FormChallengeA.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ export const FormChallengeA = () => {
name="genericFormSchema.roundId"
render={({ field }) => (
<FormItem>
<FormLabel>Round ID</FormLabel>
<FormLabel>Round Number (1, 2, or 3)</FormLabel>
<FormControl>
<Input type="string" {...field} />
</FormControl>
Expand Down
2 changes: 1 addition & 1 deletion src/app/forms/FormChallengeB.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ export const FormChallengeB = () => {
name="genericFormSchema.roundId"
render={({ field }) => (
<FormItem>
<FormLabel>Round ID</FormLabel>
<FormLabel>Round Number (1, 2, or 3)</FormLabel>
<FormControl>
<Input type="string" {...field} />
</FormControl>
Expand Down
2 changes: 1 addition & 1 deletion src/app/forms/FormChallengeC.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ export const FormChallengeC = () => {
name="genericFormSchema.roundId"
render={({ field }) => (
<FormItem>
<FormLabel>Round ID</FormLabel>
<FormLabel>Round Number (1, 2, or 3)</FormLabel>
<FormControl>
<Input type="string" {...field} />
</FormControl>
Expand Down
9 changes: 9 additions & 0 deletions src/app/judge/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
"use client";

import { SessionProvider } from "next-auth/react";

export default function RootLayout({
children,
}: Readonly<{ children: React.ReactNode }>) {
return <SessionProvider>{children}</SessionProvider>;
}
22 changes: 22 additions & 0 deletions src/app/judge/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,32 @@ import Header from "rbrgs/app/_components/header";
import { useState } from "react";
import { FormChallengeB } from "../forms/FormChallengeB";
import { FormChallengeC } from "../forms/FormChallengeC";
import { useSession } from "next-auth/react";
import { Role } from "@prisma/client";

export default function JudgePage() {
const [selected, setSelected] = useState("Sin seleccionar");

const session = useSession();

if (
session.data?.user?.role !== Role.ADMIN &&
session.data?.user?.role !== Role.JUDGE
) {
return (
<main className="mt-[4rem] h-96 bg-black text-sm text-white md:text-base">
<div className="md:pb-20">
<Header title="Judge" subtitle="" />
</div>
<div className="p-2">
<h1 className="mb-5 text-center text-4xl">
You don&apos;t have permission to access this page.
</h1>
</div>
</main>
);
}

return (
<main className="mt-[4rem] h-96 bg-black text-sm text-white md:text-base">
<div className="md:pb-20">
Expand Down
18 changes: 15 additions & 3 deletions src/app/scoreboard/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,25 @@ const TwitchEmbed = ({ channel }: { channel: string }) => (
);

export default function ScoreboardPage() {
const { data: scores, isLoading } = api.scoreboard.getScoreboard.useQuery();
const {
data: scores,
isLoading,
refetch,
} = api.scoreboard.getScoreboard.useQuery();

const { data: isFrozen } = api.scoreboard.isScoreboardFrozen.useQuery();

React.useEffect(() => {
const interval = setInterval(() => {
refetch().catch(console.error);
}, 20000);
return () => clearInterval(interval);
}, [refetch]);

return (
<div className="mt-[4rem] h-96 bg-black text-sm text-white md:text-base">
<Header title="Scoreboard" />
<div className="scrollbar-thin scrollbar-thumb-roboblue scrollbar-track-gray-700 container mx-auto overflow-x-scroll p-4">
<div className="container mx-auto overflow-x-scroll p-4 scrollbar-thin scrollbar-track-gray-700 scrollbar-thumb-roboblue">
<div className="grid gap-4 md:grid-cols-2">
{/* Stream section */}
<div className="w-full">
Expand Down Expand Up @@ -68,7 +80,7 @@ export default function ScoreboardPage() {

<Title title="General" />

<div className="scrollbar-thin scrollbar-thumb-roboblue scrollbar-track-gray-700 mx-auto w-full max-w-7xl overflow-x-auto px-4">
<div className="mx-auto w-full max-w-7xl overflow-x-auto px-4 scrollbar-thin scrollbar-track-gray-700 scrollbar-thumb-roboblue">
<table className="min-w-full border-collapse text-white">
<colgroup>
<col />
Expand Down
2 changes: 1 addition & 1 deletion src/lib/schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export const genericDataSchema = z.object({
lackOfProgress: z.coerce.number().int().min(0, {
message: "La falta de progreso tiene que ser mayor o igual a 0",
}),
roundId: z.string().min(1),
roundId: z.enum(["1", "2", "3"]),
teamId: z.string().min(1),
});

Expand Down
2 changes: 2 additions & 0 deletions src/server/api/root.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { rolesRouter } from "rbrgs/server/api/routers/roles";
import { teamRouter } from "rbrgs/server/api/routers/team";
import { judgeRouter } from "rbrgs/server/api/routers/judge";
import { scoreboardRouter } from "./routers/scoreboard";
import { adminRouter } from "./routers/admin";

/**
* This is the primary router for your server.
Expand All @@ -16,6 +17,7 @@ export const appRouter = createTRPCRouter({
team: teamRouter,
judge: judgeRouter,
scoreboard: scoreboardRouter,
admin: adminRouter,
});

// export type definition of API
Expand Down
Loading

0 comments on commit 645979f

Please sign in to comment.