From 0ee3b890e346dbfa5c007b1f39dd6a381e9fa11d Mon Sep 17 00:00:00 2001 From: Yumin Cho Date: Wed, 20 Mar 2024 20:20:40 +0900 Subject: [PATCH] feat: add date divider in ChatSection --- .../src/components/organisms/ChatSection.tsx | 23 +++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/packages/web/src/components/organisms/ChatSection.tsx b/packages/web/src/components/organisms/ChatSection.tsx index 9c82a5c3..27618198 100644 --- a/packages/web/src/components/organisms/ChatSection.tsx +++ b/packages/web/src/components/organisms/ChatSection.tsx @@ -1,13 +1,14 @@ import React, { useEffect } from "react"; import styled from "@emotion/styled"; import { useInView } from "react-intersection-observer"; - -import { Text } from "@biseo/web/components/atoms"; +import { formatDate } from "@biseo/web/utils/format"; +import { Divider, Text } from "@biseo/web/components/atoms"; import { ChatHeader, ChatInput, Message, } from "@biseo/web/components/molecules"; +import { margin, round, padding, center, text } from "@biseo/web/styles"; import { useChat } from "@biseo/web/services"; const Container = styled.div` @@ -36,8 +37,22 @@ export const ChatSection: React.FC = () => { - {messages.map(message => ( - + {messages.map((message, index) => ( + <> + + {formatDate(messages[index + 1]?.createdAt) !== + formatDate(message.createdAt) && ( +
+ + + {formatDate(message.createdAt)} + + +
+ )} + ))} {hasMore && (