2024-03-12 19:51:41 +01:00
|
|
|
import { JSXElement, Show } from "solid-js";
|
|
|
|
|
|
|
|
import { Post } from "../Util/api";
|
2024-03-19 15:23:12 +01:00
|
|
|
import EngagementButton from "./Buttons/Engegament";
|
2024-03-22 13:30:32 +01:00
|
|
|
import CommentsBUtton from "./Buttons/CommentsButton";
|
2024-03-19 15:23:12 +01:00
|
|
|
import ReportButton from "./Buttons/Report";
|
|
|
|
import ToPostButton from "./Buttons/ToPost";
|
2024-03-22 11:45:52 +01:00
|
|
|
import RemovePostButton from "./Buttons/RemovePostButton";
|
2024-03-12 19:51:41 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* PostSegment is used to display posts in both the main feed and the post view
|
2024-03-18 18:34:11 +01:00
|
|
|
*
|
2024-03-12 19:51:41 +01:00
|
|
|
* @param {Object} props The properties for the PostSegment component.
|
|
|
|
* @param {Post} props.post The post to display.
|
|
|
|
* @returns {JSXElement} A JSXElement of a post
|
|
|
|
*/
|
|
|
|
export function PostSegment({ post }: { post: Post }): JSXElement {
|
|
|
|
const dateOfCreation = new Date(post.createdAt).toDateString();
|
|
|
|
const isEdited = !(post.createdAt == post.updatedAt);
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div class="card compact w-full flex-grow border-b-2 border-b-primary bg-base-200 text-base-content transition-all hover:bg-base-300">
|
|
|
|
<div class="card-body md:mx-6">
|
2024-03-19 15:23:12 +01:00
|
|
|
<div class="flex flex-row justify-between">
|
2024-03-22 11:45:52 +01:00
|
|
|
<p class="text-xs">{dateOfCreation}</p>
|
|
|
|
<details class="dropdown">
|
|
|
|
<summary class="btn m-1">...</summary>
|
|
|
|
<ul class="menu dropdown-content z-[1] w-26 rounded-box bg-base-100 p-2 shadow">
|
|
|
|
<li>
|
|
|
|
<ReportButton />
|
|
|
|
</li>
|
|
|
|
<li>
|
|
|
|
<RemovePostButton post={post}/>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
</details>
|
2024-03-19 15:23:12 +01:00
|
|
|
</div>
|
2024-03-12 19:51:41 +01:00
|
|
|
<Show when={isEdited}>
|
|
|
|
<p>This post has been edited</p>
|
|
|
|
</Show>
|
2024-03-22 11:45:52 +01:00
|
|
|
<p class="my-5 text-base">{post.content}</p>
|
2024-03-12 19:51:41 +01:00
|
|
|
<div class="card-actions justify-between">
|
2024-03-19 15:23:12 +01:00
|
|
|
<div class="flex">
|
|
|
|
<EngagementButton post={post} />
|
2024-03-22 13:30:32 +01:00
|
|
|
<CommentsBUtton post={post} />
|
2024-03-19 15:23:12 +01:00
|
|
|
</div>
|
|
|
|
<ToPostButton post={post} />
|
2024-03-12 19:51:41 +01:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|