Skip to content

Commit

Permalink
Merge branch 'fix-button' of https://github.com/emredevsalot/monorepo
Browse files Browse the repository at this point in the history
…into fix-button
  • Loading branch information
emredevsalot committed Aug 22, 2023
2 parents de8e801 + 238e79b commit d150efc
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 13 deletions.
26 changes: 15 additions & 11 deletions apps/kampus/app/pano/PanoFeed.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -42,6 +43,7 @@ const viewerFragment = graphql`
`;

interface Props {
session: Session | null;
panoFeed: PanoFeedFragment$key;
panoViewer: PanoFeed_viewer$key;
}
Expand All @@ -59,17 +61,19 @@ export function PanoFeed(props: Props) {

return (
<>
<Button variant="outline" asChild>
<Link
href={{
pathname: `/post/create`,
search: `foo=bar`,
}}
as="post/create"
>
New post
</Link>
</Button>
{props.session && (
<Button variant="outline" asChild>
<Link
href={{
pathname: `/post/create`,
search: `foo=bar`,
}}
as="post/create"
>
New post
</Link>
</Button>
)}
<Suspense fallback="loading">
<section className="flex flex-col gap-4">
{feed?.edges?.map((edge) => {
Expand Down
4 changes: 3 additions & 1 deletion apps/kampus/app/pano/PostListContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@

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";

import { type PostListContainerQuery } from "./__generated__/PostListContainerQuery.graphql";
import { PanoFeed } from "./PanoFeed";

interface Props {
session: Session | null;
preloadedQuery: SerializablePreloadedQuery<PostListContainerQuery>;
}

Expand All @@ -29,5 +31,5 @@ export const PostListContainer = (props: Props) => {
return null;
}

return <PanoFeed panoFeed={data.viewer} panoViewer={data.viewer} />;
return <PanoFeed session={props.session} panoFeed={data.viewer} panoViewer={data.viewer} />;
};
4 changes: 3 additions & 1 deletion apps/kampus/app/pano/page.tsx
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -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<PostListContainerQuery>(query, {
Expand All @@ -28,7 +30,7 @@ export default async function PostsPage({ searchParams }: { searchParams: { filt
return (
<div className="flex flex-col gap-4">
<PostSortFilters selected={normalized ?? "ALL"} />
<PostListContainer preloadedQuery={preloadedQuery} />
<PostListContainer session={session} preloadedQuery={preloadedQuery} />
</div>
);
}

0 comments on commit d150efc

Please sign in to comment.