[go: nahoru, domu]

Skip to content

Commit

Permalink
fixed assignee logic
Browse files Browse the repository at this point in the history
  • Loading branch information
ThatXliner committed Feb 29, 2024
1 parent 51a4acf commit fdf2b24
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 14 deletions.
15 changes: 8 additions & 7 deletions apps/WarriorHappy/src/app/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,7 @@ export default function HomeScreen() {
const { data, isLoading, isFetched, isError, error } =
api.scouting.getAssignments.useQuery({
event: "2024urmom",
assignee: session?.user?.id,
});
// biome-ignore lint/style/noNonNullAssertion: <explanation>
const matchScoutAssignments = data!;
Expand All @@ -405,12 +406,12 @@ export default function HomeScreen() {
: [],
[matchScoutAssignments, val],
);
const filteredByAssigned = useMemo(() => {
return filteredByEvent?.filter(
// I'm relying on short-circuiting here for type safety lol
(x) => x?.assignee == null || x.assignee === session?.user?.id,
);
}, [filteredByEvent, session]);
// const filteredByAssigned = useMemo(() => {
// return filteredByEvent?.filter(
// // I'm relying on short-circuiting here for type safety lol
// (x) => x?.assignee == null || x.assignee === session?.user?.id,
// );
// }, [filteredByEvent, session]);

return (
<SafeAreaView className="bg-zinc-900">
Expand Down Expand Up @@ -458,7 +459,7 @@ export default function HomeScreen() {
setVal={setVal}
/>
<FlashList
data={filteredByAssigned}
data={filteredByEvent}
estimatedItemSize={20}
ItemSeparatorComponent={() => <View className="h-2" />}
renderItem={(p) => <MatchScoutAssignment assignment={p.item} />}
Expand Down
10 changes: 3 additions & 7 deletions packages/api/src/router/scouting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,13 @@ export const scoutingRouter = createTRPCRouter({
z.object({ event: z.string(), assignee: z.string().uuid().optional() }),
)
.query(async ({ ctx, input }) => {
let query = ctx.supabase
const { data, error } = await ctx.supabase
.from("assignments")
.select(
"matches (key, event, events (key, name)), team, alliance, assignee",
)
.eq("matches.event", input.event);
console.log(input);
if (input.assignee) {
query = query.eq("assignee", input.assignee);
}
const { data, error } = await query;
.eq("matches.event", input.event)
.eq("assignee", input?.assignee === undefined ? null : input.assignee);
console.log(data, input.event);
if (error !== null || data === null) {
throw new TRPCError({
Expand Down

0 comments on commit fdf2b24

Please sign in to comment.