From 8286c180208119e6c8da469ffa5fa543621615f2 Mon Sep 17 00:00:00 2001 From: N-Pex Date: Wed, 9 Oct 2024 15:09:24 +0200 Subject: [PATCH] Add day markers between articles --- .../[id]/@detail/_components/TicketDetail.tsx | 10 +++++-- apps/link/app/_styles/global.css | 29 +++++++++++++++++++ 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/apps/link/app/(main)/tickets/[id]/@detail/_components/TicketDetail.tsx b/apps/link/app/(main)/tickets/[id]/@detail/_components/TicketDetail.tsx index 88896d5..e4d0b03 100644 --- a/apps/link/app/(main)/tickets/[id]/@detail/_components/TicketDetail.tsx +++ b/apps/link/app/(main)/tickets/[id]/@detail/_components/TicketDetail.tsx @@ -113,7 +113,12 @@ export const TicketDetail: FC = ({ id }) => { ).toLocaleDateString()})`} - {ticketArticles.edges.map(({ node: article }: any) => ( + {ticketArticles.edges.map(({ node: article }: any, index: number) => { + const thisDate = new Date(ticketArticles.edges[index].node.updatedAt).toLocaleDateString(); + const lastDate = index > 0 ? new Date(ticketArticles.edges[index - 1].node.updatedAt).toLocaleDateString() : "" + return ( + <> + {thisDate !== lastDate ? ({thisDate}) : (null)} = ({ id }) => { article.sender === "Agent" ? "outgoing" : "incoming" } /> - ))} + + )})}