Skip to content

Commit 9946fcc

Browse files
committed
Greater reliability
1 parent c8598fe commit 9946fcc

File tree

5 files changed

+45
-37
lines changed

5 files changed

+45
-37
lines changed

apps/WarriorHappy/src/app/index.tsx

+15-10
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ function MatchScoutAssignment({
193193
}: {
194194
assignment: MatchScoutAssignment;
195195
}) {
196-
console.log("asrs", assignment);
196+
console.log("Match Scout Assignment:", assignment);
197197
return (
198198
<View className="bg-blue/10 flex flex-row rounded-lg bg-white/10 p-4">
199199
<View className="flex-grow flex-col">
@@ -395,17 +395,22 @@ export default function HomeScreen() {
395395
// biome-ignore lint/correctness/useExhaustiveDependencies: <explanation>
396396
useEffect(() => {
397397
if (isFetched && matchScoutAssignments) {
398-
setVal(matchScoutAssignments?.[0]?.[0]?.eventName);
398+
if (matchScoutAssignments.length === 0) {
399+
setVal("No events found");
400+
} else if (matchScoutAssignments[0].length === 0) {
401+
setVal("No assignments found");
402+
} else {
403+
setVal(matchScoutAssignments[0][0].eventName);
404+
}
399405
}
400406
}, [isFetched]);
401-
const filteredByEvent = useMemo(
402-
() =>
403-
matchScoutAssignments
404-
? // Should just be one event of that name
405-
matchScoutAssignments.filter((x) => x[0].eventName === val)[0]
406-
: [],
407-
[matchScoutAssignments, val],
408-
);
407+
const filteredByEvent =
408+
matchScoutAssignments &&
409+
matchScoutAssignments.length !== 0 &&
410+
matchScoutAssignments[0].length !== 0
411+
? // Should just be one event of that name
412+
matchScoutAssignments.filter((x) => x[0].eventName === val)[0]
413+
: [];
409414
// const filteredByAssigned = useMemo(() => {
410415
// return filteredByEvent?.filter(
411416
// // I'm relying on short-circuiting here for type safety lol

apps/WarriorHappy/src/app/match/[matchId].tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export default function Match() {
2929
matchKey: local.matchId as string,
3030
team: local.team as string,
3131
};
32-
console.log("sdakkkk", key);
32+
console.log("Match Scouting RPC key:", key);
3333
const utils = api.useUtils();
3434
// staletime infinity = fetch once
3535
const { data, isLoading, isError } = api.scouting.getMatchLog.useQuery(key, {
@@ -39,7 +39,7 @@ export default function Match() {
3939
const rawUpdate = api.scouting.updateMatchLog.useMutation({
4040
networkMode: "offlineFirst",
4141
onSuccess: (data, variables, context) => {
42-
console.log("data", data, variables, context);
42+
console.log("Mutation Data `onSuccess`:", data, variables, context);
4343
router.push("/");
4444
// utils.scouting.getMatchLog.invalidateQuery();
4545
},

apps/WarriorHappy/src/utils/api.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ export const TRPCProvider = (props: { children: React.ReactNode }) => {
5858
async headers() {
5959
const headers = new Map<string, string>();
6060
headers.set("x-trpc-source", "expo-react");
61-
console.log("supa", supabase);
61+
console.log("Supabase instance:", supabase);
6262
const { data } = await supabase.auth.getSession();
6363
const token = data.session?.access_token;
6464
// console.log("HEY SUPA DATA", data, token);

apps/nextjs/src/app/actions.ts

+19-20
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,22 @@ import { redirect } from "next/navigation";
66
import { createClient } from "@/lib/utils/supabase/server";
77

88
export async function signup(formData: FormData) {
9-
const supabase = createClient();
10-
11-
// type-casting here for convenience
12-
// in practice, you should validate your inputs
13-
const data = {
14-
email: formData.get("email") as string,
15-
password: formData.get("password") as string,
16-
};
17-
18-
const { error } = await supabase.auth.signUp(data);
19-
console.log("error", error);
20-
if (error) {
21-
// TODO: Form check error
22-
redirect("/error");
23-
}
24-
25-
revalidatePath("/", "layout");
26-
redirect("/");
27-
}
28-
9+
const supabase = createClient();
10+
11+
// type-casting here for convenience
12+
// in practice, you should validate your inputs
13+
const data = {
14+
email: formData.get("email") as string,
15+
password: formData.get("password") as string,
16+
};
17+
18+
const { error } = await supabase.auth.signUp(data);
19+
console.log("Sign Up Error:", error);
20+
if (error) {
21+
// TODO: Form check error
22+
redirect("/error");
23+
}
24+
25+
revalidatePath("/", "layout");
26+
redirect("/");
27+
}

packages/api/src/router/scouting.ts

+8-4
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export const scoutingRouter = createTRPCRouter({
3737
query = query.eq("assignee", input.assignee);
3838
}
3939
const { data, error } = await query;
40-
console.log(data, input.event);
40+
console.log("RPC: getAssignments | input:", input, " | db output:", data);
4141
if (error !== null || data === null) {
4242
throw new TRPCError({
4343
code: "INTERNAL_SERVER_ERROR",
@@ -81,8 +81,7 @@ export const scoutingRouter = createTRPCRouter({
8181
// biome-ignore lint/style/noNonNullAssertion: The match should be guaranteed to map to a singular event
8282
eventKey: x.matches!.event,
8383
// biome-ignore lint/style/noNonNullAssertion: see above
84-
85-
eventName: x.matches!.events?.name, // @ts-ignore
84+
eventName: x.matches!.events!.name,
8685
// biome-ignore lint/style/noNonNullAssertion: see above
8786
team: parseInt(x.team.match(/\d+/)![0]),
8887
red: redTeams,
@@ -135,7 +134,12 @@ export const scoutingRouter = createTRPCRouter({
135134
cause: error,
136135
});
137136
}
138-
console.log("mutation", data, error, input);
137+
console.log(
138+
"RPC: updateMatchLog (db returned data, error, input):",
139+
data,
140+
error,
141+
input,
142+
);
139143
// TODO: Actually return somthing for data
140144
// .where(eq(matches.teamNum, input.teamNum));
141145
}),

0 commit comments

Comments
 (0)