2024-06-10 09:43:10 +00:00
|
|
|
"use client";
|
|
|
|
|
2024-01-23 07:58:58 +00:00
|
|
|
import { FC, ReactNode } from "react";
|
|
|
|
import { Network } from "lucide-react";
|
|
|
|
// hooks
|
2024-03-06 13:09:14 +00:00
|
|
|
import { Tooltip } from "@plane/ui";
|
2024-03-19 14:38:35 +00:00
|
|
|
import { renderFormattedTime, renderFormattedDate, calculateTimeAgo } from "@/helpers/date-time.helper";
|
|
|
|
import { useIssueDetail } from "@/hooks/store";
|
|
|
|
import { usePlatformOS } from "@/hooks/use-platform-os";
|
2024-01-23 07:58:58 +00:00
|
|
|
// ui
|
|
|
|
// components
|
|
|
|
import { IssueUser } from "../";
|
|
|
|
// helpers
|
|
|
|
|
|
|
|
type TIssueActivityBlockComponent = {
|
|
|
|
icon?: ReactNode;
|
|
|
|
activityId: string;
|
|
|
|
ends: "top" | "bottom" | undefined;
|
|
|
|
children: ReactNode;
|
2024-02-28 11:23:26 +00:00
|
|
|
customUserName?: string;
|
2024-01-23 07:58:58 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
export const IssueActivityBlockComponent: FC<TIssueActivityBlockComponent> = (props) => {
|
2024-02-28 11:23:26 +00:00
|
|
|
const { icon, activityId, ends, children, customUserName } = props;
|
2024-01-23 07:58:58 +00:00
|
|
|
// hooks
|
|
|
|
const {
|
|
|
|
activity: { getActivityById },
|
|
|
|
} = useIssueDetail();
|
|
|
|
|
|
|
|
const activity = getActivityById(activityId);
|
2024-03-12 15:09:36 +00:00
|
|
|
const { isMobile } = usePlatformOS();
|
2024-01-23 07:58:58 +00:00
|
|
|
if (!activity) return <></>;
|
|
|
|
return (
|
|
|
|
<div
|
|
|
|
className={`relative flex items-center gap-3 text-xs ${
|
|
|
|
ends === "top" ? `pb-2` : ends === "bottom" ? `pt-2` : `py-2`
|
|
|
|
}`}
|
|
|
|
>
|
2024-03-06 13:09:14 +00:00
|
|
|
<div className="absolute left-[13px] top-0 bottom-0 w-0.5 bg-custom-background-80" aria-hidden />
|
2024-02-12 11:31:24 +00:00
|
|
|
<div className="flex-shrink-0 ring-6 w-7 h-7 rounded-full overflow-hidden flex justify-center items-center z-[4] bg-custom-background-80 text-custom-text-200">
|
2024-01-23 07:58:58 +00:00
|
|
|
{icon ? icon : <Network className="w-3.5 h-3.5" />}
|
|
|
|
</div>
|
2024-05-21 11:06:33 +00:00
|
|
|
<div className="w-full truncate text-custom-text-200">
|
2024-02-28 11:23:26 +00:00
|
|
|
<IssueUser activityId={activityId} customUserName={customUserName} />
|
2024-01-23 07:58:58 +00:00
|
|
|
<span> {children} </span>
|
|
|
|
<span>
|
|
|
|
<Tooltip
|
2024-03-12 15:09:36 +00:00
|
|
|
isMobile={isMobile}
|
2024-01-23 07:58:58 +00:00
|
|
|
tooltipContent={`${renderFormattedDate(activity.created_at)}, ${renderFormattedTime(activity.created_at)}`}
|
|
|
|
>
|
|
|
|
<span className="whitespace-nowrap"> {calculateTimeAgo(activity.created_at)}</span>
|
|
|
|
</Tooltip>
|
|
|
|
</span>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|