Skip to content

Commit

Permalink
feat: add date divider in ChatSection
Browse files Browse the repository at this point in the history
  • Loading branch information
yumincho committed Mar 20, 2024
1 parent 913b895 commit 0ee3b89
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions packages/web/src/components/organisms/ChatSection.tsx
Original file line number Diff line number Diff line change
@@ -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`
Expand Down Expand Up @@ -36,8 +37,22 @@ export const ChatSection: React.FC = () => {
<Container>
<ChatHeader title="스레드" />
<Message.List ref={scrollRef}>
{messages.map(message => (
<Message key={message.id} message={message} />
{messages.map((message, index) => (
<>
<Message key={message.id} message={message} />
{formatDate(messages[index + 1]?.createdAt) !==
formatDate(message.createdAt) && (
<div
css={[round.xl, padding(8), center, text.body, text.gray500]}
>
<Divider />
<span css={[margin(8), `white-space: nowrap`]}>
{formatDate(message.createdAt)}
</span>
<Divider />
</div>
)}
</>
))}
{hasMore && (
<Text ref={ref} variant="body" color="gray400">
Expand Down

0 comments on commit 0ee3b89

Please sign in to comment.