Compare commits
No commits in common. "2fe009042202fba164127928cc1e1f16cc1d365f" and "e04d588b5610884352d8fe948390c05ce93c1c5f" have entirely different histories.
2fe0090422
...
e04d588b56
2 changed files with 11 additions and 14 deletions
|
@ -1,4 +1,4 @@
|
||||||
import { JSXElement, splitProps } from "solid-js";
|
import { JSXElement } from "solid-js";
|
||||||
|
|
||||||
import { PublicComment } from "../Util/api";
|
import { PublicComment } from "../Util/api";
|
||||||
|
|
||||||
|
@ -7,13 +7,12 @@ interface CommentProps {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function Comment(props: CommentProps): JSXElement {
|
export function Comment(props: CommentProps): JSXElement {
|
||||||
const [local] = splitProps(props, ["comment"]);
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div class="py-5">
|
<div class="py-5">
|
||||||
<time class="text-xs opacity-50">{local.comment.created_at}</time>
|
<time class="text-xs opacity-50">{props.comment.created_at}</time>
|
||||||
</div>
|
</div>
|
||||||
<div class="">{local.comment.content}</div>
|
<div class="">{props.comment.content}</div>
|
||||||
<div class="divider" />
|
<div class="divider" />
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|
|
@ -1,18 +1,16 @@
|
||||||
import { For, JSXElement, createResource, splitProps } from "solid-js";
|
import { For, JSXElement, createResource } from "solid-js";
|
||||||
|
|
||||||
import { getComments } from "../Util/api";
|
import { getComments } from "../Util/api";
|
||||||
import { Comment } from "./Comment";
|
import { Comment } from "./Comment";
|
||||||
|
|
||||||
export function CommentSection(postId: { postId: string }): JSXElement {
|
export function CommentSection(props: { postId: string }): JSXElement {
|
||||||
const [local] = splitProps(postId, ["postId"]);
|
const [comments] = createResource(props.postId, () =>
|
||||||
// Not sure why this is a resource, refetch is not implemented
|
getComments(props.postId, 10, 0)
|
||||||
const [state] = createResource(() => getComments(local.postId, 10, 0));
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<section class="my-5 border-b-2 border-b-primary bg-base-200 p-5 ">
|
||||||
<For each={state()} fallback={<div>Loading...</div>}>
|
<For each={comments()!}>{(comment) => <Comment comment={comment} />}</For>
|
||||||
{(comment) => <Comment comment={comment} />}
|
</section>
|
||||||
</For>
|
|
||||||
</div>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue