49 lines
1.4 KiB
TypeScript
Raw Permalink Normal View History

2023-10-14 18:57:37 -04:00
import Container from "./components/Container";
import { CardTitle, CardDescription } from "@/components/ui/card";
2023-10-16 00:57:59 -04:00
import { nip19 } from "nostr-tools";
import { toast } from "sonner";
import { copyText } from "@/lib/utils";
2023-10-16 10:59:28 -04:00
import { RenderText } from "../TextRendering";
import { getTagsValues } from "@/lib/nostr/utils";
import LinkCard from "@/components/LinkCard";
2023-10-20 15:26:55 -04:00
import { type KindCardProps } from "./";
2023-10-16 00:57:59 -04:00
2023-10-20 15:26:55 -04:00
export default function KindDefault(props: KindCardProps) {
2023-10-16 10:59:28 -04:00
const { pubkey, created_at: createdAt, tags } = props;
const r = getTagsValues("r", tags).filter(Boolean);
2023-10-16 00:57:59 -04:00
const npub = nip19.npubEncode(pubkey);
2023-10-14 18:57:37 -04:00
return (
2023-10-16 00:57:59 -04:00
<Container
event={props}
2023-10-16 00:57:59 -04:00
actionOptions={[
{
label: "View profile",
href: `/${npub}`,
type: "link",
},
{
label: "Copy raw data",
type: "button",
onClick: () => {
void copyText(JSON.stringify(props));
toast.success("Copied Text!");
},
},
]}
>
2023-10-16 10:59:28 -04:00
<CardDescription className="text-sm font-normal text-secondary-foreground">
<RenderText text={props.content} />
2023-10-14 18:57:37 -04:00
</CardDescription>
2023-10-16 10:59:28 -04:00
{!!r.length && (
<div className="mt-1.5 flex flex-wrap">
{r.map((url, idx) => (
<LinkCard key={idx} url={url} className="max-w-[250px]" />
))}
</div>
)}
2023-10-14 18:57:37 -04:00
</Container>
);
}