2023-10-27 16:04:58 +02:00
|
|
|
import { useParams } from "@solidjs/router";
|
2024-03-06 00:48:19 +01:00
|
|
|
import { JSXElement, Show, Suspense, createResource } from "solid-js";
|
2023-11-15 07:29:59 +01:00
|
|
|
|
2023-11-22 15:29:27 +01:00
|
|
|
import { loadSpinner } from "../Util/Icons";
|
2024-03-06 00:48:19 +01:00
|
|
|
import { getPost } from "../Util/api";
|
|
|
|
import { CommentSection } from "./CommentSection";
|
2023-11-15 07:29:59 +01:00
|
|
|
import { PostSegment } from "./Posts";
|
2024-03-06 00:48:19 +01:00
|
|
|
import { NewCommentInputArea } from "./NewComment";
|
2023-10-27 16:04:58 +02:00
|
|
|
|
2023-11-13 12:00:46 +01:00
|
|
|
export function SinglePost(): JSXElement {
|
2023-10-27 16:04:58 +02:00
|
|
|
const params = useParams();
|
|
|
|
const [post] = createResource(params.postid, getPost);
|
|
|
|
|
|
|
|
return (
|
2023-11-13 12:10:40 +01:00
|
|
|
<Suspense fallback={loadSpinner()}>
|
2023-11-15 07:29:59 +01:00
|
|
|
<Show when={post()}>
|
|
|
|
<PostSegment post={post()!} />
|
2024-03-06 00:48:19 +01:00
|
|
|
<NewCommentInputArea parentPostId={parseInt(params.postid)}/>
|
|
|
|
<CommentSection postId={params.post_id} />
|
2023-11-15 07:29:59 +01:00
|
|
|
</Show>
|
2023-10-27 16:04:58 +02:00
|
|
|
</Suspense>
|
|
|
|
);
|
|
|
|
}
|