Skip to content

Commit

Permalink
get rid of first trial
Browse files Browse the repository at this point in the history
  • Loading branch information
emredevsalot committed Aug 22, 2023
1 parent d150efc commit c38b63b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 21 deletions.
26 changes: 11 additions & 15 deletions apps/kampus/app/pano/PanoFeed.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ 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 @@ -43,7 +42,6 @@ const viewerFragment = graphql`
`;

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

return (
<>
{props.session && (
<Button variant="outline" asChild>
<Link
href={{
pathname: `/post/create`,
search: `foo=bar`,
}}
as="post/create"
>
New post
</Link>
</Button>
)}
<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: 1 addition & 3 deletions apps/kampus/app/pano/PostListContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,13 @@

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 @@ -31,5 +29,5 @@ export const PostListContainer = (props: Props) => {
return null;
}

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

0 comments on commit c38b63b

Please sign in to comment.