Skip to content

Commit fdf2b24

Browse files
committed
fixed assignee logic
1 parent 51a4acf commit fdf2b24

File tree

2 files changed

+11
-14
lines changed

2 files changed

+11
-14
lines changed

apps/WarriorHappy/src/app/index.tsx

+8-7
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,7 @@ export default function HomeScreen() {
386386
const { data, isLoading, isFetched, isError, error } =
387387
api.scouting.getAssignments.useQuery({
388388
event: "2024urmom",
389+
assignee: session?.user?.id,
389390
});
390391
// biome-ignore lint/style/noNonNullAssertion: <explanation>
391392
const matchScoutAssignments = data!;
@@ -405,12 +406,12 @@ export default function HomeScreen() {
405406
: [],
406407
[matchScoutAssignments, val],
407408
);
408-
const filteredByAssigned = useMemo(() => {
409-
return filteredByEvent?.filter(
410-
// I'm relying on short-circuiting here for type safety lol
411-
(x) => x?.assignee == null || x.assignee === session?.user?.id,
412-
);
413-
}, [filteredByEvent, session]);
409+
// const filteredByAssigned = useMemo(() => {
410+
// return filteredByEvent?.filter(
411+
// // I'm relying on short-circuiting here for type safety lol
412+
// (x) => x?.assignee == null || x.assignee === session?.user?.id,
413+
// );
414+
// }, [filteredByEvent, session]);
414415

415416
return (
416417
<SafeAreaView className="bg-zinc-900">
@@ -458,7 +459,7 @@ export default function HomeScreen() {
458459
setVal={setVal}
459460
/>
460461
<FlashList
461-
data={filteredByAssigned}
462+
data={filteredByEvent}
462463
estimatedItemSize={20}
463464
ItemSeparatorComponent={() => <View className="h-2" />}
464465
renderItem={(p) => <MatchScoutAssignment assignment={p.item} />}

packages/api/src/router/scouting.ts

+3-7
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,13 @@ export const scoutingRouter = createTRPCRouter({
2525
z.object({ event: z.string(), assignee: z.string().uuid().optional() }),
2626
)
2727
.query(async ({ ctx, input }) => {
28-
let query = ctx.supabase
28+
const { data, error } = await ctx.supabase
2929
.from("assignments")
3030
.select(
3131
"matches (key, event, events (key, name)), team, alliance, assignee",
3232
)
33-
.eq("matches.event", input.event);
34-
console.log(input);
35-
if (input.assignee) {
36-
query = query.eq("assignee", input.assignee);
37-
}
38-
const { data, error } = await query;
33+
.eq("matches.event", input.event)
34+
.eq("assignee", input?.assignee === undefined ? null : input.assignee);
3935
console.log(data, input.event);
4036
if (error !== null || data === null) {
4137
throw new TRPCError({

0 commit comments

Comments
 (0)