Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
84 commits
Select commit Hold shift + click to select a range
570523b
Merge pull request #377 from Decatur-Robotics/main
Tr01ler Dec 17, 2024
5b73c60
Componentalized a lot of things that will not fit in this commit message
Tr01ler Dec 17, 2024
41153c5
Componentalized the rest of InsightsAndSettingsCard
Tr01ler Dec 17, 2024
664a516
Don't try to overwrite team _id in createSeason
renatodellosso Feb 18, 2025
7da72cb
Fix event page error: event not found when rankings don't exist
renatodellosso Feb 18, 2025
b4f8bce
Add undershoot deadband for wait
renatodellosso Feb 18, 2025
aa1de31
Fix _id overwrite error in createCompetition
renatodellosso Feb 18, 2025
ab2467f
publishing
BanEvading Feb 24, 2025
b84dba8
Don't use cache in sign in flow
renatodellosso Feb 24, 2025
acde19c
1.2.3
gearbox4026 Feb 24, 2025
790097a
Reuse db in auth flow
renatodellosso Feb 24, 2025
b78ba52
Reduce getDatabase calls in Auth
renatodellosso Feb 24, 2025
7b9d17f
Add log for sign in callback
renatodellosso Feb 24, 2025
27245d5
Merge branch 'main' into zeroes
BanEvading Feb 24, 2025
f4d1995
Format Auth
renatodellosso Feb 24, 2025
70f203f
Merge branch 'main' into zeroes
renatodellosso Feb 24, 2025
56f7054
Merge pull request #449 from Decatur-Robotics/zeroes
renatodellosso Feb 24, 2025
d82f169
Merge pull request #450 from Decatur-Robotics/main
Tr01ler Feb 25, 2025
76890ba
Create DbInterfaceAuthAdapter
renatodellosso Feb 25, 2025
5a4fc83
Remove unneeded DB call in session callback
renatodellosso Feb 25, 2025
1803cd1
1.2.4
gearbox4026 Feb 25, 2025
ed77b0b
Remove unneeded variable
renatodellosso Feb 25, 2025
770b149
Merge branch 'custom-mongo-auth-adapter' of github.com:Decatur-Roboti…
renatodellosso Feb 25, 2025
f6f2247
Remove base adapter
renatodellosso Feb 25, 2025
180842e
Merge pull request #451 from Decatur-Robotics/custom-mongo-auth-adapter
renatodellosso Feb 25, 2025
58252d4
More tests and logs
renatodellosso Feb 25, 2025
87a67bf
Merge branch 'main' into custom-mongo-auth-adapter
renatodellosso Feb 25, 2025
c32993a
1.2.5
gearbox4026 Feb 25, 2025
acc0a10
Merge pull request #452 from Decatur-Robotics/custom-mongo-auth-adapter
renatodellosso Feb 25, 2025
58f8273
More logs
renatodellosso Feb 25, 2025
b919af7
Merge branch 'main' of github.com:Decatur-Robotics/Gearbox
renatodellosso Feb 25, 2025
392d3dd
Fix formatting in adapter
renatodellosso Feb 25, 2025
7fc9ffc
Revert "Fix formatting in adapter"
renatodellosso Feb 25, 2025
bdad8f3
Revert "Merge branch 'main' of github.com:Decatur-Robotics/Gearbox"
renatodellosso Feb 25, 2025
00791b6
Revert "More logs"
renatodellosso Feb 25, 2025
e43a1d9
Reapply "More logs"
renatodellosso Feb 25, 2025
e4dd9d1
Reapply "Merge branch 'main' of github.com:Decatur-Robotics/Gearbox"
renatodellosso Feb 25, 2025
41c1d7d
Use old adapter
renatodellosso Feb 25, 2025
59ee9f0
Fix sessions and OAuth
renatodellosso Feb 26, 2025
5390646
More logs for sign in
renatodellosso Feb 27, 2025
b0b26eb
Add timer for sign in flow
renatodellosso Feb 27, 2025
afcc356
Switch back to new DB adapter
renatodellosso Feb 27, 2025
fefa87f
Fix populateMissingUserFields
renatodellosso Feb 27, 2025
0506ae8
Don't repair users in email sign in anymore
renatodellosso Feb 27, 2025
7eb2518
Don't overwrite existing users
renatodellosso Feb 27, 2025
ddd599a
Add [AUTH] prefix to authentication logs for better clarity
renatodellosso Feb 27, 2025
1dff377
Use cache in signIn DB
renatodellosso Feb 27, 2025
cfa6e7d
Better logs for creating a session
renatodellosso Feb 27, 2025
725d36b
Don't create duplicate accounts
renatodellosso Feb 27, 2025
e437dc7
More logs
renatodellosso Feb 27, 2025
8eaa79e
1.2.4
gearbox4026 Feb 27, 2025
12d2058
Better logs in Auth.ts
renatodellosso Feb 27, 2025
e10f2bf
Fix tests
renatodellosso Feb 27, 2025
15ad33d
Merge branch 'main' into Move-InsightsAndSettings-Logic-to-component
Tr01ler Feb 27, 2025
f96b0e1
Return DB session
renatodellosso Feb 27, 2025
ccdac59
Removed two unintentional indents
Tr01ler Feb 27, 2025
3ab179c
Removed yet another indent.
Tr01ler Feb 27, 2025
1d49bb9
Attempting to please Prettier
Tr01ler Feb 27, 2025
60175e5
Attempt 2 at pleasing Prettier
Tr01ler Feb 27, 2025
0827676
Merge branch 'main' into Move-InsightsAndSettings-Logic-to-component
Tr01ler Feb 27, 2025
7c7f490
don't overwrite user IDs
renatodellosso Feb 27, 2025
9de9dfb
Merge branch 'main' into Move-InsightsAndSettings-Logic-to-component
Tr01ler Feb 27, 2025
eab5879
Merge pull request #455 from Decatur-Robotics/Move-InsightsAndSetting…
renatodellosso Feb 27, 2025
0ff2a1b
Remove user ID assignment from authentication process and improve log…
renatodellosso Feb 27, 2025
cc59b57
Merge branch 'main' of github.com:Decatur-Robotics/Gearbox
renatodellosso Feb 27, 2025
12acc67
Logs for AccessLevels
renatodellosso Feb 27, 2025
9301a0c
Don't set id for existing users
renatodellosso Feb 27, 2025
9504cb1
Fix access level errors
renatodellosso Feb 27, 2025
2b6565f
Less logs in Auth
renatodellosso Feb 27, 2025
45919e7
New accounts work
renatodellosso Feb 27, 2025
a37b288
Add comp log
renatodellosso Feb 28, 2025
9f1e813
Add match log
renatodellosso Feb 28, 2025
e34b85f
Use match number from TBA to set match number in document
renatodellosso Feb 28, 2025
3e02832
Less logs and better code for visualizing scouter assignment
renatodellosso Feb 28, 2025
7c27de6
Don't allow russian emails
renatodellosso Feb 28, 2025
f226226
Add captcha
renatodellosso Feb 28, 2025
dcf2372
Add log for blocked emails
renatodellosso Feb 28, 2025
acbb20f
Link to sign in page in header
renatodellosso Feb 28, 2025
6dec8c1
Also link to sign in
renatodellosso Feb 28, 2025
89ffd9b
Add log for recaptcha key
renatodellosso Mar 1, 2025
eaf81a3
Add captcha key to production public env
renatodellosso Mar 1, 2025
66df04f
Clean up Recaptcha setup
renatodellosso Mar 1, 2025
167c40a
Remove old email blacklist
renatodellosso Mar 1, 2025
1fa4a42
Use Logger in index.ts
renatodellosso Mar 1, 2025
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
3 changes: 2 additions & 1 deletion .env.production
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
# We have to include these at build time, so this file is used to inject them into the build process.
NEXT_PUBLIC_API_URL=/api/
NEXT_PUBLIC_SLACK_CLIENT_ID=10831824934.7404945710466
NEXT_PUBLIC_GOOGLE_ANALYTICS_ID=G-1BFJYBDC76
NEXT_PUBLIC_GOOGLE_ANALYTICS_ID=G-1BFJYBDC76
NEXT_PUBLIC_RECAPTCHA_KEY=6Le63OUqAAAAABxxDrbaU9OywDLLHqutVwbw7a9d
4 changes: 3 additions & 1 deletion .env.test
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@ DEVELOPER_EMAILS=["[email protected]"]

