Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 22 additions & 2 deletions apps/nextjs/src/app/dashboard/Assignments.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"use client";

import { useState } from "react";
import { useEffect, useState } from "react";
import { Metadata } from "next";
import Image from "next/image";
import { Button } from "@/components/ui/button";
Expand All @@ -19,6 +19,7 @@ import {
import { ScrollArea } from "@/components/ui/scroll-area";
import { Separator } from "@/components/ui/separator";
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
import { assignTasks } from "@/lib/utils/autoassign";
import { DndContext, DragOverlay, useDroppable } from "@dnd-kit/core";

import { AssignmentCard, MemberCard } from "./components/cards";
Expand All @@ -33,7 +34,19 @@ import { UserNav } from "./components/user-nav";
const tags = Array.from({ length: 50 }).map(
(_, i, a) => `v1.2.0-beta.${a.length - i}`,
);

function autoAssign(
assignments: string[],
members: { [key: string]: string[] },
setMembers: (members: { [key: string]: string[] }) => void,
setAssignments: (assignments: string[]) => void,
) {
// useEffect(() => {
const autoassign = assignTasks(assignments, Object.keys(members));
console.log(autoassign, typeof autoassign);
setMembers(autoassign);
setAssignments([]);
// }, []);
}
export default function Assignments() {
// XXX: Use real data via tRPC
const [members, setMembers] = useState<{ [key: string]: string[] }>(
Expand Down Expand Up @@ -137,6 +150,13 @@ export default function Assignments() {
</ResizablePanelGroup> */}
</ResizablePanel>
</ResizablePanelGroup>
<Button
onClick={() =>
autoAssign(assignments, members, setMembers, setAssignments)
}
>
Auto Assign
</Button>
</DndContext>
);
}
Expand Down
2 changes: 1 addition & 1 deletion apps/nextjs/src/app/dashboard/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { ScrollArea } from "@/components/ui/scroll-area";
import { Separator } from "@/components/ui/separator";
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";

import Assignments from "./Assignments";
import Assignments, { autoassign } from "./Assignments";
import { CalendarDateRangePicker } from "./components/date-range-picker";
import { MainNav } from "./components/main-nav";
import { Overview } from "./components/overview";
Expand Down
19 changes: 19 additions & 0 deletions apps/nextjs/src/app/matches/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import React from "react";
import { createTRPCClient } from "@trpc/client";
import { httpBatchLink } from "@trpc/client/links/httpBatchLink";
import { createTRPCReact } from "@trpc/react-query";

import type { AppRouter } from "@acme/api";

const api = createTRPCReact<AppRouter>();

export default async function getTeamEvents(teamKey: string, year: number) {
const teamEvents = await api.tba.teamEvents.useQuery({
teamKey,
year,
});
console.log(teamEvents);
return teamEvents;
}

console.log("HAAAAAAA: ", getTeamEvents("frc254", 2023));
16 changes: 8 additions & 8 deletions apps/nextjs/src/lib/utils/autoassign.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function assignTasks(times, users) {
export function assignTasks(times, users) {
// Sort the times for ordered assignment
const sortedTimes = times.sort();

Expand Down Expand Up @@ -38,12 +38,12 @@ users.forEach(user => {
return assignments;
}

// Example usage:
const times = ['10:00', '10:30', '11:00', '11:30'].reduce((acc, time) => acc.concat(Array(6).fill(time)), []);
const users = ['Bryan', 'has', 'no', 'girls', 'also', 'the', 'scouting', 'app', 'works','on','his','computer'];
// // Example usage:
// const times = ['10:00', '10:30', '11:00', '11:30'].reduce((acc, time) => acc.concat(Array(6).fill(time)), []);
// const users = ['Bryan', 'has', 'no', 'girls', 'also', 'the', 'scouting', 'app', 'works','on','his','computer'];

const assignments = assignTasks(times, users);
for (const user in assignments) {
console.log(`${user}: ${assignments[user]}`);
}
// const assignments = assignTasks(times, users);
// for (const user in assignments) {
// console.log(`${user}: ${assignments[user]}`);
// }