1
- import { User } from '@sendbird/chat' ;
2
1
import { ReactNode } from 'react' ;
3
2
import styled from 'styled-components' ;
4
3
5
- import Avatar from '@uikit/ui/Avatar' ;
6
- import Label , { LabelColors , LabelTypography } from '@uikit/ui/Label' ;
7
-
8
4
import BotProfileImage from './BotProfileImage' ;
5
+ import { useChatContext } from './chat/context/ChatProvider' ;
9
6
import { DefaultSentTime , FullBodyContainer , WideSentTime } from './MessageComponent' ;
10
7
import { useConstantState } from '../context/ConstantContext' ;
8
+ import { Label } from '../foundation/components/Label' ;
11
9
import { formatCreatedAtToAMPM } from '../utils/messageTimestamp' ;
12
10
13
11
const Root = styled . span `
14
12
display: flex;
15
13
flex-direction: row;
16
14
align-items: flex-end;
17
- margin-bottom: 6px;
18
15
gap: 8px;
19
16
position: relative;
20
17
` ;
@@ -40,14 +37,11 @@ const EmptyImageContainer = styled.div`
40
37
` ;
41
38
42
39
type Props = {
43
- botUser ?: User ;
44
40
createdAt ?: number ;
45
41
messageData ?: string ;
46
42
bodyComponent : ReactNode ;
47
43
chainTop ?: boolean ;
48
44
chainBottom ?: boolean ;
49
- messageCount ?: number ;
50
- zIndex ?: number ;
51
45
messageFeedback ?: ReactNode ;
52
46
wideContainer ?: boolean ;
53
47
} ;
@@ -59,46 +53,33 @@ const HEIGHTS = {
59
53
} ;
60
54
61
55
export default function BotMessageWithBodyInput ( props : Props ) {
56
+ const { botUser } = useChatContext ( ) ;
62
57
const { botStudioEditProps, dateLocale } = useConstantState ( ) ;
63
58
64
- const {
65
- botUser,
66
- createdAt,
67
- bodyComponent,
68
- messageCount,
69
- zIndex,
70
- chainTop,
71
- chainBottom,
72
- messageFeedback,
73
- wideContainer = false ,
74
- } = props ;
59
+ const { createdAt, bodyComponent, chainTop, chainBottom, messageFeedback, wideContainer = false } = props ;
75
60
76
61
const profilePaddingBottom = ( messageFeedback ? HEIGHTS . FEEDBACK : 0 ) + ( wideContainer ? HEIGHTS . TIMESTAMP : 0 ) ;
77
62
78
63
const nonChainedMessage = chainTop == null && chainBottom == null ;
79
- const displayProfileImage = nonChainedMessage || chainBottom ;
80
64
const displaySender = nonChainedMessage || chainTop ;
65
+ const displayProfileImage = nonChainedMessage || chainBottom ;
81
66
const { profileUrl, nickname } = botStudioEditProps ?. botInfo ?? { } ;
82
67
const botProfileUrl = profileUrl ?? botUser ?. profileUrl ;
83
68
const botNickname = nickname ?? botUser ?. nickname ;
84
69
85
70
return (
86
- < Root style = { { zIndex : messageCount === 1 && zIndex ? zIndex : 0 } } >
71
+ < Root >
87
72
{ displayProfileImage ? (
88
73
< div style = { { paddingBottom : profilePaddingBottom } } >
89
- { botProfileUrl != null && botProfileUrl != '' ? (
90
- < Avatar src = { botProfileUrl } alt = "botProfileImage" height = "28px" width = "28px" />
91
- ) : (
92
- < BotProfileImage width = { 28 } height = { 28 } iconWidth = { 16 } iconHeight = { 16 } />
93
- ) }
74
+ < BotProfileImage size = { 28 } profileUrl = { botProfileUrl } />
94
75
</ div >
95
76
) : (
96
77
< EmptyImageContainer />
97
78
) }
98
79
< FullBodyContainer >
99
80
{ displaySender && (
100
81
< Sender >
101
- < Label type = { LabelTypography . CAPTION_2 } color = { LabelColors . ONBACKGROUND_2 } >
82
+ < Label type = { 'caption2' } color = { 'onbackground2' } >
102
83
{ botNickname }
103
84
</ Label >
104
85
</ Sender >
0 commit comments