diff --git a/web/ee/components/workspace-notifications/notification-card/preview/preview-activity.tsx b/web/ee/components/workspace-notifications/notification-card/preview/preview-activity.tsx index 03864bcc40..910fdd0050 100644 --- a/web/ee/components/workspace-notifications/notification-card/preview/preview-activity.tsx +++ b/web/ee/components/workspace-notifications/notification-card/preview/preview-activity.tsx @@ -2,11 +2,9 @@ import { FC } from "react"; import { TNotification } from "@plane/types"; -import { LiteTextReadOnlyEditor } from "@/components/editor"; // helpers +import { NotificationContent } from "@/components/workspace-notifications"; import { cn } from "@/helpers/common.helper"; -import { renderFormattedDate } from "@/helpers/date-time.helper"; -import { replaceUnderscoreIfSnakeCase, stripAndTruncateHTML } from "@/helpers/string.helper"; // components import { IssueActivityBlock } from "@/plane-web/components/workspace-notifications"; @@ -18,77 +16,6 @@ export type TNotificationPreviewActivity = { projectId: string; }; -const NotificationContent: FC<{ - notification: TNotification; - workspaceId: string; - workspaceSlug: string; - projectId: string; -}> = ({ notification, workspaceId, workspaceSlug, projectId }) => { - const { data, triggered_by_details: triggeredBy } = notification; - const notificationField = data?.issue_activity.field; - const newValue = data?.issue_activity.new_value; - const verb = data?.issue_activity.verb; - - const renderTriggerName = () => ( - - {triggeredBy?.is_bot ? triggeredBy.first_name : triggeredBy?.display_name}{" "} - - ); - - const renderAction = () => { - if (!notificationField) return ""; - if (notificationField === "duplicate") - return verb === "created" - ? "marked that this work item is a duplicate of" - : "marked that this work item is not a duplicate"; - if (notificationField === "relates_to") return "marked that this work item is related to"; - if (notificationField === "comment") return "commented"; - if (notificationField === "archived_at") { - return newValue === "restore" ? "restored the work item" : "archived the work item"; - } - if (notificationField === "None") return null; - - const baseAction = !["comment", "archived_at"].includes(notificationField) ? verb : ""; - return `${baseAction} ${replaceUnderscoreIfSnakeCase(notificationField)}`; - }; - - const renderValue = () => { - if (notificationField === "None") return "the work item and assigned it to you."; - if (notificationField === "comment") return null; - if (notificationField === "target_date" || notificationField === "start_date") return renderFormattedDate(newValue); - if (notificationField === "attachment") return "the work item"; - if (notificationField === "description") return stripAndTruncateHTML(newValue || "", 55); - if (notificationField === "archived_at") return null; - return newValue; - }; - - const shouldShowConnector = !["comment", "archived_at", "None"].includes(notificationField || ""); - - return ( - <> - {renderTriggerName()} - {renderAction()} - {verb !== "deleted" && ( - <> - {shouldShowConnector && to } - {renderValue()}. - {notificationField === "comment" && ( -