feat: add feed event item created time

This commit is contained in:
moonrailgun 2024-06-27 20:33:44 +08:00
parent af5f6ad9f5
commit 926ea980ff

View File

@ -1,21 +1,34 @@
import { AppRouterOutput } from '@/api/trpc';
import React from 'react';
import { Badge } from '../ui/badge';
import dayjs from 'dayjs';
import { Tooltip, TooltipContent, TooltipTrigger } from '../ui/tooltip';
type FeedEventItemType = AppRouterOutput['feed']['events'][number];
export const FeedEventItem: React.FC<{ event: FeedEventItemType }> = React.memo(
({ event }) => {
return (
<div className="border-muted rounded-lg border px-4 py-2">
<div className="mb-2">{event.eventName}</div>
<div className="flex flex-wrap gap-2">
<Badge>{event.source}</Badge>
<div className="border-muted flex items-center rounded-lg border px-4 py-2">
<div className="flex-1">
<div className="mb-2">{event.eventName}</div>
<div className="flex flex-wrap gap-2">
<Badge>{event.source}</Badge>
{event.tags.map((tag) => (
<Badge variant="secondary">{tag}</Badge>
))}
{event.tags.map((tag) => (
<Badge variant="secondary">{tag}</Badge>
))}
</div>
</div>
<Tooltip>
<TooltipTrigger className="cursor-default">
<div>{dayjs(event.createdAt).fromNow()}</div>
</TooltipTrigger>
<TooltipContent>
<p>{dayjs(event.createdAt).format('YYYY-MM-DD HH:mm:ss')}</p>
</TooltipContent>
</Tooltip>
</div>
);
}