From 238e79b3c4c237a07ad42c9635573fcbab7669d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emre=20Erg=C3=BCl?= Date: Mon, 21 Aug 2023 14:30:10 +0300 Subject: [PATCH] fix(apps/pano): "New post" button appears without login --- apps/kampus/app/pano/PanoFeed.tsx | 26 +++++++++++++--------- apps/kampus/app/pano/PostListContainer.tsx | 4 +++- apps/kampus/app/pano/page.tsx | 4 +++- 3 files changed, 21 insertions(+), 13 deletions(-) diff --git a/apps/kampus/app/pano/PanoFeed.tsx b/apps/kampus/app/pano/PanoFeed.tsx index fdfaf347..beac3b7f 100644 --- a/apps/kampus/app/pano/PanoFeed.tsx +++ b/apps/kampus/app/pano/PanoFeed.tsx @@ -3,6 +3,7 @@ import Link from "next/link"; import { graphql, useFragment, usePaginationFragment } from "react-relay"; import { Button } from "@kampus/ui"; +import { Session } from "@kampus/next-auth"; import { PostItem } from "~/app/pano/features/post-list/PostItem"; import { type PanoFeed_viewer$key } from "./__generated__/PanoFeed_viewer.graphql"; @@ -39,6 +40,7 @@ const viewerFragment = graphql` `; interface Props { + session: Session | null; panoFeed: PanoFeedFragment$key; panoViewer: PanoFeed_viewer$key; } @@ -54,17 +56,19 @@ export function PanoFeed(props: Props) { return ( <> - + {props.session && ( + + )}
{feed?.edges?.map((edge) => { diff --git a/apps/kampus/app/pano/PostListContainer.tsx b/apps/kampus/app/pano/PostListContainer.tsx index c10b62e9..85b22b86 100644 --- a/apps/kampus/app/pano/PostListContainer.tsx +++ b/apps/kampus/app/pano/PostListContainer.tsx @@ -2,6 +2,7 @@ import { graphql, usePreloadedQuery } from "react-relay"; +import { Session } from "@kampus/next-auth"; import { type SerializablePreloadedQuery } from "@kampus/relay"; import useSerializablePreloadedQuery from "@kampus/relay/use-serializable-preloaded-query"; @@ -9,6 +10,7 @@ import { type PostListContainerQuery } from "./__generated__/PostListContainerQu import { PanoFeed } from "./PanoFeed"; interface Props { + session: Session | null; preloadedQuery: SerializablePreloadedQuery; } @@ -29,5 +31,5 @@ export const PostListContainer = (props: Props) => { return null; } - return ; + return ; }; diff --git a/apps/kampus/app/pano/page.tsx b/apps/kampus/app/pano/page.tsx index 51378b2d..badd056c 100644 --- a/apps/kampus/app/pano/page.tsx +++ b/apps/kampus/app/pano/page.tsx @@ -1,3 +1,4 @@ +import { getServerSession } from "@kampus/next-auth"; import loadSerializableQuery from "@kampus/relay/load-serializable-query"; import { PostSortFilters } from "~/app/pano/features/post-filter/PostSortFilters"; @@ -19,6 +20,7 @@ const normalizeFilter = (query?: string): PanoPostFilterType | null => { }; export default async function PostsPage({ searchParams }: { searchParams: { filter?: string } }) { + const session = await getServerSession(); const normalized = normalizeFilter(searchParams.filter); const preloadedQuery = await loadSerializableQuery(query, { @@ -28,7 +30,7 @@ export default async function PostsPage({ searchParams }: { searchParams: { filt return (
- +
); }