Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
3714f11
Bump unified-api-nextjs
renatodellosso Feb 10, 2025
8d343e9
Bump unified-api-nextjs
renatodellosso Feb 11, 2025
568d28b
Merge pull request #444 from Decatur-Robotics/main
renatodellosso Feb 13, 2025
b5088c8
Start fallbacks
renatodellosso Feb 16, 2025
43e0fce
Merge pull request #447 from Decatur-Robotics/main
renatodellosso Feb 18, 2025
774ede2
Did some stuff, don't remember what
renatodellosso Feb 18, 2025
5d05ac6
Moved sw.ts
renatodellosso Feb 24, 2025
f7d734f
Misc changes. No more URL on offline page, no precache config in sw.ts
renatodellosso Feb 24, 2025
e872191
Don't remember what I did
renatodellosso Feb 25, 2025
941ae60
Merge pull request #457 from Decatur-Robotics/main
renatodellosso Mar 3, 2025
ece5f76
Bump version in lock
renatodellosso Mar 3, 2025
1de680b
Merge branch 'offline-mode' into updating-offline-mode
renatodellosso Mar 11, 2025
a1e6a51
Merge pull request #469 from Decatur-Robotics/updating-offline-mode
renatodellosso Mar 11, 2025
af599b3
Fix sign in
renatodellosso Mar 11, 2025
0223e5f
Almost finish fallback for competitionMatches
renatodellosso Mar 11, 2025
2e1f490
Make comp index load documents via api
renatodellosso Mar 13, 2025
cabe608
Fix sign in error
renatodellosso Mar 14, 2025
56b569a
Comp page loads
renatodellosso Mar 14, 2025
e94098c
Update mongo-anywhere to get addOrUpdateObject
renatodellosso Mar 14, 2025
30098c0
Add fallback for findCompSeasonAndTeamByCompSlug
renatodellosso Mar 14, 2025
7cc0939
Comp page now loads offline!
renatodellosso Mar 17, 2025
f87535b
Add tests for ClientApiUtils
renatodellosso Mar 17, 2025
f66f542
Add test for handling undefined object in saveObjectAfterResponse
renatodellosso Mar 17, 2025
1e98d0e
Stuff, not sure what
renatodellosso Mar 20, 2025
b96a972
Merge branch 'offline-mode' into updating-offline-mode
renatodellosso Mar 24, 2025
310d1ec
Fix build
renatodellosso Mar 24, 2025
c5ab63a
Fix build again
renatodellosso Mar 24, 2025
bb9ed47
Merge pull request #490 from Decatur-Robotics/updating-offline-mode
renatodellosso Mar 24, 2025
e34a4b5
Fix unit tests
renatodellosso Mar 24, 2025
b27b539
Team page now fetches props
renatodellosso Mar 24, 2025
079b615
Make season page load offline
renatodellosso Mar 25, 2025
98f12b6
Start offline pit reports
renatodellosso Mar 25, 2025
1a915fb
Rename [pitreportId] to pit.tsx
renatodellosso Mar 27, 2025
7fc9822
Revert "Rename [pitreportId] to pit.tsx"
renatodellosso Mar 27, 2025
23766c1
Add sync button
renatodellosso Mar 27, 2025
a3d0acb
Miscellaneous changes
renatodellosso Mar 27, 2025
452ad03
Merge branch 'main' into offline-mode
renatodellosso Apr 13, 2025
66785b8
Fix LocalStorage in Playwright
renatodellosso Apr 17, 2025
2a07056
Merge branch 'main' into offline-mode
renatodellosso Apr 17, 2025
166ffee
Fix findTeamBySlug
renatodellosso Apr 17, 2025
3feb681
Fix linter errors
renatodellosso Apr 17, 2025
6a414da
Use fetch to cache pit reports
renatodellosso Apr 17, 2025
3ca4dc7
Improved syncComp
renatodellosso Apr 20, 2025
1567b22
Pit reports load offline now
renatodellosso Apr 26, 2025
4203f10
Added Madge, split games into multiple files
renatodellosso Apr 26, 2025
87cdacf
Fix unit tests
renatodellosso Apr 26, 2025
b0f9ee6
Fix build
renatodellosso Apr 26, 2025
3bf4965
Actually fix build this time
renatodellosso Apr 26, 2025
683b189
Pit reports work!
renatodellosso Apr 27, 2025
1ade2f5
Pit reports can be submitted offline and then synced
renatodellosso Apr 27, 2025
b342a92
Update components/competition/CompHeaderCard.tsx
renatodellosso Apr 27, 2025
2703f3d
Refactor syncComp function to use Promise for better error handling
renatodellosso Apr 27, 2025
3ad6189
Merge branch 'main' into offline-mode
renatodellosso Apr 29, 2025
697b3ab
Merge branch 'main' into offline-mode
renatodellosso May 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
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ yarn-error.log*
/certs/production.pem
/certs/production-key.pem


.env.*.local
.env.local
.env

Expand Down
98 changes: 55 additions & 43 deletions components/SignInMenu.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Container from "@/components/Container";
import { useCurrentSession } from "@/lib/client/useCurrentSession";
import { signIn } from "next-auth/react";
import { useRouter } from "next/router";
import { useCallback, useEffect, useRef, useState } from "react";
Expand All @@ -14,6 +15,8 @@ const errorMessages: { [error: string]: string } = {
};

