Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ async function getPosts(id: string, token: string) {
});

if (!res.ok) {
return {
posts: [],
error: `Failed to fetch posts: ${res.status}`,
}
return {
posts: [],
error: `Failed to fetch posts: ${res.status}`,
};
}

const body = await res.json();
Expand All @@ -33,13 +33,13 @@ async function getPosts(id: string, token: string) {
id: post.id.toString(),
})),
error: null,
}
};
} catch (e) {
console.error("Error fetching posts:", e);
return {
posts: [],
error: (e as Error).message,
}
};
}
}

Expand All @@ -49,20 +49,20 @@ export default async function ForumWrapper({
params: Promise<{ id: string; slug: string[] | undefined }>;
}) {
const { id, slug } = await params;
return <Suspense fallback={<PostsForumPage posts={[]} initalPost={undefined} />}>
<Forum id={id} slug={slug} />
</Suspense>
return (
<Suspense fallback={<PostsForumPage posts={[]} initalPost={undefined} />}>
<Forum id={id} slug={slug} />
</Suspense>
);
}


async function Forum({id, slug}: {id: string, slug: string[] | undefined}){

async function Forum({ id, slug }: { id: string; slug: string[] | undefined }) {
const selectPost = slug ? slug[0] : undefined;
const supabase = await createClient();
const token = (await supabase.auth.getSession())?.data.session?.access_token;
if (!token) {
redirect("auth/login");
}
const {posts} = await getPosts(id, token);
const { posts } = await getPosts(id, token);
return <PostsForumPage posts={posts} initalPost={selectPost} />;
}
}
Loading
Loading