Skip to content

Commit

Permalink
Added check for userMetadata to prevent TRPC error
Browse files Browse the repository at this point in the history
  • Loading branch information
ishaanthenerd committed Oct 8, 2024
1 parent 0f37645 commit 1dd1d8e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
6 changes: 4 additions & 2 deletions src/app/community/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,8 @@ export const metadata: Metadata = {
const Community = async () => {
const { clubs } = await api.club.all({});
const session = await getServerAuthSession();
const events = await api.userMetadata.getEvents();

if (!session) {
if (!session || !api.userMetadata) {
return (
<main className="h-full md:pl-72">
<Header />
Expand All @@ -39,6 +38,9 @@ const Community = async () => {
</main>
);
}

const events = await api.userMetadata.getEvents();

return (
<main className="h-full md:pl-72">
<Header />
Expand Down
16 changes: 15 additions & 1 deletion src/components/CommunityEvents.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,22 @@ import EventCard from '@src/components/events/EventCard';
import { SelectEvent } from '@src/server/db/models';
import Link from 'next/link';

type Event = SelectEvent & {
liked: boolean;
club: {
id: string;
name: string;
description: string;
image: string;
tags: string[];
approved: "approved" | "rejected" | "pending";
profileImage: string | null;
soc: boolean;
}
}

type Props = {
events: SelectEvent[]
events: Event[];
}

const CommunityEvents = ({ events }: Props) => {
Expand Down

0 comments on commit 1dd1d8e

Please sign in to comment.