TOA_URL=https://example.com
TOA_APP_ID=123
TOA_KEY=456
TOA_KEY=456

DEFAULT_IMAGE=https://example.com/default.jpg
9 changes: 2 additions & 7 deletions components/Container.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,6 @@ export default function Container(props: ContainerProps) {
}, [eventSearch]);

useEffect(() => {
if (window.location.href.includes("signin")) {
console.log("triggered");
location.reload();
}

const loadTeams = async () => {
if (!user) {
return;
Expand Down Expand Up @@ -231,7 +226,7 @@ export default function Container(props: ContainerProps) {
</Link>
) : (
<a
href={"/api/auth/signin"}
href={"/signin"}
rel="noopener noreferrer"
target="_blank"
>
Expand Down Expand Up @@ -268,7 +263,7 @@ export default function Container(props: ContainerProps) {
<h2 className="card-title">Wait a minute...</h2>
<p>You need to sign in first!</p>
<div className="card-actions justify-end">
<Link href={"/api/auth/signin"}>
<Link href={"/signin"}>
<button className="btn btn-primary">Sign In</button>
</Link>
</div>
Expand Down
148 changes: 96 additions & 52 deletions components/competition/InsightsAndSettingsCard.tsx
Original file line number Diff line number Diff line change
@@ -1,89 +1,136 @@
import { NotLinkedToTba } from "@/lib/client/ClientUtils";
import { download, NotLinkedToTba } from "@/lib/client/ClientUtils";
import { defaultGameId } from "@/lib/client/GameId";
import { Round } from "@/lib/client/StatsMath";
import { games } from "@/lib/games";
import { Competition, Pitreport, Report, Team } from "@/lib/Types";
import { Competition, MatchType, Pitreport, Report, Team } from "@/lib/Types";
import Link from "next/link";
import { ChangeEvent } from "react";
import { ChangeEvent, useState } from "react";
import { BsGearFill, BsClipboard2Check } from "react-icons/bs";
import { FaSync, FaBinoculars, FaUserCheck, FaDatabase } from "react-icons/fa";
import { FaUserGroup } from "react-icons/fa6";
import ClientApi from "@/lib/api/ClientApi";

const api = new ClientApi();

export default function InsightsAndSettingsCard(props: {
showSettings: boolean;
setShowSettings: (value: boolean) => void;
isManager: boolean | undefined;
comp: Competition | undefined;
reloadCompetition: () => void;
assignScouters: () => void;
exportAsCsv: () => void;
exportPending: boolean;
showSubmittedMatches: boolean;
toggleShowSubmittedMatches: () => void;
assigningMatches: boolean;
regeneratePitReports: () => void;
newCompName: string | undefined;
setNewCompName: (value: string) => void;
newCompTbaId: string | undefined;
setNewCompTbaId: (value: string) => void;
saveCompChanges: () => void;
redAlliance: number[];
setRedAlliance: (value: number[]) => void;
blueAlliance: number[];
setBlueAlliance: (value: number[]) => void;
matchNumber: number | undefined;
setMatchNumber: (value: number) => void;
createMatch: () => void;
teamToAdd: number;
setTeamToAdd: (value: number) => void;
addTeam: () => void;
submittedReports: number | undefined;
reports: Report[];
loadingScoutStats: boolean;
pitreports: Pitreport[];
submittedPitreports: number | undefined;
togglePublicData: (e: ChangeEvent<HTMLInputElement>) => void;
seasonSlug: string | undefined;
team: Team | undefined;
allianceIndices: number[];
}) {
const [showSettings, setShowSettings] = useState(false);
const {
showSettings,
setShowSettings,
isManager,
comp,
reloadCompetition,
assignScouters,
exportAsCsv,
exportPending,
showSubmittedMatches,
toggleShowSubmittedMatches,
assigningMatches,
newCompName,
setNewCompName,
newCompTbaId,
setNewCompTbaId,
saveCompChanges,
redAlliance,
setRedAlliance,
blueAlliance,
setBlueAlliance,
matchNumber,
setMatchNumber,
createMatch,
teamToAdd,
setTeamToAdd,
addTeam,
submittedReports,
reports,
loadingScoutStats,
pitreports,
submittedPitreports,
togglePublicData,
seasonSlug,
team,
allianceIndices,
} = props;
const [newCompName, setNewCompName] = useState(comp?.name);
const [newCompTbaId, setNewCompTbaId] = useState(comp?.tbaId);
const [exportPending, setExportPending] = useState(false);
const [teamToAdd, setTeamToAdd] = useState<number>(0);
const [blueAlliance, setBlueAlliance] = useState<number[]>([]);
const [redAlliance, setRedAlliance] = useState<number[]>([]);
const [matchNumber, setMatchNumber] = useState<number | undefined>(undefined);

const exportAsCsv = async () => {
setExportPending(true);

const res = await api.exportCompAsCsv(comp?._id!).catch((e) => {
console.error(e);
return { csv: undefined };
});

if (!res) {
console.error("failed to export");
}

if (res.csv) {
download(`${comp?.name ?? "Competition"}.csv`, res.csv, "text/csv");
} else {
console.error("No CSV data returned from server");
}

setExportPending(false);
};

const createMatch = async () => {
try {
await api.createMatch(
comp?._id!,
Number(matchNumber),
0,
MatchType.Qualifying,
blueAlliance as number[],
redAlliance as number[],
);
} catch (e) {
console.error(e);
}

location.reload();
};

const allianceIndices: number[] = [];
for (let i = 0; i < games[comp?.gameId ?? defaultGameId].allianceSize; i++) {
allianceIndices.push(i);
}

async function saveCompChanges() {
// Check if tbaId is valid
if (!comp?.tbaId || !comp?.name || !comp?._id) return;

let tbaId = newCompTbaId;
const autoFillData = await api.competitionAutofill(tbaId ?? "");
if (
!autoFillData?.name &&
!confirm(`Invalid TBA ID: ${tbaId}. Save changes anyway?`)
)
return;

await api.updateCompNameAndTbaId(
comp?._id,
newCompName ?? "Unnamed",
tbaId ?? NotLinkedToTba,
);
location.reload();
}

function togglePublicData(e: ChangeEvent<HTMLInputElement>) {
if (!comp?._id) return;
api.setCompPublicData(comp?._id, e.target.checked);
}

function addTeam() {
console.log("Adding pit report for team", teamToAdd);
if (!teamToAdd || teamToAdd < 1 || !comp?._id) return;

api
.createPitReportForTeam(teamToAdd, comp?._id)
// We can't just pass location.reload, it will throw "illegal invocation." I don't know why. -Renato
.finally(() => location.reload());
}

return (
<div className="w-full card bg-base-200 shadow-xl">
Expand Down Expand Up @@ -367,7 +414,7 @@ export default function InsightsAndSettingsCard(props: {
? (+(
Round(submittedReports / reports.length) * 100
)).toFixed(0)
: "?"}
: "0"}
%
</div>
<div className="stat-desc"></div>
Expand All @@ -394,7 +441,7 @@ export default function InsightsAndSettingsCard(props: {
? (+(
Round(submittedReports / reports.length) * 100
)).toFixed(0)
: "?"}
: "0"}
%
</div>
<div className="stat-desc">
Expand All @@ -412,12 +459,9 @@ export default function InsightsAndSettingsCard(props: {
<FaUserGroup size={40}></FaUserGroup>
</div>
<div className="stat-value text-primary">
{!submittedPitreports && submittedPitreports !== 0
? "?"
: submittedPitreports}
/
{!submittedPitreports ? "0" : submittedPitreports}/
{!pitreports || pitreports.length === 0
? "?"
? "0"
: pitreports.length}
</div>
</div>
Expand Down
56 changes: 23 additions & 33 deletions components/competition/MatchScheduleCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { MdErrorOutline } from "react-icons/md";
import Avatar from "../Avatar";
import Loading from "../Loading";
import { AdvancedSession } from "@/lib/client/useCurrentSession";
import { useEffect } from "react";

export default function MatchScheduleCard(props: {
team: Team | undefined;
Expand Down Expand Up @@ -62,11 +63,14 @@ export default function MatchScheduleCard(props: {
showSubmittedMatches,
} = props;

const displayedMatches = showSubmittedMatches
? matches
: matches.filter((match) =>
match.reports.some((reportId) => !reportsById[reportId]?.submitted),
);
const unsubmittedMatches: Match[] = [];

for (const match of matches) {
if (match.reports.some((reportId) => !reportsById[reportId]?.submitted))
unsubmittedMatches.push(match);
}

const displayedMatches = showSubmittedMatches ? matches : unsubmittedMatches;

return (
<div className="w-full card bg-base-200 shadow-xl ">
Expand All @@ -80,38 +84,24 @@ export default function MatchScheduleCard(props: {
)}
</h1>
{isManager &&
matchesAssigned === false &&
Object.keys(usersById).length >= 6 ? (
matchesAssigned !== undefined ? (
matchesAssigned === false &&
Object.keys(usersById).length >= 6 &&
(!assigningMatches ? (
<div className="opacity-100 font-bold text-warning flex flex-row items-center justify-start space-x-3">
<div>
{!assigningMatches
? "Matches are not assigned"
: "Assigning matches"}
</div>
{!assigningMatches ? (
<button
className={
"btn btn-primary btn-sm " +
(assigningMatches ? "disabled" : "")
}
onClick={assignScouters}
>
Assign Matches
</button>
) : (
<BsGearFill
size={30}
className="animate-spin-slow text-white"
/>
)}
<div>Matches are not assigned.</div>
<button
className={
"btn btn-primary btn-sm " +
(assigningMatches ? "disabled" : "")
}
onClick={assignScouters}
>
Assign Matches
</button>
</div>
) : (
<progress className="progress w-full" />
)
) : (
<></>
)}
))}
<div className="divider my-0"></div>
{loadingMatches || loadingReports || loadingUsers ? (
<div className="w-full flex flex-col items-center justify-center">
Expand Down
3 changes: 3 additions & 0 deletions environment.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ declare global {

DEVELOPER_EMAILS: string;

NEXT_PUBLIC_RECAPTCHA_KEY: string;
RECAPTCHA_SECRET: string;

NODE_ENV: "development" | "production";
}
}
Expand Down
Loading
Loading