Skip to content

Commit 3828243

Browse files
authored
feat: display event data in posts (#6041)
1 parent 38e490c commit 3828243

File tree

2 files changed

+45
-0
lines changed

2 files changed

+45
-0
lines changed

apps/web/src/components/Post/PostBody.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { memo } from "react";
77
import Quote from "@/components/Shared/Embed/Quote";
88
import Markup from "@/components/Shared/Markup";
99
import Attachments from "@/components/Shared/Post/Attachments";
10+
import Event from "@/components/Shared/Post/Event";
1011
import Oembed from "@/components/Shared/Post/Oembed";
1112
import PostLink from "@/components/Shared/Post/PostLink";
1213
import Video from "@/components/Shared/Post/Video";
@@ -51,6 +52,7 @@ const PostBody = ({
5152
const showLive = metadata.__typename === "LivestreamMetadata";
5253
// Show attachments if it's there
5354
const showAttachments = filteredAttachments.length > 0 || filteredAsset;
55+
const showEvent = metadata.__typename === "EventMetadata";
5456
// Show sharing link
5557
const showSharingLink = metadata.__typename === "LinkMetadata";
5658
const showOembed =
@@ -90,6 +92,7 @@ const PostBody = ({
9092
) : null}
9193
{showOembed ? <Oembed url={urls[0]} /> : null}
9294
{showSharingLink ? <Oembed url={metadata.sharingLink} /> : null}
95+
{showEvent ? <Event metadata={metadata} /> : null}
9396
{targetPost.quoteOf ? <Quote post={targetPost.quoteOf} /> : null}
9497
</div>
9598
);
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import type { EventMetadataFragment } from "@hey/indexer";
2+
import dayjs from "dayjs";
3+
import { Card, H6 } from "@/components/Shared/UI";
4+
import stopEventPropagation from "@/helpers/stopEventPropagation";
5+
6+
interface EventProps {
7+
metadata: EventMetadataFragment;
8+
}
9+
10+
const Event = ({ metadata }: EventProps) => {
11+
const handleClick = (event: React.MouseEvent<HTMLAnchorElement>) => {
12+
stopEventPropagation(event);
13+
};
14+
15+
return (
16+
<Card className="mt-3 space-y-1 p-3" forceRounded>
17+
{metadata.title ? <H6>{metadata.title}</H6> : null}
18+
<div className="text-gray-500 text-sm dark:text-gray-400">
19+
{dayjs(metadata.startsAt).format("MMM D, YYYY h:mm A")} -{" "}
20+
{dayjs(metadata.endsAt).format("MMM D, YYYY h:mm A")}
21+
</div>
22+
{metadata.location?.physical ? (
23+
<div className="text-gray-500 text-sm dark:text-gray-400">
24+
{metadata.location.physical}
25+
</div>
26+
) : null}
27+
{metadata.location?.virtual ? (
28+
<a
29+
className="block text-indigo-500 text-sm"
30+
href={metadata.location.virtual}
31+
onClick={handleClick}
32+
rel="noreferrer noopener"
33+
target="_blank"
34+
>
35+
{metadata.location.virtual}
36+
</a>
37+
) : null}
38+
</Card>
39+
);
40+
};
41+
42+
export default Event;

0 commit comments

Comments
 (0)