[go: nahoru, domu]

Skip to content

Commit

Permalink
Refactor autoAssign function and remove unused code
Browse files Browse the repository at this point in the history
  • Loading branch information
DragonXDev committed Apr 5, 2024
1 parent 68cd96f commit ba3274f
Showing 1 changed file with 19 additions and 27 deletions.
46 changes: 19 additions & 27 deletions apps/nextjs/src/app/dashboard/Assignments.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,27 +33,6 @@ import { Search } from "./components/search";
import TeamSwitcher from "./components/team-switcher";
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: { [key: string]: string[] } = assignTasks(
assignments,
Object.keys(members),
);
console.log(autoassign, typeof autoassign);
setMembers(autoassign);
// {[key: string]: string[];}
setAssignments([]);
// }, []);
}

type AssignmentsProps = {
selectedEvent: string;
};
Expand Down Expand Up @@ -87,7 +66,23 @@ type Alliance = {
team_keys: string[];
};

function Assignments({ selectedEvent }: AssignmentsProps) {
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([]);
// }, []);
}
function Assignments({ selectedEvent }) {
// XXX: Use real data via tRPC
// const [members, setMembers] = useState<{ [key: string]: string[] }>(
// Object.fromEntries(tags.map((x) => [`${x}M`, []])),
Expand Down Expand Up @@ -149,7 +144,7 @@ function Assignments({ selectedEvent }: AssignmentsProps) {
// biome-ignore lint/complexity/noForEach: <explanation>
matches.forEach((match: MatchSubset) => {
// Extract match number and alliances
const { alliances } = match;
const { match_num, match_key, alliances } = match;

// Iterate over each alliance (blue and red)
// biome-ignore lint/complexity/noForEach: <explanation>
Expand Down Expand Up @@ -217,10 +212,7 @@ function Assignments({ selectedEvent }: AssignmentsProps) {
}
return false; // Return false if not found in either alliance
});
if (!match) {
console.error("Match not found for the active team key.");
return; // Stop execution if match is not found
}

// Check if the activeTeamKey is part of the blue alliance or the red alliance
const allianceColor = match.alliances.blue.team_keys.includes(
activeTeamKey,
Expand Down

0 comments on commit ba3274f

Please sign in to comment.