From 1dd1d8e0781b45e73e47fbaf690387ce757ce8d6 Mon Sep 17 00:00:00 2001
From: ishaanthenerd <145402353+ishaanthenerd@users.noreply.github.com>
Date: Tue, 8 Oct 2024 23:03:07 +0000
Subject: [PATCH] Added check for userMetadata to prevent TRPC error
---
src/app/community/page.tsx | 6 ++++--
src/components/CommunityEvents.tsx | 16 +++++++++++++++-
2 files changed, 19 insertions(+), 3 deletions(-)
diff --git a/src/app/community/page.tsx b/src/app/community/page.tsx
index 8e3370c4..3b512c34 100644
--- a/src/app/community/page.tsx
+++ b/src/app/community/page.tsx
@@ -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 (
@@ -39,6 +38,9 @@ const Community = async () => {
);
}
+
+ const events = await api.userMetadata.getEvents();
+
return (
diff --git a/src/components/CommunityEvents.tsx b/src/components/CommunityEvents.tsx
index cca4c013..90c051ee 100644
--- a/src/components/CommunityEvents.tsx
+++ b/src/components/CommunityEvents.tsx
@@ -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) => {