shoc-frontend-new/src/components/common/comment-timeline-mappers.ts

25 lines
714 B
TypeScript
Raw Normal View History

import type { CommentTimelineItem } from "./comment-timeline";
type CommentSource = {
id: string | number;
userName?: string;
commenter?: string | null;
createdDate?: string;
commenttext: string;
mentions?: string[];
};
export function mapWorkOrderCommentsToTimeline(comments: CommentSource[]): CommentTimelineItem[] {
return comments.map((comment) => ({
id: comment.id,
author: comment.userName || comment.commenter || "System",
createdAt: comment.createdDate,
body: comment.commenttext,
mentions: comment.mentions,
}));
}
export function mapDispatchCommentsToTimeline(comments: CommentSource[]): CommentTimelineItem[] {
return mapWorkOrderCommentsToTimeline(comments);
}