Skip to content

Commit

Permalink
Merge branch 'main' into fix-slack-notifications
Browse files Browse the repository at this point in the history
  • Loading branch information
renatodellosso authored Dec 3, 2024
2 parents fccd7ad + 623ab5b commit 3ec586a
Show file tree
Hide file tree
Showing 8 changed files with 1,564 additions and 740 deletions.
7 changes: 4 additions & 3 deletions components/competition/CompetitionIndex.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ import CompHeaderCard from "./CompHeaderCard";
import InsightsAndSettingsCard from "./InsightsAndSettingsCard";
import MatchScheduleCard from "./MatchScheduleCard";
import PitScoutingCard from "./PitScoutingCard";
import toast from "react-hot-toast";

const api = new ClientApi();

Expand Down Expand Up @@ -386,7 +387,7 @@ export default function CompetitionIndex(props: {
}

if ((res.result as string).toLowerCase() !== "success") {
alert(res.result);
toast.error(res.result);
}

setAssigningMatches(false);
Expand All @@ -395,11 +396,11 @@ export default function CompetitionIndex(props: {
const reloadCompetition = async () => {
const num = Math.floor(Math.random() * 1000000);
if(prompt(`Are you sure you want to reload the competition? This will overwrite ALL your data. We CANNOT recover your data. If you are sure, type '${num}'`) !== String(num)) {
alert("Cancelled");
toast("Cancelled");
return;
}

alert("Reloading competition...");
toast("Reloading competition...");

setUpdatingComp("Checking for Updates...");
const res = await api.reloadCompetition(comp?._id!);
Expand Down
6 changes: 3 additions & 3 deletions components/stats/Picklist.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ function TeamCard(props: { cardData: CardData, draggable: boolean, picklist?: Pi
return (
<div
className={`w-${props.width ?? "[150px]"} h-${props.height ?? "[100px]"} bg-base-100 rounded-lg p-1 flex items-center justify-center border-2 border-base-100 hover:border-primary`}
ref={dragRef}
ref={dragRef as unknown as () => void}
>
<h1>
{props.rank !== undefined ? `${props.rank + 1}. ` : ""}<span className="max-sm:hidden">Team</span> <span className="text-accent">#{teamNumber}</span>
Expand Down Expand Up @@ -115,7 +115,7 @@ function PicklistCard(props: { picklist: Picklist, picklists: Picklist[] }) {
return (
<div
className="bg-base-200 min-h-[30rem] h-fit rounded-lg w-1/3 sm:w-1/6 min-h-32 flex flex-col items-center space-y-2 p-2 sm:p-4"
ref={dropRef}
ref={dropRef as unknown as () => void}
>
<input defaultValue={picklist.name} className="w-[95%] input input-sm max-sm:hidden" onChange={changeName} />
<h1 className="w-[95%] input input-sm input-disabled sm:hidden">{picklist.name}</h1>
Expand Down Expand Up @@ -148,7 +148,7 @@ export function TeamList(props: { teams: CardData[], picklists: Picklist[], expe
});

return (
<div ref={dropRef} className="w-full h-fit flex flex-row bg-base-300 space-x-2 p-2 overflow-x-scroll">
<div ref={dropRef as unknown as () => void} className="w-full h-fit flex flex-row bg-base-300 space-x-2 p-2 overflow-x-scroll">
{
props.teams.sort((a, b) => a.number - b.number).map((team) => (
<TeamCard
Expand Down
3 changes: 2 additions & 1 deletion lib/Auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { Analytics } from '@/lib/client/Analytics';
import Email from "next-auth/providers/email";
import ResendUtils from "./ResendUtils";
import CollectionId from "./client/CollectionId";
import { AdapterUser } from "next-auth/adapters";

var db = getDatabase();

Expand Down Expand Up @@ -128,7 +129,7 @@ export const AuthenticationOptions: AuthOptions = {
debug: false,
adapter: {
...adapter,
createUser: async (user) => {
createUser: async (user: Omit<AdapterUser, "id">) => {
const createdUser = await adapter.createUser!(user);

Analytics.newSignUp(user.name ?? "Unknown User");
Expand Down
5 changes: 0 additions & 5 deletions lib/api/AccessLevels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,6 @@ namespace AccessLevels {
return { authorized: false, authData: undefined };
}

console.log(team.owners, user._id?.toString());

return { authorized: team.owners.includes(user._id?.toString()!), authData: { team, comp } };
}

Expand Down Expand Up @@ -241,8 +239,6 @@ namespace AccessLevels {
}

export async function IfOnTeamThatOwnsPicklist(req: NextApiRequest, res: ApiLib.ApiResponse<any>, { userPromise, db }: UserAndDb, picklistId: string) {
console.log("IfOnTeamThatOwnsPicklist", picklistId);

const user = await userPromise;
if (!user) {
return { authorized: false, authData: undefined };
Expand All @@ -258,7 +254,6 @@ namespace AccessLevels {
return { authorized: false, authData: undefined };
}

console.log(team.users, user._id?.toString());
return { authorized: team.users.includes(user._id?.toString()!), authData: { team, picklist } };
}
}
Expand Down
3 changes: 2 additions & 1 deletion lib/api/ApiLib.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { NextApiRequest, NextApiResponse } from "next";
import { OmitCallSignature } from "@/lib/Types";
import toast from "react-hot-toast";

/**
* @tested_by tests/lib/api/ApiLib.test.ts
Expand Down Expand Up @@ -108,7 +109,7 @@ namespace ApiLib {

if (res?.error) {
if (res.error === "Unauthorized") {
alert(`Unauthorized API request: ${subUrl}. If this is an error, please contact the developers.`);
toast.error(`Unauthorized API request: ${subUrl}. If this is an error, please contact the developers.`);
}
throw new Error(`${subUrl}: ${res.error}`);
}
Expand Down
Loading

0 comments on commit 3ec586a

Please sign in to comment.