function SignInCard() {
const { status, session } = useCurrentSession();

const router = useRouter();
const emailRef = useRef<HTMLInputElement>(null);
const { executeRecaptcha } = useGoogleReCaptcha();
Expand Down Expand Up @@ -57,49 +60,58 @@ function SignInCard() {
return (
<div className="card bg-base-300 w-5/6 md:w-1/2">
<div className="card-body">
<h1 className="card-title">Sign In</h1>
{error && <p className="text-error">{error}</p>}
<p className="italic">Choose a login provider</p>
<span>
You currently <span className="text-red-500">have</span> to sign-in
using either your{" "}
<span className="text-green-400">original sign-in method</span> or
your <span className="text-green-400">email.</span>
</span>
<div className="divider" />

<button
onClick={() => signInWithCallbackUrl("google")}
className="btn btn-primary w-full font-bold text-md"
>
<FaGoogle />
Login with Google
</button>

<button
onClick={() => signInWithCallbackUrl("slack")}
className="btn btn-secondary w-full font-bold text-md"
>
<FaSlack />
Login with Slack
</button>

<div className="divider" />
<div className="flex flex-col gap-2">
<p>Email Sign In</p>
<input
ref={emailRef}
className="input input-bordered w-full"
type="email"
placeholder="Email"
/>
<button
onClick={logInWithEmail}
className="btn btn-accent w-full font-bold text-md"
>
Login with Email
</button>
</div>
{status === "authenticated" ? (
<>
<h1 className="card-title">Welcome back, {session.user!.name}</h1>
<progress className="progress w-56" />
</>
) : (
<>
<h1 className="card-title">Sign In</h1>
{error && <p className="text-error">{error}</p>}
<p className="italic">Choose a login provider</p>
<span>
You currently <span className="text-red-500">have</span> to
sign-in using either your{" "}
<span className="text-green-400">original sign-in method</span> or
your <span className="text-green-400">email.</span>
</span>
<div className="divider" />

<button
onClick={() => signInWithCallbackUrl("google")}
className="btn btn-primary w-full font-bold text-md"
>
<FaGoogle />
Login with Google
</button>

<button
onClick={() => signInWithCallbackUrl("slack")}
className="btn btn-secondary w-full font-bold text-md"
>
<FaSlack />
Login with Slack
</button>

<div className="divider" />
<div className="flex flex-col gap-2">
<p>Email Sign In</p>
<input
ref={emailRef}
className="input input-bordered w-full"
type="email"
placeholder="Email"
/>
<button
onClick={logInWithEmail}
className="btn btn-accent w-full font-bold text-md"
>
Login with Email
</button>
</div>
</>
)}
</div>
</div>
);
Expand Down
70 changes: 69 additions & 1 deletion components/competition/CompHeaderCard.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,22 @@
import ClientApi from "@/lib/api/ClientApi";
import { NotLinkedToTba } from "@/lib/client/ClientUtils";
import { Competition, Match, Report } from "@/lib/Types";
import { useState } from "react";
import { BiExport } from "react-icons/bi";

import { FaCalendarDay } from "react-icons/fa";
import { MdAutoGraph, MdQueryStats, MdCoPresent } from "react-icons/md";
import {
MdAutoGraph,
MdQueryStats,
MdCoPresent,
MdCloudSync,
} from "react-icons/md";
import ViewMatchesModal from "../ViewMatchesModal";
import { User } from "../../lib/Types";
import toast from "react-hot-toast";
import { syncCompData } from "@/lib/api/ClientApiUtils";

const api = new ClientApi();

export default function CompHeaderCard({
comp,
Expand All @@ -21,16 +32,73 @@ export default function CompHeaderCard({
matchPathway: string;
}) {
const [viewMatches, setViewMatches] = useState(false);
const [syncingOfflineData, setSyncingOfflineData] = useState(false);

async function toggleViewMatches() {
setViewMatches(!viewMatches);
}

async function syncComp() {
if (!comp) return;

const toastId = toast.loading("Caching offline pages...");
setSyncingOfflineData(true);
new Promise(async (resolve, reject) => {
await syncCompData(api, comp._id!.toString());

const totalItemsToSync = comp?.pitReports.length || 0;
let itemsSynced = 0;
await Promise.all(
comp?.pitReports.map(async (report) => {
await fetch(`${location.href}/pit/${report}`);
itemsSynced++;
toast.loading(
`Caching offline pages... (${itemsSynced}/${totalItemsToSync})`,
{
id: toastId,
},
);
}),
);

console.log("Cached all offline pages!");
toast.success("Cached all offline pages!", { id: toastId });

// Finally block doesn't run for some reason
setSyncingOfflineData(false);
resolve(true);
})
.catch((err) => {
toast.error(`Error syncing offline data. Error: ${err}`, {
id: toastId,
});

// Finally block doesn't run for some reason
setSyncingOfflineData(false);
})
.finally(() => setSyncingOfflineData(false));
}

return (
<div className="w-full card bg-base-200 shadow-xl">
<div className="card-body">
<div className="flex flex-row items-center justify-between w-full">
<h1 className="card-title text-3xl font-bold">{comp?.name}</h1>
<div
className="tooltip"
data-tip="Sync Offline Data"
>
{syncingOfflineData ? (
<span className="loading loading-spinner loading-xs" />
) : (
<button
onClick={syncComp}
className="btn btn-ghost"
>
<MdCloudSync />
</button>
)}
</div>
</div>
<div className="divider"></div>
<div className="w-full flex flex-col sm:flex-row items-center mt-4 max-sm:space-y-1">
Expand Down
Loading