agx-chat-web 1.2.1 → 1.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agx-chat.esm.js +1 -1
- package/dist/agx-chat.esm.js.map +1 -1
- package/package.json +2 -3
- package/src/__tests__/app/Messenger/classes/slaCalculations.spec.ts +0 -122
- package/src/app/ChatProvider/ChatProvider.tsx +0 -20
- package/src/app/Messenger/classes/slaCalculations.ts +0 -197
- package/src/app/Messenger/components/ChatButton/ChatButton.tsx +0 -64
- package/src/app/Messenger/components/ChatTabs/ChatTabs.less +0 -18
- package/src/app/Messenger/components/ChatTabs/ChatTabs.tsx +0 -32
- package/src/app/Messenger/components/DocMessage/DocMessage.less +0 -71
- package/src/app/Messenger/components/DocMessage/DocMessage.tsx +0 -50
- package/src/app/Messenger/components/ImagesContainer/ImagesContainer.less +0 -79
- package/src/app/Messenger/components/ImagesContainer/ImagesContainer.tsx +0 -51
- package/src/app/Messenger/components/IncomingMessage/IncomingMessage.tsx +0 -170
- package/src/app/Messenger/components/InfiniteScroll/InfiniteScroll.tsx +0 -80
- package/src/app/Messenger/components/InputFile/InputFile.tsx +0 -147
- package/src/app/Messenger/components/InputFile/inputFile.less +0 -59
- package/src/app/Messenger/components/MessageBallon/MessageBalloon.tsx +0 -100
- package/src/app/Messenger/components/MessengerAvatar/MessengerAvatar.tsx +0 -29
- package/src/app/Messenger/components/MessengerThemeWrapper/MessengerThemeWrapper.tsx +0 -62
- package/src/app/Messenger/components/RenderFileIcon/RenderFileIcon.tsx +0 -40
- package/src/app/Messenger/components/SearchInput/SearchInput.less +0 -45
- package/src/app/Messenger/components/SearchInput/SearchInput.tsx +0 -77
- package/src/app/Messenger/components/Select/Select.less +0 -22
- package/src/app/Messenger/components/Select/Select.tsx +0 -56
- package/src/app/Messenger/components/SendMessageForm/SendMessageForm.tsx +0 -254
- package/src/app/Messenger/components/SenderMessages/SenderMessages.tsx +0 -91
- package/src/app/Messenger/components/SystemMessage/SystemMessage.tsx +0 -25
- package/src/app/Messenger/components/TextArea/TextArea.tsx +0 -35
- package/src/app/Messenger/components/TextArea/Textarea.less +0 -22
- package/src/app/Messenger/components/Tooltip/Tooltip.less +0 -27
- package/src/app/Messenger/components/Tooltip/Tooltip.tsx +0 -17
- package/src/app/Messenger/hooks/useConversations.tsx +0 -143
- package/src/app/Messenger/hooks/useMessages.tsx +0 -49
- package/src/app/Messenger/hooks/useThemes.tsx +0 -14
- package/src/app/Messenger/icons/AttachFileIcon.tsx +0 -20
- package/src/app/Messenger/icons/CSVFileIcon.tsx +0 -26
- package/src/app/Messenger/icons/CloseIcon.tsx +0 -20
- package/src/app/Messenger/icons/DOCFileIcon.tsx +0 -54
- package/src/app/Messenger/icons/DownloadMinimalistIcon.tsx +0 -37
- package/src/app/Messenger/icons/EmptyIcon.tsx +0 -20
- package/src/app/Messenger/icons/MP4FileIcon.tsx +0 -26
- package/src/app/Messenger/icons/MessageIcon.tsx +0 -27
- package/src/app/Messenger/icons/PDFFileIcon.tsx +0 -54
- package/src/app/Messenger/icons/ReadIcon.tsx +0 -18
- package/src/app/Messenger/icons/SearchIcon.tsx +0 -20
- package/src/app/Messenger/icons/TimerIcon.tsx +0 -18
- package/src/app/Messenger/icons/TrashIcon.tsx +0 -21
- package/src/app/Messenger/views/Messenger.less +0 -623
- package/src/app/Messenger/views/MessengerList.tsx +0 -170
- package/src/app/Messenger/views/MessengerListItem.tsx +0 -178
- package/src/app/Messenger/views/MessengerMessages.tsx +0 -414
- package/src/app/Messenger/views/NewFormChat.tsx +0 -145
- package/src/app/i18n/index.ts +0 -36
- package/src/app/i18n/locales/en.json +0 -64
- package/src/app/i18n/locales/pt.json +0 -64
- package/src/assets/right-arrow.svg +0 -10
- package/src/index.ts +0 -23
- package/src/react-app-env.d.ts +0 -19
- package/src/setupTests.ts +0 -5
- package/src/styles/abstracts/animations.less +0 -8
- package/src/styles/abstracts/mixins.less +0 -5
- package/src/styles/abstracts/variables.less +0 -31
- package/src/styles/base/base.less +0 -6
- package/src/styles/index.less +0 -5
- package/src/types.ts +0 -174
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import React, { useEffect, useState } from 'react'
|
|
2
|
-
import { IImagesContainer } from 'types'
|
|
3
|
-
import RenderFileIcon from '../RenderFileIcon/RenderFileIcon'
|
|
4
|
-
|
|
5
|
-
function ImagesContainer ({ file, onClose }: IImagesContainer) {
|
|
6
|
-
const [fileInfo, setFileInfo] = useState<{ name: string; type: string }>({
|
|
7
|
-
name: '',
|
|
8
|
-
type: '',
|
|
9
|
-
})
|
|
10
|
-
|
|
11
|
-
const [b64, setB64] = useState<string>('')
|
|
12
|
-
|
|
13
|
-
useEffect(() => {
|
|
14
|
-
function getBase64 (file: File) {
|
|
15
|
-
return new Promise((resolve, reject) => {
|
|
16
|
-
const reader = new FileReader()
|
|
17
|
-
reader.readAsDataURL(file)
|
|
18
|
-
reader.onload = () => resolve(reader.result)
|
|
19
|
-
reader.onerror = (error) => reject(error)
|
|
20
|
-
})
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
if (file) getBase64(file).then((base64) => setB64(base64 as string))
|
|
24
|
-
}, [file])
|
|
25
|
-
|
|
26
|
-
useEffect(() => {
|
|
27
|
-
if (file) {
|
|
28
|
-
setFileInfo({
|
|
29
|
-
name: file.name,
|
|
30
|
-
type: file.type,
|
|
31
|
-
})
|
|
32
|
-
}
|
|
33
|
-
}, [file])
|
|
34
|
-
|
|
35
|
-
return (
|
|
36
|
-
<div className='images-container'>
|
|
37
|
-
<div className='images-container__close'>
|
|
38
|
-
<button className='images-container__close--icon' onClick={onClose} />
|
|
39
|
-
</div>
|
|
40
|
-
|
|
41
|
-
<div className='images-container__container'>
|
|
42
|
-
<div className='images-container__image'>
|
|
43
|
-
<RenderFileIcon fileType={fileInfo.type} b64={b64} />
|
|
44
|
-
<span className='images-container__title-img'>{fileInfo.name}</span>
|
|
45
|
-
</div>
|
|
46
|
-
</div>
|
|
47
|
-
</div>
|
|
48
|
-
)
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
export default ImagesContainer
|
|
@@ -1,170 +0,0 @@
|
|
|
1
|
-
import useTheme from '../../hooks/useThemes'
|
|
2
|
-
import React, { useCallback, useState } from 'react'
|
|
3
|
-
import { Iimages, IInconmingMessage } from 'types'
|
|
4
|
-
import MessengerAvatar from '../MessengerAvatar/MessengerAvatar'
|
|
5
|
-
import ReactSimpleImageViewer from '../../../../../node_modules/react-simple-image-viewer'
|
|
6
|
-
import DocMessage from '../DocMessage/DocMessage'
|
|
7
|
-
import { useTranslation } from 'react-i18next'
|
|
8
|
-
|
|
9
|
-
interface IMessagesWithFile {
|
|
10
|
-
file:
|
|
11
|
-
| Iimages
|
|
12
|
-
| {
|
|
13
|
-
contentType: string
|
|
14
|
-
location: string
|
|
15
|
-
mimetype: string
|
|
16
|
-
originalname: string
|
|
17
|
-
size?: number
|
|
18
|
-
pages?: number
|
|
19
|
-
key?: string
|
|
20
|
-
}
|
|
21
|
-
| undefined
|
|
22
|
-
message: string
|
|
23
|
-
date: string
|
|
24
|
-
openImageViewer: (index: number) => void
|
|
25
|
-
id: string
|
|
26
|
-
formatDate: (date: string | Date) => string | undefined
|
|
27
|
-
currentImage: number
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export const MessageImage = ({ ...rest }) => {
|
|
31
|
-
const { t } = useTranslation('messengerMessages')
|
|
32
|
-
return (
|
|
33
|
-
<div className='messenger__message--file'>
|
|
34
|
-
<img
|
|
35
|
-
{...rest}
|
|
36
|
-
width={200}
|
|
37
|
-
height={200}
|
|
38
|
-
alt={t('incommingMessage.messageImage')}
|
|
39
|
-
/>
|
|
40
|
-
</div>
|
|
41
|
-
)
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
const MessageWithFile = ({
|
|
45
|
-
file,
|
|
46
|
-
message,
|
|
47
|
-
date,
|
|
48
|
-
openImageViewer,
|
|
49
|
-
id,
|
|
50
|
-
formatDate,
|
|
51
|
-
currentImage,
|
|
52
|
-
}: IMessagesWithFile) => {
|
|
53
|
-
const isImage = (
|
|
54
|
-
file:
|
|
55
|
-
| {
|
|
56
|
-
contentType: string
|
|
57
|
-
location: string
|
|
58
|
-
mimetype: string
|
|
59
|
-
originalname: string
|
|
60
|
-
size?: number
|
|
61
|
-
pages?: number
|
|
62
|
-
key?: string
|
|
63
|
-
}
|
|
64
|
-
| Iimages
|
|
65
|
-
| undefined
|
|
66
|
-
): file is Iimages => {
|
|
67
|
-
if (!file) return false
|
|
68
|
-
if (['image/png', 'image/jpeg'].includes(file?.mimetype ?? '')) {
|
|
69
|
-
return true
|
|
70
|
-
}
|
|
71
|
-
return false
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
return (
|
|
75
|
-
<>
|
|
76
|
-
{isImage(file) ? (
|
|
77
|
-
<MessageImage
|
|
78
|
-
src={file?.location}
|
|
79
|
-
onClick={() => openImageViewer(currentImage)}
|
|
80
|
-
/>
|
|
81
|
-
) : (
|
|
82
|
-
file && (
|
|
83
|
-
<DocMessage
|
|
84
|
-
file={file}
|
|
85
|
-
message={message}
|
|
86
|
-
date={date}
|
|
87
|
-
read={false}
|
|
88
|
-
id={id}
|
|
89
|
-
formatDate={formatDate}
|
|
90
|
-
/>
|
|
91
|
-
)
|
|
92
|
-
)}
|
|
93
|
-
</>
|
|
94
|
-
)
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
function IncomingMessage ({
|
|
98
|
-
date,
|
|
99
|
-
message,
|
|
100
|
-
user,
|
|
101
|
-
hasFile,
|
|
102
|
-
file,
|
|
103
|
-
isSystemMessage,
|
|
104
|
-
formatDate,
|
|
105
|
-
id,
|
|
106
|
-
}: IInconmingMessage) {
|
|
107
|
-
const { theme } = useTheme()
|
|
108
|
-
const [currentImage, setCurrentImage] = useState(0)
|
|
109
|
-
const [isViewerOpen, setIsViewerOpen] = useState(false)
|
|
110
|
-
|
|
111
|
-
const openImageViewer = useCallback((index: number) => {
|
|
112
|
-
setCurrentImage(index)
|
|
113
|
-
setIsViewerOpen(true)
|
|
114
|
-
}, [])
|
|
115
|
-
|
|
116
|
-
const closeImageViewer = () => {
|
|
117
|
-
setCurrentImage(0)
|
|
118
|
-
setIsViewerOpen(false)
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
return (
|
|
122
|
-
<div className='messenger__messages-row--received' id={id}>
|
|
123
|
-
{(user.avatar || user.name) && !isSystemMessage && (
|
|
124
|
-
<div className='messenger__message-avatar mr-2'>
|
|
125
|
-
<MessengerAvatar image={user.avatar}>
|
|
126
|
-
{user.name.slice(0, 1)}
|
|
127
|
-
</MessengerAvatar>
|
|
128
|
-
</div>
|
|
129
|
-
)}
|
|
130
|
-
|
|
131
|
-
<div
|
|
132
|
-
className='messenger__messages-received'
|
|
133
|
-
style={{ background: theme?.messengerIncomerColor }}
|
|
134
|
-
>
|
|
135
|
-
{!isSystemMessage && (
|
|
136
|
-
<p className='messenger__message-title'>{user.name}</p>
|
|
137
|
-
)}
|
|
138
|
-
|
|
139
|
-
<span>
|
|
140
|
-
{hasFile && (
|
|
141
|
-
<MessageWithFile
|
|
142
|
-
file={file}
|
|
143
|
-
message={message}
|
|
144
|
-
date={date}
|
|
145
|
-
openImageViewer={openImageViewer}
|
|
146
|
-
id={id}
|
|
147
|
-
formatDate={formatDate}
|
|
148
|
-
currentImage={currentImage}
|
|
149
|
-
/>
|
|
150
|
-
)}
|
|
151
|
-
{message && <p className='messenger__message'>{message}</p>}
|
|
152
|
-
<p className='messenger__message--date'>
|
|
153
|
-
{formatDate(date) ?? new Date(date).toLocaleString()}
|
|
154
|
-
</p>
|
|
155
|
-
</span>
|
|
156
|
-
</div>
|
|
157
|
-
{file && isViewerOpen && (
|
|
158
|
-
<ReactSimpleImageViewer
|
|
159
|
-
src={[file.location]}
|
|
160
|
-
currentIndex={0}
|
|
161
|
-
disableScroll={false}
|
|
162
|
-
closeOnClickOutside={true}
|
|
163
|
-
onClose={closeImageViewer}
|
|
164
|
-
/>
|
|
165
|
-
)}
|
|
166
|
-
</div>
|
|
167
|
-
)
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
export default IncomingMessage
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import React, { ReactNode, CSSProperties } from 'react'
|
|
2
|
-
|
|
3
|
-
interface IInfiniteScroll {
|
|
4
|
-
loading: boolean
|
|
5
|
-
more: boolean
|
|
6
|
-
fetch: () => void
|
|
7
|
-
children: ReactNode
|
|
8
|
-
loadingCover: React.ReactElement
|
|
9
|
-
root: Element | null
|
|
10
|
-
reverse?: boolean
|
|
11
|
-
rootMargin?: number
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
const intersectDivStyle: CSSProperties = {
|
|
15
|
-
width: 25,
|
|
16
|
-
height: 25,
|
|
17
|
-
visibility: 'hidden',
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
function InfiniteScroll ({
|
|
21
|
-
loading,
|
|
22
|
-
loadingCover,
|
|
23
|
-
more,
|
|
24
|
-
fetch,
|
|
25
|
-
children,
|
|
26
|
-
root,
|
|
27
|
-
reverse = false,
|
|
28
|
-
rootMargin = 400,
|
|
29
|
-
}: IInfiniteScroll) {
|
|
30
|
-
const [infiniteElement, setInfiniteElement] =
|
|
31
|
-
React.useState<HTMLDivElement | null>(null)
|
|
32
|
-
|
|
33
|
-
React.useEffect(() => {
|
|
34
|
-
if (!root) return
|
|
35
|
-
const currentElement = infiniteElement
|
|
36
|
-
const observer = new IntersectionObserver(
|
|
37
|
-
(entries) => {
|
|
38
|
-
const first = entries[0]
|
|
39
|
-
if (first.isIntersecting === true) fetch()
|
|
40
|
-
},
|
|
41
|
-
{
|
|
42
|
-
root,
|
|
43
|
-
rootMargin: rootMargin.toString() + 'px',
|
|
44
|
-
threshold: 0.5,
|
|
45
|
-
}
|
|
46
|
-
)
|
|
47
|
-
|
|
48
|
-
if (currentElement) {
|
|
49
|
-
observer.observe(currentElement)
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
return () => {
|
|
53
|
-
if (currentElement) observer.unobserve(currentElement)
|
|
54
|
-
}
|
|
55
|
-
}, [infiniteElement])
|
|
56
|
-
|
|
57
|
-
if (reverse) {
|
|
58
|
-
return (
|
|
59
|
-
<>
|
|
60
|
-
{more && !loading && (
|
|
61
|
-
<div ref={setInfiniteElement} style={intersectDivStyle}></div>
|
|
62
|
-
)}
|
|
63
|
-
{loading && loadingCover}
|
|
64
|
-
{children}
|
|
65
|
-
</>
|
|
66
|
-
)
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
return (
|
|
70
|
-
<>
|
|
71
|
-
{children}
|
|
72
|
-
{loading && loadingCover}
|
|
73
|
-
{more && !loading && (
|
|
74
|
-
<div ref={setInfiniteElement} style={intersectDivStyle}></div>
|
|
75
|
-
)}
|
|
76
|
-
</>
|
|
77
|
-
)
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
export default InfiniteScroll
|
|
@@ -1,147 +0,0 @@
|
|
|
1
|
-
import TrashIcon from '../../icons/TrashIcon'
|
|
2
|
-
import React, { useMemo } from 'react'
|
|
3
|
-
import useTheme from '../../hooks/useThemes'
|
|
4
|
-
import { useTranslation } from 'react-i18next'
|
|
5
|
-
|
|
6
|
-
interface IProps {
|
|
7
|
-
fileList: File[]
|
|
8
|
-
onUpdateFile: (files: File) => void
|
|
9
|
-
label: string
|
|
10
|
-
onRemoveFile: (files: File) => void
|
|
11
|
-
maxSize: string
|
|
12
|
-
loading: boolean
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
function InputFile ({
|
|
16
|
-
fileList,
|
|
17
|
-
onUpdateFile,
|
|
18
|
-
label,
|
|
19
|
-
onRemoveFile,
|
|
20
|
-
maxSize,
|
|
21
|
-
loading,
|
|
22
|
-
}: IProps) {
|
|
23
|
-
const { theme } = useTheme()
|
|
24
|
-
const { t } = useTranslation('newFormChat')
|
|
25
|
-
|
|
26
|
-
const validateFileType = useMemo(
|
|
27
|
-
() => (allowedTypes: string[], file?: File) => {
|
|
28
|
-
if (file?.type) {
|
|
29
|
-
return allowedTypes.includes(file.type)
|
|
30
|
-
}
|
|
31
|
-
const extension = file?.name.split('.').pop()?.toLowerCase()
|
|
32
|
-
return extension ? allowedTypes.includes(`.${extension}`) : false
|
|
33
|
-
},
|
|
34
|
-
[]
|
|
35
|
-
)
|
|
36
|
-
|
|
37
|
-
const onUpload = () => {
|
|
38
|
-
const input = document.querySelector('.file-input__input') as HTMLElement
|
|
39
|
-
input?.click()
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
const onChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
|
43
|
-
const file = e?.target?.files?.[0]
|
|
44
|
-
|
|
45
|
-
const isAllowedType = validateFileType(
|
|
46
|
-
[
|
|
47
|
-
'image/png',
|
|
48
|
-
'image/jpeg',
|
|
49
|
-
'application/pdf',
|
|
50
|
-
'application/msword',
|
|
51
|
-
'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
|
|
52
|
-
'text/csv',
|
|
53
|
-
'video/mp4',
|
|
54
|
-
],
|
|
55
|
-
file
|
|
56
|
-
)
|
|
57
|
-
if (!isAllowedType) {
|
|
58
|
-
console.error(t('inputFile.documentSendError'))
|
|
59
|
-
return false
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
if (file) onUpdateFile(file)
|
|
63
|
-
return true
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
const removeItem = (file: File) => {
|
|
67
|
-
if (fileList.some((item) => item === file)) {
|
|
68
|
-
onRemoveFile(file)
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
return (
|
|
73
|
-
<>
|
|
74
|
-
<div className='file-input'>
|
|
75
|
-
<label
|
|
76
|
-
style={{ color: theme.newChatFormTexts }}
|
|
77
|
-
htmlFor=''
|
|
78
|
-
className='file-input__label'
|
|
79
|
-
>
|
|
80
|
-
{label}
|
|
81
|
-
</label>
|
|
82
|
-
<div
|
|
83
|
-
className='file-input__container'
|
|
84
|
-
style={{
|
|
85
|
-
backgroundColor: theme.inputBg,
|
|
86
|
-
color: theme.newChatFormTexts,
|
|
87
|
-
}}
|
|
88
|
-
>
|
|
89
|
-
<input
|
|
90
|
-
className='file-input__input'
|
|
91
|
-
type='file'
|
|
92
|
-
id='docpicker'
|
|
93
|
-
hidden
|
|
94
|
-
accept='.jpg, .jpeg, .png, .pdf, .doc, .docx, .csv, .mp4'
|
|
95
|
-
onChange={(event) => onChange(event)}
|
|
96
|
-
/>
|
|
97
|
-
|
|
98
|
-
<h4>{t('inputFile.chooseFile')}</h4>
|
|
99
|
-
<button
|
|
100
|
-
className='file-input__button'
|
|
101
|
-
type='button'
|
|
102
|
-
onClick={onUpload}
|
|
103
|
-
style={{
|
|
104
|
-
background: theme?.buttonPrimary,
|
|
105
|
-
color: theme?.buttonPrimaryText,
|
|
106
|
-
}}
|
|
107
|
-
>
|
|
108
|
-
{t('inputFile.chooseFile')}
|
|
109
|
-
</button>
|
|
110
|
-
|
|
111
|
-
{loading ? (
|
|
112
|
-
''
|
|
113
|
-
) : (
|
|
114
|
-
<p>
|
|
115
|
-
{t('inputFile.allowDocuments')}(
|
|
116
|
-
{t('inputFile.allowSizeDocument', { maxSize })})
|
|
117
|
-
</p>
|
|
118
|
-
)}
|
|
119
|
-
</div>
|
|
120
|
-
</div>
|
|
121
|
-
|
|
122
|
-
<div>
|
|
123
|
-
{fileList &&
|
|
124
|
-
fileList.map((item) => (
|
|
125
|
-
<div
|
|
126
|
-
className='file-input__list'
|
|
127
|
-
key={item.name}
|
|
128
|
-
style={{
|
|
129
|
-
backgroundColor: theme.inputBg,
|
|
130
|
-
color: theme.newChatFormTexts,
|
|
131
|
-
}}
|
|
132
|
-
>
|
|
133
|
-
<span className='file-input__list--file-name'>{item.name}</span>
|
|
134
|
-
<button
|
|
135
|
-
className='file-input__delete'
|
|
136
|
-
onClick={() => removeItem(item)}
|
|
137
|
-
>
|
|
138
|
-
<TrashIcon color={theme.newChatFormDeleteFileButton || 'red'} />
|
|
139
|
-
</button>
|
|
140
|
-
</div>
|
|
141
|
-
))}
|
|
142
|
-
</div>
|
|
143
|
-
</>
|
|
144
|
-
)
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
export default InputFile
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
.file-input {
|
|
2
|
-
margin-bottom: 1rem;
|
|
3
|
-
width: 100%;
|
|
4
|
-
|
|
5
|
-
&__label {
|
|
6
|
-
color: @title-form-color;
|
|
7
|
-
font-weight: bold;
|
|
8
|
-
margin: 0.5rem;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
&__container {
|
|
12
|
-
align-items: center;
|
|
13
|
-
background-color: var(--secondary-color);
|
|
14
|
-
border-radius: 10px;
|
|
15
|
-
display: flex;
|
|
16
|
-
flex-direction: column;
|
|
17
|
-
justify-content: center;
|
|
18
|
-
margin-top: 0.5rem;
|
|
19
|
-
padding: 1rem;
|
|
20
|
-
width: 100%;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
&__button {
|
|
24
|
-
border: none;
|
|
25
|
-
border-radius: 30px;
|
|
26
|
-
color: var(--secondary-color);
|
|
27
|
-
cursor: pointer;
|
|
28
|
-
font-size: 1rem;
|
|
29
|
-
font-weight: bold;
|
|
30
|
-
margin: 0.5rem 1rem;
|
|
31
|
-
padding: 0.5rem;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
&__list {
|
|
35
|
-
align-items: center;
|
|
36
|
-
background-color: var(--secondary-color);
|
|
37
|
-
border-radius: 10px;
|
|
38
|
-
display: flex;
|
|
39
|
-
justify-content: space-between;
|
|
40
|
-
margin: 0.5rem 0;
|
|
41
|
-
padding: 0.5rem;
|
|
42
|
-
|
|
43
|
-
&--file-name {
|
|
44
|
-
overflow: hidden;
|
|
45
|
-
text-overflow: ellipsis;
|
|
46
|
-
white-space: nowrap;
|
|
47
|
-
max-width: 100%;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
&__delete {
|
|
52
|
-
align-items: center;
|
|
53
|
-
background: transparent;
|
|
54
|
-
border: none;
|
|
55
|
-
cursor: pointer;
|
|
56
|
-
display: flex;
|
|
57
|
-
justify-content: center;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
|
-
import { Iimages, IMessages } from 'types'
|
|
3
|
-
import IncomingMessage from '../IncomingMessage/IncomingMessage'
|
|
4
|
-
import SenderMessages from '../SenderMessages/SenderMessages'
|
|
5
|
-
import SystemMessage from '../SystemMessage/SystemMessage'
|
|
6
|
-
|
|
7
|
-
function MessageBalloon ({
|
|
8
|
-
item,
|
|
9
|
-
creatorId,
|
|
10
|
-
formatDate,
|
|
11
|
-
id,
|
|
12
|
-
}: {
|
|
13
|
-
item: IMessages
|
|
14
|
-
creatorId?: string
|
|
15
|
-
formatDate: (date: string | Date) => string | undefined
|
|
16
|
-
id: string
|
|
17
|
-
}) {
|
|
18
|
-
if (item.isSystemMessage) {
|
|
19
|
-
return (
|
|
20
|
-
<SystemMessage
|
|
21
|
-
formatDate={formatDate}
|
|
22
|
-
date={item.createdAt}
|
|
23
|
-
message={item.content}
|
|
24
|
-
id={item.senderId}
|
|
25
|
-
user={{ name: 'System' }}
|
|
26
|
-
/>
|
|
27
|
-
)
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
if (
|
|
31
|
-
item.sender.uniqueCode &&
|
|
32
|
-
!item.isSystemMessage &&
|
|
33
|
-
item.sender.uniqueCode === creatorId
|
|
34
|
-
) {
|
|
35
|
-
return (
|
|
36
|
-
<>
|
|
37
|
-
<SenderMessages
|
|
38
|
-
id={id}
|
|
39
|
-
formatDate={formatDate}
|
|
40
|
-
message={item.content}
|
|
41
|
-
date={item.createdAt}
|
|
42
|
-
read={item.everybodyHasRead}
|
|
43
|
-
hasFile={item.hasFile}
|
|
44
|
-
file={item.file}
|
|
45
|
-
/>
|
|
46
|
-
|
|
47
|
-
{item.images &&
|
|
48
|
-
item.images.map((image: Iimages, index: number) => (
|
|
49
|
-
<SenderMessages
|
|
50
|
-
key={image.key}
|
|
51
|
-
id={`${id}image-${index}`}
|
|
52
|
-
formatDate={formatDate}
|
|
53
|
-
date={item.createdAt}
|
|
54
|
-
file={image}
|
|
55
|
-
message=''
|
|
56
|
-
hasFile={true}
|
|
57
|
-
read={item.everybodyHasRead}
|
|
58
|
-
/>
|
|
59
|
-
))}
|
|
60
|
-
</>
|
|
61
|
-
)
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
return (
|
|
65
|
-
<>
|
|
66
|
-
<IncomingMessage
|
|
67
|
-
id={id}
|
|
68
|
-
formatDate={formatDate}
|
|
69
|
-
date={item.createdAt}
|
|
70
|
-
message={item.content}
|
|
71
|
-
hasFile={item.hasFile}
|
|
72
|
-
isSystemMessage={item.isSystemMessage}
|
|
73
|
-
file={item.file}
|
|
74
|
-
user={{
|
|
75
|
-
avatar: item.sender?.image,
|
|
76
|
-
name: item.sender.username,
|
|
77
|
-
}}
|
|
78
|
-
/>
|
|
79
|
-
|
|
80
|
-
{item.images &&
|
|
81
|
-
item.images.map((image: Iimages, index: number) => (
|
|
82
|
-
<IncomingMessage
|
|
83
|
-
key={image.key}
|
|
84
|
-
id={`${id}image-${index}`}
|
|
85
|
-
formatDate={formatDate}
|
|
86
|
-
date={item.createdAt}
|
|
87
|
-
file={image}
|
|
88
|
-
message=''
|
|
89
|
-
hasFile={true}
|
|
90
|
-
user={{
|
|
91
|
-
avatar: item.sender?.image,
|
|
92
|
-
name: item.sender.username,
|
|
93
|
-
}}
|
|
94
|
-
/>
|
|
95
|
-
))}
|
|
96
|
-
</>
|
|
97
|
-
)
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
export default MessageBalloon
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import useTheme from '../../hooks/useThemes'
|
|
2
|
-
import React from 'react'
|
|
3
|
-
import { useTranslation } from 'react-i18next'
|
|
4
|
-
import { IMesssengerAvatar } from 'types'
|
|
5
|
-
|
|
6
|
-
function MessengerAvatar ({
|
|
7
|
-
image,
|
|
8
|
-
children,
|
|
9
|
-
className = '',
|
|
10
|
-
}: IMesssengerAvatar) {
|
|
11
|
-
const { t } = useTranslation('messengerList')
|
|
12
|
-
const { theme } = useTheme()
|
|
13
|
-
return (
|
|
14
|
-
<figure
|
|
15
|
-
className={`${className} messenger__aside-list-item--avatar`}
|
|
16
|
-
style={{
|
|
17
|
-
background: theme.messengerIncomerColor,
|
|
18
|
-
}}
|
|
19
|
-
>
|
|
20
|
-
{image ? (
|
|
21
|
-
<img loading='lazy' alt={t('messengerAvatar.alt')} src={image} />
|
|
22
|
-
) : (
|
|
23
|
-
children
|
|
24
|
-
)}
|
|
25
|
-
</figure>
|
|
26
|
-
)
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export default MessengerAvatar
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import React, { createContext, ReactNode } from 'react'
|
|
2
|
-
|
|
3
|
-
const defaultThemeVariables = {
|
|
4
|
-
asideBg: '#eee',
|
|
5
|
-
asideFontColor: 'var(--secondary-color)',
|
|
6
|
-
messengerMessagesBg: '#eeeeee',
|
|
7
|
-
headerAndSenderBg: '#232831',
|
|
8
|
-
buttonPrimary: '#25D366',
|
|
9
|
-
buttonPrimaryText: '#707070',
|
|
10
|
-
buttonsDisabled: '#94989D',
|
|
11
|
-
uploadFileIconColor: '#8696a0',
|
|
12
|
-
messengerNotSelectedBg: '#DDDDDD',
|
|
13
|
-
newChatFormBg: '',
|
|
14
|
-
newChatFormRadius: '0 20px 20px 0',
|
|
15
|
-
newChatFormTexts: '#000',
|
|
16
|
-
newChatFormDeleteFileButton: '#DD4E4E',
|
|
17
|
-
disclaimerPrimaryColor: '#4791FF',
|
|
18
|
-
disclaimerSecondaryColor: '#4791FF',
|
|
19
|
-
disclaimerTextColor: '#000',
|
|
20
|
-
messengerSenderColor: '#00A73E',
|
|
21
|
-
messengerIncomerColor: '#707070',
|
|
22
|
-
messengerSystemColor: '#2A313A',
|
|
23
|
-
borderColor: '#AAAAAA',
|
|
24
|
-
inputBg: 'var(--secondary-color)',
|
|
25
|
-
chatInputBorder: '',
|
|
26
|
-
listItemHover: '',
|
|
27
|
-
active: '',
|
|
28
|
-
activeTabBorter: '#25D366',
|
|
29
|
-
emptyMessagesFontColor: '#000',
|
|
30
|
-
documentMessagesTextColor: '#fff',
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
type ThemeVariables = typeof defaultThemeVariables
|
|
34
|
-
|
|
35
|
-
type ThemeContextContent = {
|
|
36
|
-
theme: Partial<ThemeVariables>
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export const MessageThemeContext = createContext<ThemeContextContent>(
|
|
40
|
-
{} as unknown as ThemeContextContent
|
|
41
|
-
)
|
|
42
|
-
|
|
43
|
-
type Props = {
|
|
44
|
-
children: ReactNode
|
|
45
|
-
theme?: Partial<ThemeVariables>
|
|
46
|
-
}
|
|
47
|
-
const MessageThemeWrapper = ({
|
|
48
|
-
children,
|
|
49
|
-
theme = defaultThemeVariables,
|
|
50
|
-
}: Props) => {
|
|
51
|
-
const config = {
|
|
52
|
-
theme,
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
return (
|
|
56
|
-
<MessageThemeContext.Provider value={config}>
|
|
57
|
-
{children}
|
|
58
|
-
</MessageThemeContext.Provider>
|
|
59
|
-
)
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
export default MessageThemeWrapper
|