2023-10-25 15:15:56 -04:00
|
|
|
"use client";
|
2023-10-25 12:56:51 -04:00
|
|
|
import { HiSignal } from "react-icons/hi2";
|
2023-10-25 15:15:56 -04:00
|
|
|
import { RiAddFill } from "react-icons/ri";
|
|
|
|
import { Button } from "@/components/ui/button";
|
2023-10-25 12:56:51 -04:00
|
|
|
import Feed from "@/containers/Feed";
|
2023-10-25 15:15:56 -04:00
|
|
|
import CreateKind1Modal from "@/components/Modals/Kind1";
|
|
|
|
|
|
|
|
import useCurrentUser from "@/lib/hooks/useCurrentUser";
|
|
|
|
import { useModal } from "@/app/_providers/modal/provider";
|
2023-10-25 12:56:51 -04:00
|
|
|
|
|
|
|
type AnnouncementsContainerProps = {
|
|
|
|
eventReference: string;
|
2023-10-25 15:15:56 -04:00
|
|
|
hosts: string[];
|
2023-10-25 12:56:51 -04:00
|
|
|
};
|
|
|
|
export default function AnnouncementsContainer({
|
|
|
|
eventReference,
|
2023-10-25 15:15:56 -04:00
|
|
|
hosts,
|
2023-10-25 12:56:51 -04:00
|
|
|
}: AnnouncementsContainerProps) {
|
2023-10-25 15:15:56 -04:00
|
|
|
const modal = useModal();
|
|
|
|
|
|
|
|
const { currentUser } = useCurrentUser();
|
2023-10-25 12:56:51 -04:00
|
|
|
return (
|
|
|
|
<div className="overflow-hidden rounded-[1rem] border bg-muted p-[0.5rem]">
|
2023-10-25 15:15:56 -04:00
|
|
|
<div className="flex items-center justify-between gap-x-3 pb-2 pl-2">
|
|
|
|
<div className="flex items-center gap-x-3">
|
|
|
|
<HiSignal className="h-5 w-5" />
|
|
|
|
<h3 className="text-lg font-semibold">Announcements</h3>
|
|
|
|
</div>
|
|
|
|
{currentUser && hosts.includes(currentUser.pubkey) && (
|
|
|
|
<Button
|
|
|
|
onClick={() =>
|
|
|
|
modal?.show(
|
|
|
|
<CreateKind1Modal
|
|
|
|
tags={[
|
|
|
|
["a", eventReference],
|
|
|
|
["l", "announcement"],
|
|
|
|
]}
|
|
|
|
/>,
|
|
|
|
)
|
|
|
|
}
|
|
|
|
size={"icon"}
|
|
|
|
className="center group h-auto w-auto gap-x-1 rounded-full p-1"
|
|
|
|
>
|
|
|
|
<RiAddFill className="h-5 w-5" />
|
|
|
|
</Button>
|
|
|
|
)}
|
2023-10-25 12:56:51 -04:00
|
|
|
</div>
|
|
|
|
<div className="w-full space-y-3">
|
|
|
|
<Feed
|
|
|
|
filter={{
|
2023-10-25 15:15:56 -04:00
|
|
|
authors: hosts,
|
2023-10-25 12:56:51 -04:00
|
|
|
["#a"]: [eventReference],
|
2023-10-25 15:15:56 -04:00
|
|
|
["#l"]: ["announcement"],
|
2023-10-25 12:56:51 -04:00
|
|
|
}}
|
|
|
|
empty={() => (
|
2023-10-25 15:15:56 -04:00
|
|
|
<div className="py-3 text-center text-sm text-muted-foreground">
|
2023-10-25 12:56:51 -04:00
|
|
|
<p>No Announcements yet</p>
|
|
|
|
</div>
|
|
|
|
)}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|