isometrik-chat 0.1.0
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/README.md +74 -0
- package/babel.config.js +6 -0
- package/dist/index.js +684 -0
- package/package.json +59 -0
- package/public/Logo-192x192.png +0 -0
- package/public/Logo-512x512.png +0 -0
- package/public/favicon.ico +0 -0
- package/public/fonts/BenjaminVictoria.ttf +0 -0
- package/public/icons/arrow_logo.svg +9 -0
- package/public/icons/assets/ic_placeholder_banner.svg +1 -0
- package/public/icons/attach-file.svg +9 -0
- package/public/icons/audio_pause.svg +1 -0
- package/public/icons/audio_play.svg +6 -0
- package/public/icons/back.svg +3 -0
- package/public/icons/bell.svg +1 -0
- package/public/icons/block.svg +1 -0
- package/public/icons/bottom-arrow.svg +1 -0
- package/public/icons/camera-switch.svg +12 -0
- package/public/icons/camera.svg +4 -0
- package/public/icons/cancel.svg +1 -0
- package/public/icons/chat empty placeholder.svg +58 -0
- package/public/icons/chat_audio_pause.png +0 -0
- package/public/icons/chat_audio_play.png +0 -0
- package/public/icons/close.svg +5 -0
- package/public/icons/crossCarousel.svg +3 -0
- package/public/icons/delete.svg +3 -0
- package/public/icons/disappear.svg +24 -0
- package/public/icons/document.png +0 -0
- package/public/icons/document.svg +1 -0
- package/public/icons/downloadCarousel.svg +6 -0
- package/public/icons/edit-pencil.svg +6 -0
- package/public/icons/emoji.svg +8 -0
- package/public/icons/emojiCarousel.svg +3 -0
- package/public/icons/filter.svg +1 -0
- package/public/icons/forwardCarousel.svg +3 -0
- package/public/icons/gallery.svg +1 -0
- package/public/icons/goToMessageCarousel.svg +3 -0
- package/public/icons/ic_uil_arrow-left.svg +1 -0
- package/public/icons/ic_uil_eye-slash.svg +1 -0
- package/public/icons/ic_uil_eye.svg +1 -0
- package/public/icons/leftArrowCarousel.svg +6 -0
- package/public/icons/light-mode.svg +14 -0
- package/public/icons/lock.svg +1 -0
- package/public/icons/login_background.png +0 -0
- package/public/icons/menu .svg +5 -0
- package/public/icons/menuCarousel.svg +5 -0
- package/public/icons/message.svg +3 -0
- package/public/icons/placeholder.svg +958 -0
- package/public/icons/poll.svg +1 -0
- package/public/icons/retake.png +0 -0
- package/public/icons/right-arrow.svg +3 -0
- package/public/icons/right.svg +3 -0
- package/public/icons/round-star.svg +1 -0
- package/public/icons/search.svg +3 -0
- package/public/icons/send.svg +10 -0
- package/public/icons/starCarousel.svg +3 -0
- package/public/icons/status.svg +1 -0
- package/public/icons/sticker.svg +1 -0
- package/public/icons/thumb-down.svg +1 -0
- package/public/icons/user.svg +1 -0
- package/public/icons/users.svg +1 -0
- package/public/icons/voice.png +0 -0
- package/public/index.html +38 -0
- package/public/logo192.png +0 -0
- package/public/logo512.png +0 -0
- package/public/manifest.json +25 -0
- package/public/offline.html +12 -0
- package/public/robots.txt +3 -0
- package/public/service-worker.js +81 -0
- package/src/App.js +15 -0
- package/src/App.test.js +8 -0
- package/src/Authpage.js +16 -0
- package/src/ChatContext.js +172 -0
- package/src/Data/index.js +110 -0
- package/src/assets/icons.js +49 -0
- package/src/assets/images/WhatsApp.html +258 -0
- package/src/assets/images/WhatsApp_files/301446776_522918349234681_1974693392291574064_n.jpg +0 -0
- package/src/assets/images/WhatsApp_files/app-bf223f825866ee433b07.css +242 -0
- package/src/assets/images/WhatsApp_files/app.77ee8aa7a4c593101105.js +77 -0
- package/src/assets/images/WhatsApp_files/lazy_loaded_high_priority_components.85a06e74a0a4ade1640b.css +16 -0
- package/src/assets/images/WhatsApp_files/lazy_loaded_low_priority_components.8621270bc215a9298a97.css +47 -0
- package/src/assets/images/WhatsApp_files/libsignal-protocol-ee5b8ba.min.js +21 -0
- package/src/assets/images/WhatsApp_files/main.48b845d68e066fb27a75.css +161 -0
- package/src/assets/images/WhatsApp_files/runtime.e6018f3c1e255e8f4dc7.js +2 -0
- package/src/assets/images/WhatsApp_files/stylex-d50abd61e6cf7eab2afd855adccf14e5.css +2841 -0
- package/src/assets/images/WhatsApp_files/vendor1_app.58a51d93a250f83ab555.js +79 -0
- package/src/assets/images/bg.jpeg +0 -0
- package/src/assets/images/drkbg.jpg +0 -0
- package/src/assets/images/notFound.jpeg +0 -0
- package/src/assets/images/watsapp.jpg +0 -0
- package/src/assets/images/watsappbg.png +0 -0
- package/src/assets/images/wb.jpg +0 -0
- package/src/assets/images/whatsapp.jpeg +0 -0
- package/src/components/ChatBox/AudioBubble.js +162 -0
- package/src/components/ChatBox/ChatBubble.js +232 -0
- package/src/components/ChatBox/DocumentBubble.js +87 -0
- package/src/components/ChatBox/MessagesBox.js +533 -0
- package/src/components/CustomModal.js +60 -0
- package/src/components/Icon.js +10 -0
- package/src/components/ImageComponent.js +24 -0
- package/src/components/MediaDocs.js +155 -0
- package/src/components/MediaDocumentContainer.js +55 -0
- package/src/components/MessageInfoDropdown.js +124 -0
- package/src/components/Modal/AllowMicPermissionModal.js +63 -0
- package/src/components/Modal/BlockUnblockChatModal.js +78 -0
- package/src/components/Modal/CameraPermissionBlockedModal.js +61 -0
- package/src/components/Modal/CameraPermissionRequestModal.js +60 -0
- package/src/components/Modal/ClearChatModal.js +78 -0
- package/src/components/Modal/DeleteChatModal.js +79 -0
- package/src/components/Modal/MicPermissionDisableModal.js +63 -0
- package/src/components/Modal/Modal.js +103 -0
- package/src/components/Modal/ModalDialog.js +103 -0
- package/src/components/Modal/ProfilePictureUploadPreview.js +160 -0
- package/src/components/OutsideAlerter/OutsideAlerter.js +38 -0
- package/src/components/ProfilePicture/ProfilePicture.js +127 -0
- package/src/components/Registration/Login.js +265 -0
- package/src/components/Registration/SignUp.js +322 -0
- package/src/components/SnackBar.js +42 -0
- package/src/components/common/Modal/useDetectOutsideClick.js +23 -0
- package/src/components/common/styled/PageWrapper.js +25 -0
- package/src/components/formcontrol/CustomButton.js +38 -0
- package/src/components/formcontrol/InputText.js +60 -0
- package/src/global-styles.js +42 -0
- package/src/hooks/useDeviceType.js +28 -0
- package/src/hooks/useThrottle.js +29 -0
- package/src/index.css +225 -0
- package/src/index.js +23 -0
- package/src/lib/constant.js +21 -0
- package/src/lib/functionality.js +13 -0
- package/src/lib/helpers.js +320 -0
- package/src/lib/mockData/index.js +76 -0
- package/src/lib/session/index.js +31 -0
- package/src/lib/validation.js +4 -0
- package/src/logo.svg +1 -0
- package/src/pages/WhatsappMainBox/index.js +574 -0
- package/src/reportWebVitals.js +13 -0
- package/src/services/deliveryStatus.js +27 -0
- package/src/setupTests.js +5 -0
- package/src/utils/chatSdk.js +14 -0
- package/src/utils/global.js +57 -0
- package/src/utils/media.js +79 -0
- package/src/view/component/BlockedContactSlide.js +134 -0
- package/src/view/component/Carousle/UpperMenuBar.js +106 -0
- package/src/view/component/Carousle/index.js +204 -0
- package/src/view/component/Chatbox.js/AudioRecorder.js +311 -0
- package/src/view/component/Chatbox.js/ChatBubbleReply.js +27 -0
- package/src/view/component/Chatbox.js/TakePhoto.js +363 -0
- package/src/view/component/Chatbox.js/index.js +856 -0
- package/src/view/component/Chatbox.js/styles.css +231 -0
- package/src/view/component/Contact/index.js +56 -0
- package/src/view/component/Contact/styles.css +208 -0
- package/src/view/component/ContactInfo/index.js +543 -0
- package/src/view/component/ContactInfo/styles.css +289 -0
- package/src/view/component/Context/index.js +3 -0
- package/src/view/component/DialogBox.js +15 -0
- package/src/view/component/ImageCropper/ImageCropper.js +128 -0
- package/src/view/component/Loader/Loader.js +52 -0
- package/src/view/component/Loader/UserPagingLoader.js +62 -0
- package/src/view/component/MainChatBox/index.js +819 -0
- package/src/view/component/MainChatBox/styles.css +124 -0
- package/src/view/component/Menu/index.js +261 -0
- package/src/view/component/Menu/styles.css +68 -0
- package/src/view/component/Profile/ProfileInfoContainer.js +112 -0
- package/src/view/component/Profile/ProfileUpdate.js +178 -0
- package/src/view/component/Profile/TakeProfilePhoto.js +391 -0
- package/src/view/component/Profile/index.js +550 -0
- package/src/view/component/Profile/styles.css +370 -0
- package/src/view/component/ReplyChatMessage/ReplyChatMessage.js +48 -0
- package/src/view/component/SeachBar/index.js +106 -0
- package/src/view/component/SeachBar/styles.css +53 -0
- package/src/view/component/Siderbar/index.js +512 -0
- package/src/view/component/Siderbar/styles.css +138 -0
- package/src/view/component/Toaster/Toaster.js +117 -0
- package/src/view/component/UserDetailsCard/UserDetailCard.js +337 -0
- package/src/view/component/deleteMessageMoal.js +80 -0
- package/src/view/component/emoji/index.js +22 -0
- package/src/view/component/emoji/sstyles.css +0 -0
- package/src/view/component/forwardData/index.js +327 -0
- package/src/view/component/forwardData/styles.css +112 -0
- package/src/view/component/forwardPopup/index.js +55 -0
- package/src/view/component/forwardPopup/styles.css +144 -0
- package/src/view/component/mediaList/index.js +92 -0
- package/src/view/component/menuDialog/index.js +71 -0
- package/src/view/component/menuDialog/styles.css +24 -0
- package/src/view/component/pagination/pagination.js +52 -0
- package/src/view/component/pagination/paginationForMsg.js +43 -0
- package/src/view/component/sidebarChat/index.js +321 -0
- package/src/view/component/sidebarChat/styles.css +109 -0
|
@@ -0,0 +1,856 @@
|
|
|
1
|
+
import React, { useEffect, useRef, useState } from "react";
|
|
2
|
+
import "./styles.css";
|
|
3
|
+
import watsappbg from "../../../assets/images/watsappbg.png";
|
|
4
|
+
import darkbg from "../../../assets/images/drkbg.jpg";
|
|
5
|
+
import MessagesBox from "../../../components/ChatBox/MessagesBox";
|
|
6
|
+
import client from "../../../utils/chatSdk";
|
|
7
|
+
import { chatAttachmentOptions, deletemesageForSelf, getDeviceId, getMediaUrl, mediaUploadValidator, deleteMessageforEveryOne, generatedMessagePresignedUrls, documentUploadValidator, validDocumentType, encodeChatBody } from "../../../lib/helpers";
|
|
8
|
+
import PaginationForMsg from "../pagination/paginationForMsg";
|
|
9
|
+
import styled, { css } from "styled-components";
|
|
10
|
+
import { mobile } from "../../../utils/media";
|
|
11
|
+
import Picker, { Theme } from 'emoji-picker-react';
|
|
12
|
+
import {
|
|
13
|
+
ATTACH_FILE,
|
|
14
|
+
CAMERA,
|
|
15
|
+
DOCUMENT,
|
|
16
|
+
EMOJI_ICON,
|
|
17
|
+
GALLERY,
|
|
18
|
+
POll,
|
|
19
|
+
SENDICON,
|
|
20
|
+
STICKER,
|
|
21
|
+
USER,
|
|
22
|
+
VOICE,
|
|
23
|
+
CLOSE_ICON,
|
|
24
|
+
} from "../../../utils/global";
|
|
25
|
+
import ImageComponent from "../../../components/ImageComponent";
|
|
26
|
+
import OutsideAlerter from "../../../components/OutsideAlerter/OutsideAlerter";
|
|
27
|
+
// import ReplyChatMessage from "../ReplyChatMessage/ReplyChatMessage";
|
|
28
|
+
import CustomModal from "../../../components/CustomModal";
|
|
29
|
+
import ModalDialog from "../../../components/Modal/ModalDialog";
|
|
30
|
+
import AudioRecorder from "./AudioRecorder";
|
|
31
|
+
import TakePhoto from "./TakePhoto";
|
|
32
|
+
import { getCookie } from "../../../lib/session";
|
|
33
|
+
import { MESSAGE_DELETE_FOR_ALL, MESSAGE_DELETE_LOCAL } from "../../../lib/constant";
|
|
34
|
+
|
|
35
|
+
const ChatMessages = styled.div`
|
|
36
|
+
overflow-y: auto;
|
|
37
|
+
height: calc(100vh - 145px);
|
|
38
|
+
|
|
39
|
+
--overflow-style: none;
|
|
40
|
+
scrollbar-width: none;
|
|
41
|
+
|
|
42
|
+
::-webkit-scrollbar {
|
|
43
|
+
display: none;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
${mobile(css`
|
|
47
|
+
height: calc(100vh - 200px);
|
|
48
|
+
`)}
|
|
49
|
+
`;
|
|
50
|
+
|
|
51
|
+
const FormContainer = styled.form`
|
|
52
|
+
.custom_mic_icon{
|
|
53
|
+
margin-right: 1rem;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
${mobile(css`
|
|
57
|
+
position: fixed;
|
|
58
|
+
bottom: 0;
|
|
59
|
+
width: 100%;
|
|
60
|
+
`)}
|
|
61
|
+
`;
|
|
62
|
+
|
|
63
|
+
const PollImage = styled.p`
|
|
64
|
+
background: linear-gradient(to top, #039889 50%, #00ae9b 50%);
|
|
65
|
+
height: 50px;
|
|
66
|
+
width: 50px;
|
|
67
|
+
border-radius: 30px;
|
|
68
|
+
display: flex;
|
|
69
|
+
justify-content: center;
|
|
70
|
+
align-items: center;
|
|
71
|
+
`;
|
|
72
|
+
|
|
73
|
+
const GalleryImage = styled.p`
|
|
74
|
+
background: linear-gradient(to top, #d120bf 50%, #b553dd 50%);
|
|
75
|
+
height: 50px;
|
|
76
|
+
width: 50px;
|
|
77
|
+
border-radius: 30px;
|
|
78
|
+
display: flex;
|
|
79
|
+
justify-content: center;
|
|
80
|
+
align-items: center;
|
|
81
|
+
position: relative;
|
|
82
|
+
`;
|
|
83
|
+
const DocumentImage = styled.p`
|
|
84
|
+
background: linear-gradient(to top, #208ad1 50%, #5353dd 50%);
|
|
85
|
+
height: 50px;
|
|
86
|
+
width: 50px;
|
|
87
|
+
border-radius: 30px;
|
|
88
|
+
display: flex;
|
|
89
|
+
justify-content: center;
|
|
90
|
+
align-items: center;
|
|
91
|
+
`;
|
|
92
|
+
|
|
93
|
+
const CameraImage = styled.p`
|
|
94
|
+
background: linear-gradient(to top, #eb138f 50%, #f40073 50%);
|
|
95
|
+
height: 50px;
|
|
96
|
+
width: 50px;
|
|
97
|
+
border-radius: 30px;
|
|
98
|
+
display: flex;
|
|
99
|
+
justify-content: center;
|
|
100
|
+
align-items: center;
|
|
101
|
+
position: relative;
|
|
102
|
+
`;
|
|
103
|
+
|
|
104
|
+
const UserImage = styled.p`
|
|
105
|
+
background: linear-gradient(to top, #00aaff 50%, #0000ff 50%);
|
|
106
|
+
height: 50px;
|
|
107
|
+
width: 50px;
|
|
108
|
+
border-radius: 30px;
|
|
109
|
+
display: flex;
|
|
110
|
+
justify-content: center;
|
|
111
|
+
align-items: center;
|
|
112
|
+
`;
|
|
113
|
+
|
|
114
|
+
const StickerImage = styled.p`
|
|
115
|
+
background: linear-gradient(to top, #1395eb 50%, #0000ff 50%);
|
|
116
|
+
height: 50px;
|
|
117
|
+
width: 50px;
|
|
118
|
+
border-radius: 30px;
|
|
119
|
+
display: flex;
|
|
120
|
+
justify-content: center;
|
|
121
|
+
align-items: center;
|
|
122
|
+
position: relative;
|
|
123
|
+
`;
|
|
124
|
+
|
|
125
|
+
const AttachFile = styled.div`
|
|
126
|
+
position: absolute;
|
|
127
|
+
bottom: 60px;
|
|
128
|
+
left: 50px;
|
|
129
|
+
cursor: pointer;
|
|
130
|
+
visibility: hidden;
|
|
131
|
+
transform: translateY(50px);
|
|
132
|
+
transition: opacity 331ms cubic-bezier(0.4, 0, 0.2, 1) 0ms,
|
|
133
|
+
transform 220ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;
|
|
134
|
+
transform-origin: left top;
|
|
135
|
+
z-index: 999;
|
|
136
|
+
${(props) =>
|
|
137
|
+
props.uploadFiles &&
|
|
138
|
+
css`
|
|
139
|
+
opacity: 1;
|
|
140
|
+
visibility: visible;
|
|
141
|
+
transform: translateY(0);
|
|
142
|
+
`}
|
|
143
|
+
`;
|
|
144
|
+
|
|
145
|
+
const AttachFileContainer = styled.div`
|
|
146
|
+
position: relative;
|
|
147
|
+
`;
|
|
148
|
+
|
|
149
|
+
const ChatBoxBodyContainer = styled.div`
|
|
150
|
+
${mobile(css`
|
|
151
|
+
height: calc(100vh - 132px);
|
|
152
|
+
`)}
|
|
153
|
+
`;
|
|
154
|
+
const BlockUserFooter = styled.div`
|
|
155
|
+
background-color: var(--modal_color);
|
|
156
|
+
padding: 14px 19px;
|
|
157
|
+
width: 100%;
|
|
158
|
+
`;
|
|
159
|
+
|
|
160
|
+
const BlockUserFooterText = styled.p`
|
|
161
|
+
color: var(--black);
|
|
162
|
+
text-align: center;
|
|
163
|
+
margin: 10px 0;
|
|
164
|
+
`;
|
|
165
|
+
|
|
166
|
+
const EmojiPicker = styled.div`
|
|
167
|
+
position:absolute;
|
|
168
|
+
left:0px;
|
|
169
|
+
bottom:68px;
|
|
170
|
+
width:100%;
|
|
171
|
+
z-index: 999;
|
|
172
|
+
visibility:hidden;
|
|
173
|
+
transform: translateY(70px);
|
|
174
|
+
transition: opacity 331ms cubic-bezier(0.4, 0, 0.2, 1) 0ms,
|
|
175
|
+
transform 220ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;
|
|
176
|
+
transform-origin: left top;
|
|
177
|
+
${(props) =>
|
|
178
|
+
props.isShowEmojiPicker &&
|
|
179
|
+
css`
|
|
180
|
+
opacity: 1;
|
|
181
|
+
visibility: visible;
|
|
182
|
+
transform: translateY(0);
|
|
183
|
+
`}
|
|
184
|
+
`;
|
|
185
|
+
|
|
186
|
+
const ChatMessageWrapper = styled.div`
|
|
187
|
+
display: flex;
|
|
188
|
+
align-items: center;
|
|
189
|
+
width: 100%;
|
|
190
|
+
`;
|
|
191
|
+
|
|
192
|
+
const ReplyMessage = styled.div`
|
|
193
|
+
position:absolute;
|
|
194
|
+
left:0px;
|
|
195
|
+
bottom:0px;
|
|
196
|
+
width:100%;
|
|
197
|
+
z-index: 999;
|
|
198
|
+
visibility:hidden;
|
|
199
|
+
transform: translateY(30px);
|
|
200
|
+
transition: opacity 331ms cubic-bezier(0.4, 0, 0.2, 1) 0ms,
|
|
201
|
+
transform 220ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;
|
|
202
|
+
transform-origin: left top;
|
|
203
|
+
${(props) =>
|
|
204
|
+
props?.reply &&
|
|
205
|
+
css`
|
|
206
|
+
opacity: 1;
|
|
207
|
+
visibility: visible;
|
|
208
|
+
transform: translateY(0);
|
|
209
|
+
`}
|
|
210
|
+
|
|
211
|
+
`;
|
|
212
|
+
|
|
213
|
+
const ShowHoverItem = styled.div`
|
|
214
|
+
display: flex;
|
|
215
|
+
justify-content: center;
|
|
216
|
+
align-items: center;
|
|
217
|
+
padding: 0.5rem 1rem;
|
|
218
|
+
background: var(--bg-white);
|
|
219
|
+
position: absolute;
|
|
220
|
+
left: 60px;
|
|
221
|
+
top: 0;
|
|
222
|
+
color: var( --black);
|
|
223
|
+
white-space: nowrap;
|
|
224
|
+
border-radius: 20px;
|
|
225
|
+
`;
|
|
226
|
+
|
|
227
|
+
function Chatbox(props) {
|
|
228
|
+
const {
|
|
229
|
+
sidebarChatItem,
|
|
230
|
+
messages,
|
|
231
|
+
getPaginationMessagesData,
|
|
232
|
+
findUserId,
|
|
233
|
+
state,
|
|
234
|
+
setState,
|
|
235
|
+
setGetMessageTextLength,
|
|
236
|
+
userConversationDetail,
|
|
237
|
+
setslideShow,
|
|
238
|
+
setMessageInfo,
|
|
239
|
+
messageInfo,
|
|
240
|
+
MessageInfoHandler,
|
|
241
|
+
setMessageChat,
|
|
242
|
+
setSearchShow,
|
|
243
|
+
setToastStatus,
|
|
244
|
+
setMediaDocs,
|
|
245
|
+
userDetails,
|
|
246
|
+
handleImgVidClick,
|
|
247
|
+
setIsOpen,
|
|
248
|
+
isOpen,
|
|
249
|
+
getMediaDocs,
|
|
250
|
+
theme,
|
|
251
|
+
} = props;
|
|
252
|
+
const [messageText, setMessageText] = useState("");
|
|
253
|
+
const [uploadFiles, setUploadFiles] = useState(false);
|
|
254
|
+
const [isShowEmojiPicker, setIsShowEmojiPicker] = useState(false);
|
|
255
|
+
const [isReply, setIsReply] = useState(false);
|
|
256
|
+
const [reply, setReply] = useState({ isreply: false, Data: {}, showReplyMessage: false });
|
|
257
|
+
const [deleteMessage, setDeleteMessage] = useState({ delete: false, data: {} })
|
|
258
|
+
const [isDelete, setIsDelete] = useState(false)
|
|
259
|
+
const [audioRecorderStatus, setAudioRecorderStatus] = useState(false);
|
|
260
|
+
const [recordedStream, setRecordedStream] = useState('');
|
|
261
|
+
const [takeCameraPhoto, setTakeCameraPhoto] = useState(false);
|
|
262
|
+
const [convertClickedImageToFileType, setConvertClickedImageToFileType] = useState('');
|
|
263
|
+
const [hoveredItem, setHoveredItem] = useState(null);
|
|
264
|
+
const [showAudioRecordButton, setShowAudioRecordButton] = useState(true);
|
|
265
|
+
const submitAudioRecordingRef = useRef();
|
|
266
|
+
const chatScrollMessageRef = useRef(null);
|
|
267
|
+
const selectImageUploadRef = useRef(null);
|
|
268
|
+
const documentUploadRef = useRef(null);
|
|
269
|
+
const userId = getCookie("userId");
|
|
270
|
+
const isSelfMessage = (userId === deleteMessage?.data?.chat?.senderInfo?.userId || userId === deleteMessage?.data?.chat?.senderId);
|
|
271
|
+
|
|
272
|
+
useEffect(() => {
|
|
273
|
+
setGetMessageTextLength(messageText);
|
|
274
|
+
}, [messageText]);
|
|
275
|
+
|
|
276
|
+
useEffect(() => {
|
|
277
|
+
setMessageText('');
|
|
278
|
+
}, [findUserId?.conversationId])
|
|
279
|
+
|
|
280
|
+
const sendRecordedAudioServer = async () => {
|
|
281
|
+
const recordedStreamAttachment = {};
|
|
282
|
+
const currentTimestamp = new Date().getTime();
|
|
283
|
+
const file = new File([recordedStream], "recording.mp3", {
|
|
284
|
+
type: "audio/mp3",
|
|
285
|
+
});
|
|
286
|
+
recordedStreamAttachment.name = file?.name;
|
|
287
|
+
recordedStreamAttachment.size = file?.size;
|
|
288
|
+
recordedStreamAttachment.extension = 'mp3';
|
|
289
|
+
recordedStreamAttachment.attachmentType = 2;
|
|
290
|
+
recordedStreamAttachment.mimeType = 'mp3';
|
|
291
|
+
const payload = {
|
|
292
|
+
conversationId: sidebarChatItem?.conversationId,
|
|
293
|
+
attachments: [
|
|
294
|
+
{
|
|
295
|
+
nameWithExtension: "unnamed.mp3",
|
|
296
|
+
mediaType: 2,
|
|
297
|
+
mediaId: `${currentTimestamp}`,
|
|
298
|
+
}
|
|
299
|
+
]
|
|
300
|
+
}
|
|
301
|
+
try {
|
|
302
|
+
const res = await generatedMessagePresignedUrls(payload);
|
|
303
|
+
recordedStreamAttachment.thumbnailUrl = res?.presignedUrls?.[0].thumbnailUrl;
|
|
304
|
+
recordedStreamAttachment.mediaUrl = res?.presignedUrls?.[0].mediaUrl;
|
|
305
|
+
recordedStreamAttachment.mediaId = res?.presignedUrls?.[0].mediaId;
|
|
306
|
+
if (res) {
|
|
307
|
+
const uploadAudio = await getMediaUrl(res?.presignedUrls[0].mediaPresignedUrl, file, 'mp3');
|
|
308
|
+
}
|
|
309
|
+
return recordedStreamAttachment;
|
|
310
|
+
} catch (error) {
|
|
311
|
+
console.error('error', error);
|
|
312
|
+
setToastStatus({ open: true, variant: 'error', message: error?.msg || error?.message || '' })
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
const handleChatMessages = async (e) => {
|
|
317
|
+
e.preventDefault();
|
|
318
|
+
setMessageText("");
|
|
319
|
+
// replyMessageCloseHandler();
|
|
320
|
+
const messagePayload = await getChatMessagePayload();
|
|
321
|
+
try {
|
|
322
|
+
const res = await client?.message?.postMessages(messagePayload);
|
|
323
|
+
console.log(res, 'res');
|
|
324
|
+
} catch (error) {
|
|
325
|
+
console.log("err", error);
|
|
326
|
+
}
|
|
327
|
+
};
|
|
328
|
+
|
|
329
|
+
const getChatMessagePayload = async (e) => {
|
|
330
|
+
const deviceId = await getDeviceId();
|
|
331
|
+
// e.preventDefault();
|
|
332
|
+
// setMessageText("");
|
|
333
|
+
const payload = {
|
|
334
|
+
showInConversation: true,
|
|
335
|
+
metaData: {
|
|
336
|
+
secretMessage: true,
|
|
337
|
+
},
|
|
338
|
+
messageType: 0,
|
|
339
|
+
events: {
|
|
340
|
+
updateUnreadCount: true,
|
|
341
|
+
sendPushNotification: true,
|
|
342
|
+
},
|
|
343
|
+
encrypted: true,
|
|
344
|
+
deviceId: deviceId.substring(0, 100),
|
|
345
|
+
customType: "NormalMessage",
|
|
346
|
+
conversationId: sidebarChatItem?.conversationId,
|
|
347
|
+
conversationType: sidebarChatItem?.conversationType,
|
|
348
|
+
isGroup: sidebarChatItem?.isGroup,
|
|
349
|
+
body: encodeChatBody(messageText),
|
|
350
|
+
searchableTags: [encodeChatBody(messageText)],
|
|
351
|
+
};
|
|
352
|
+
if (reply?.isreply === true) {
|
|
353
|
+
payload.customType = 'Reply';
|
|
354
|
+
payload.messageType = 2;
|
|
355
|
+
payload.parentMessageId = reply?.data?.chat?.messageId;
|
|
356
|
+
return payload;
|
|
357
|
+
} else if (audioRecorderStatus) {
|
|
358
|
+
const attachments = await sendRecordedAudioServer();
|
|
359
|
+
payload.attachments = [attachments];
|
|
360
|
+
payload.customType = 'audio';
|
|
361
|
+
payload.body = btoa('Voice message');
|
|
362
|
+
payload.searchableTags = [btoa('Voice message')]
|
|
363
|
+
payload.notificationBody = 'Sent you an Audio';
|
|
364
|
+
payload.notificationTitle = sidebarChatItem?.senderName;
|
|
365
|
+
return payload;
|
|
366
|
+
} else {
|
|
367
|
+
return payload;
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
const handleKeyDown = (event) => {
|
|
372
|
+
if (event.key === "Enter") {
|
|
373
|
+
handleSubmit(event);
|
|
374
|
+
}
|
|
375
|
+
};
|
|
376
|
+
|
|
377
|
+
const handleSubmit = (event) => {
|
|
378
|
+
event.preventDefault();
|
|
379
|
+
submitAudioRecordingRef?.current?.handleDeleteButtonClick();
|
|
380
|
+
setAudioRecorderStatus(false);
|
|
381
|
+
handleChatMessages(event);
|
|
382
|
+
setIsShowEmojiPicker(false);
|
|
383
|
+
setReply({ ...reply, isreply: false, showReplyMessage: true });
|
|
384
|
+
setShowAudioRecordButton(true);
|
|
385
|
+
};
|
|
386
|
+
|
|
387
|
+
const uploadImageToServer = async (file, documentType) => {
|
|
388
|
+
try {
|
|
389
|
+
let filesObj = {};
|
|
390
|
+
const mediaId = String(new Date().getTime() + Math.floor(Math.random() * 1000));
|
|
391
|
+
filesObj[mediaId] = {
|
|
392
|
+
nameWithExtension: file?.name,
|
|
393
|
+
mediaType: 0,
|
|
394
|
+
mediaId,
|
|
395
|
+
size: file?.size,
|
|
396
|
+
mimeType: file?.type,
|
|
397
|
+
file
|
|
398
|
+
}
|
|
399
|
+
const presignedUrlPayload = {
|
|
400
|
+
conversationId: sidebarChatItem?.conversationId,
|
|
401
|
+
attachments: Object.values(filesObj)
|
|
402
|
+
}
|
|
403
|
+
const response = await client?.message?.postMessagesPresignedurls(presignedUrlPayload);
|
|
404
|
+
const deviceId = await getDeviceId();
|
|
405
|
+
if (response?.presignedUrls) {
|
|
406
|
+
response?.presignedUrls.forEach(async (element) => {
|
|
407
|
+
const attachmentsForImg = [];
|
|
408
|
+
const fileExtensionType = filesObj[element?.mediaId].mimeType.split('/')[1];
|
|
409
|
+
attachmentsForImg.push({
|
|
410
|
+
thumbnailUrl: element?.thumbnailUrl,
|
|
411
|
+
mediaUrl: element?.mediaUrl,
|
|
412
|
+
mediaId: element?.mediaId,
|
|
413
|
+
size: filesObj[element?.mediaId].size,
|
|
414
|
+
mimeType: filesObj[element?.mediaId].mimeType,
|
|
415
|
+
name: filesObj[element?.mediaId].nameWithExtension,
|
|
416
|
+
extension: fileExtensionType,
|
|
417
|
+
attachmentType: 0
|
|
418
|
+
})
|
|
419
|
+
await getMediaUrl(element?.mediaPresignedUrl, filesObj[element.mediaId].file, filesObj[element.mediaId].file.type).then(async () => {
|
|
420
|
+
const messagePayload = {
|
|
421
|
+
showInConversation: true,
|
|
422
|
+
messageType: 0,
|
|
423
|
+
encrypted: true,
|
|
424
|
+
deviceId: deviceId,
|
|
425
|
+
conversationId: sidebarChatItem?.conversationId,
|
|
426
|
+
body: fileExtensionType === 'mp4' ? btoa('video') : documentType ? btoa('document') : btoa('image'),
|
|
427
|
+
parentMessageId: null,
|
|
428
|
+
metaData: null,
|
|
429
|
+
events: null,
|
|
430
|
+
attachments: attachmentsForImg,
|
|
431
|
+
notificationBody: `Sent you ${fileExtensionType === 'mp4' ? 'a video' :
|
|
432
|
+
documentType ? 'a document' : 'an image'} `,
|
|
433
|
+
notificationTitle: userDetails?.userName,
|
|
434
|
+
}
|
|
435
|
+
if (documentType) {
|
|
436
|
+
messagePayload.customType = 'document'
|
|
437
|
+
}
|
|
438
|
+
await client?.message?.postMessages(messagePayload);
|
|
439
|
+
}).catch((err) => {
|
|
440
|
+
console.log(err, 'err');
|
|
441
|
+
})
|
|
442
|
+
});
|
|
443
|
+
}
|
|
444
|
+
} catch (e) {
|
|
445
|
+
console.log("error from galleryClickHandler", e);
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
const galleryClickHandler = async (e) => {
|
|
450
|
+
try {
|
|
451
|
+
const file = e.target.files[0];
|
|
452
|
+
const { valid, error } = mediaUploadValidator(file);
|
|
453
|
+
if (!valid) {
|
|
454
|
+
setToastStatus({ open: true, message: 'File Size should be less than 50MB.', variant: 'error' })
|
|
455
|
+
return;
|
|
456
|
+
}
|
|
457
|
+
await uploadImageToServer(file);
|
|
458
|
+
} catch (error) {
|
|
459
|
+
console.error('error', error);
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
// const textarea = document.querySelector("textarea");
|
|
464
|
+
// textarea.addEventListener( e=>{
|
|
465
|
+
// textarea.style.height = "59px";
|
|
466
|
+
// let scHeight = e.target.scrollHeight;
|
|
467
|
+
// textarea.style.height = `${scHeight}px`;
|
|
468
|
+
// })
|
|
469
|
+
const audioHandler = () => {
|
|
470
|
+
setAudioRecorderStatus(true);
|
|
471
|
+
setShowAudioRecordButton(false);
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
const audioCloseHandler = () => {
|
|
475
|
+
setAudioRecorderStatus(false);
|
|
476
|
+
setShowAudioRecordButton(true);
|
|
477
|
+
setMessageText('');
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
const handleOnEmojiClick = (emojiObject) => {
|
|
481
|
+
setMessageText((prevInput) => prevInput + emojiObject.emoji);
|
|
482
|
+
};
|
|
483
|
+
|
|
484
|
+
|
|
485
|
+
const allMessagesArray = () => {
|
|
486
|
+
try {
|
|
487
|
+
let currIndex;
|
|
488
|
+
if (findUserId.action === MESSAGE_DELETE_FOR_ALL) {
|
|
489
|
+
currIndex = state?.messages[findUserId?.conversationId].findIndex(
|
|
490
|
+
(obj) =>
|
|
491
|
+
(obj.messageId === findUserId?.messageIds[0])
|
|
492
|
+
);
|
|
493
|
+
const removeMessageObj = state?.messages[findUserId?.conversationId].splice(currIndex, 1);
|
|
494
|
+
|
|
495
|
+
setState((prev) => {
|
|
496
|
+
return {
|
|
497
|
+
...prev,
|
|
498
|
+
messages: {
|
|
499
|
+
...prev.messages,
|
|
500
|
+
[sidebarChatItem?.conversationId]: [...state?.messages[findUserId?.conversationId]],
|
|
501
|
+
},
|
|
502
|
+
};
|
|
503
|
+
});
|
|
504
|
+
};
|
|
505
|
+
} catch (error) {
|
|
506
|
+
console.error('error', error);
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
const sortedMessageArraySelf = () => {
|
|
511
|
+
try {
|
|
512
|
+
let currIndex;
|
|
513
|
+
currIndex = state?.messages[findUserId?.conversationId].findIndex(
|
|
514
|
+
(obj) =>
|
|
515
|
+
(obj.messageId === deleteMessage?.data?.chat?.messageId)
|
|
516
|
+
);
|
|
517
|
+
state?.messages[findUserId?.conversationId].splice(currIndex, 1);
|
|
518
|
+
setState((prev) => {
|
|
519
|
+
return {
|
|
520
|
+
...prev,
|
|
521
|
+
messages: {
|
|
522
|
+
...prev.messages,
|
|
523
|
+
[sidebarChatItem?.conversationId]: [...state?.messages[findUserId?.conversationId]],
|
|
524
|
+
},
|
|
525
|
+
};
|
|
526
|
+
});
|
|
527
|
+
} catch (error) {
|
|
528
|
+
console.error('error', error);
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
useEffect(() => {
|
|
533
|
+
if (findUserId.action === MESSAGE_DELETE_FOR_ALL) {
|
|
534
|
+
allMessagesArray();
|
|
535
|
+
}
|
|
536
|
+
}, [findUserId]);
|
|
537
|
+
|
|
538
|
+
const deleteMesageHandler = async () => {
|
|
539
|
+
try {
|
|
540
|
+
const res = await deletemesageForSelf(sidebarChatItem?.conversationId, deleteMessage?.data?.chat?.messageId);
|
|
541
|
+
sortedMessageArraySelf();
|
|
542
|
+
setDeleteMessage({ ...deleteMessage, delete: false, data: {} });
|
|
543
|
+
setIsDelete(true);
|
|
544
|
+
} catch (error) {
|
|
545
|
+
console.error('error', error);
|
|
546
|
+
setToastStatus({ open: true, variant: "error", message: error.messages || error });
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
const cancleDeleteMessage = () => {
|
|
552
|
+
setDeleteMessage({ ...deleteMessage, delete: false, data: {} });
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
const deleteMessageEveryone = async () => {
|
|
556
|
+
try {
|
|
557
|
+
const res = await deleteMessageforEveryOne(sidebarChatItem?.conversationId, deleteMessage?.data?.chat?.messageId);
|
|
558
|
+
setDeleteMessage({ ...deleteMessage, delete: false, data: {} });
|
|
559
|
+
} catch (error) {
|
|
560
|
+
console.error('error', error);
|
|
561
|
+
setToastStatus({ open: true, variant: "error", message: error.messages || error });
|
|
562
|
+
}
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
const sendClickedImage = async () => {
|
|
566
|
+
try {
|
|
567
|
+
const { valid, error } = mediaUploadValidator(convertClickedImageToFileType);
|
|
568
|
+
if (!valid) {
|
|
569
|
+
setToastStatus({ open: true, message: 'File Size should be less than 50MB.', variant: 'error' })
|
|
570
|
+
return;
|
|
571
|
+
}
|
|
572
|
+
await uploadImageToServer(convertClickedImageToFileType);
|
|
573
|
+
setTakeCameraPhoto(false);
|
|
574
|
+
} catch (error) {
|
|
575
|
+
console.error('error', error);
|
|
576
|
+
}
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
const attachmentOptionClickHandler = (data) => {
|
|
580
|
+
setUploadFiles(!uploadFiles);
|
|
581
|
+
setHoveredItem(null);
|
|
582
|
+
if (data.id === 0) {
|
|
583
|
+
setTakeCameraPhoto(true);
|
|
584
|
+
} else if (data.id === 2) {
|
|
585
|
+
selectImageUploadRef.current.click();
|
|
586
|
+
} else if (data.id === 1) {
|
|
587
|
+
documentUploadRef.current.click();
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
|
|
591
|
+
const handleOnFocus = () => {
|
|
592
|
+
console.log('!!! -- handleOnFocus -- !!!');
|
|
593
|
+
window.scrollTo(0, 0);
|
|
594
|
+
document.body.scrollTop = 0;
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
const documentUploadHandler = async (e) => {
|
|
598
|
+
try {
|
|
599
|
+
const file = e.target.files[0];
|
|
600
|
+
const { valid, error } = documentUploadValidator(file);
|
|
601
|
+
if (!valid) {
|
|
602
|
+
setToastStatus({ open: true, message: error, variant: 'error' })
|
|
603
|
+
return;
|
|
604
|
+
};
|
|
605
|
+
await uploadImageToServer(file, true);
|
|
606
|
+
} catch (error) {
|
|
607
|
+
console.error(error, 'error');
|
|
608
|
+
setToastStatus({ open: true, message: 'Something went wrong!', variant: 'error' })
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
}
|
|
612
|
+
|
|
613
|
+
return (
|
|
614
|
+
<>
|
|
615
|
+
<PaginationForMsg
|
|
616
|
+
elementRef={chatScrollMessageRef}
|
|
617
|
+
pageEventHandler={getPaginationMessagesData}
|
|
618
|
+
isTop={true}
|
|
619
|
+
/>
|
|
620
|
+
{
|
|
621
|
+
takeCameraPhoto ?
|
|
622
|
+
<>
|
|
623
|
+
<TakePhoto setConvertClickedImageToFileType={setConvertClickedImageToFileType} sendClickedImage={sendClickedImage} theme={props?.theme} isTakePhotoModal={takeCameraPhoto} onClose={() => setTakeCameraPhoto(false)} />
|
|
624
|
+
</> :
|
|
625
|
+
<>
|
|
626
|
+
<ChatBoxBodyContainer
|
|
627
|
+
className="chatbox_body"
|
|
628
|
+
id="allMessages"
|
|
629
|
+
style={{
|
|
630
|
+
background: `url(${props?.theme === true ? darkbg : watsappbg})`,
|
|
631
|
+
}}
|
|
632
|
+
>
|
|
633
|
+
<ChatMessages ref={chatScrollMessageRef} id="chat-messages">
|
|
634
|
+
<MessagesBox
|
|
635
|
+
getUsersChatMessagesDetail={messages || []}
|
|
636
|
+
chatProfileData={sidebarChatItem?.opponentDetails}
|
|
637
|
+
conversationId={sidebarChatItem?.conversationId}
|
|
638
|
+
theme={props?.theme}
|
|
639
|
+
findUserId={findUserId}
|
|
640
|
+
state={state}
|
|
641
|
+
setState={setState}
|
|
642
|
+
chatContainerRef={chatScrollMessageRef}
|
|
643
|
+
setslideShow={setslideShow}
|
|
644
|
+
setMessageInfo={setMessageInfo}
|
|
645
|
+
messageInfo={messageInfo}
|
|
646
|
+
MessageInfoHandler={MessageInfoHandler}
|
|
647
|
+
setMessageChat={setMessageChat}
|
|
648
|
+
setSearchShow={setSearchShow}
|
|
649
|
+
setToastStatus={setToastStatus}
|
|
650
|
+
setIsReply={setIsReply}
|
|
651
|
+
isReply={isReply}
|
|
652
|
+
setReply={setReply}
|
|
653
|
+
reply={reply}
|
|
654
|
+
setDeleteMessage={setDeleteMessage}
|
|
655
|
+
deleteMessage={deleteMessage}
|
|
656
|
+
setIsDelete={setIsDelete}
|
|
657
|
+
isDelete={isDelete}
|
|
658
|
+
setMediaDocs={setMediaDocs}
|
|
659
|
+
userDetails={userDetails}
|
|
660
|
+
handleImgVidClick={handleImgVidClick}
|
|
661
|
+
setIsOpen={setIsOpen}
|
|
662
|
+
isOpen={isOpen}
|
|
663
|
+
getMediaDocs={getMediaDocs}
|
|
664
|
+
/>
|
|
665
|
+
</ChatMessages>
|
|
666
|
+
</ChatBoxBodyContainer>
|
|
667
|
+
<FormContainer>
|
|
668
|
+
{
|
|
669
|
+
userConversationDetail?.messagingDisabled ?
|
|
670
|
+
<BlockUserFooter>
|
|
671
|
+
<BlockUserFooterText>{`Can't send a message to blocked contact ${userConversationDetail.opponentDetails.userName} .`}</BlockUserFooterText>
|
|
672
|
+
</BlockUserFooter>
|
|
673
|
+
:
|
|
674
|
+
<div
|
|
675
|
+
className={
|
|
676
|
+
!props?.footer ? "chat_footer footerChat" : "chat_footer footer"
|
|
677
|
+
}
|
|
678
|
+
>
|
|
679
|
+
{/* <ReplyMessage reply={reply?.isreply}>
|
|
680
|
+
{reply?.isreply && <ReplyChatMessage setReply={setReply} reply={reply} />}
|
|
681
|
+
</ReplyMessage> */}
|
|
682
|
+
{isShowEmojiPicker &&
|
|
683
|
+
<ImageComponent
|
|
684
|
+
src={CLOSE_ICON}
|
|
685
|
+
style={{ margin: "0px 10px", padding: "2px" }}
|
|
686
|
+
className={props?.theme ? "darkicons" : "lighticons"}
|
|
687
|
+
onClick={() => setIsShowEmojiPicker(false)}
|
|
688
|
+
/>}
|
|
689
|
+
{
|
|
690
|
+
!audioRecorderStatus
|
|
691
|
+
&&
|
|
692
|
+
<>
|
|
693
|
+
<OutsideAlerter onClose={() => setIsShowEmojiPicker(false)}>
|
|
694
|
+
{
|
|
695
|
+
!isShowEmojiPicker &&
|
|
696
|
+
<ImageComponent
|
|
697
|
+
src={EMOJI_ICON}
|
|
698
|
+
className={props?.theme ? "dark_footer_icons" : "light_footer_icons"}
|
|
699
|
+
onClick={() => setIsShowEmojiPicker(true)}
|
|
700
|
+
/>
|
|
701
|
+
}
|
|
702
|
+
|
|
703
|
+
<EmojiPicker isShowEmojiPicker={isShowEmojiPicker}>
|
|
704
|
+
<Picker
|
|
705
|
+
width="100%"
|
|
706
|
+
className=""
|
|
707
|
+
onEmojiClick={(e) => handleOnEmojiClick(e)}
|
|
708
|
+
autoFocusSearch
|
|
709
|
+
emojiStyle="apple"
|
|
710
|
+
height="100%"
|
|
711
|
+
previewConfig={{ showPreview: false, defaultCaption: 'hello' }}
|
|
712
|
+
/>
|
|
713
|
+
</EmojiPicker> </OutsideAlerter>
|
|
714
|
+
<ChatMessageWrapper>
|
|
715
|
+
<OutsideAlerter onClose={() => setUploadFiles(false)}>
|
|
716
|
+
<ImageComponent
|
|
717
|
+
onClick={() => setUploadFiles(!uploadFiles)}
|
|
718
|
+
style={{ margilLeft: "10px", height: "35px", width: "35px" }}
|
|
719
|
+
src={ATTACH_FILE}
|
|
720
|
+
className={props?.theme ? "dark_footer_icons" : "light_footer_icons"}
|
|
721
|
+
/>
|
|
722
|
+
<AttachFile uploadFiles={uploadFiles}>
|
|
723
|
+
<AttachFileContainer>
|
|
724
|
+
{
|
|
725
|
+
chatAttachmentOptions.map(data => (
|
|
726
|
+
<CameraImage key={data.title}
|
|
727
|
+
onMouseEnter={() => setHoveredItem(data.title)}
|
|
728
|
+
onMouseLeave={() => setHoveredItem(null)}
|
|
729
|
+
>
|
|
730
|
+
<ImageComponent
|
|
731
|
+
onClick={() => {
|
|
732
|
+
attachmentOptionClickHandler(data);
|
|
733
|
+
}}
|
|
734
|
+
src={data.imageUrl}
|
|
735
|
+
className="darkicons"
|
|
736
|
+
/>
|
|
737
|
+
{hoveredItem === data.title &&
|
|
738
|
+
<ShowHoverItem>
|
|
739
|
+
{hoveredItem}
|
|
740
|
+
</ShowHoverItem>
|
|
741
|
+
}
|
|
742
|
+
</CameraImage>
|
|
743
|
+
))
|
|
744
|
+
}
|
|
745
|
+
<input type="file" ref={documentUploadRef} className="d-none" onChange={documentUploadHandler} name="" id="" />
|
|
746
|
+
<input ref={selectImageUploadRef} accept="image/png, image/gif, image/jpeg, input/jpg, video/mp4" multiple type="file" name="file" id="file-input" onClick={(event) => event.target.value = null} className="d-none" onChange={galleryClickHandler} />
|
|
747
|
+
</AttachFileContainer>
|
|
748
|
+
</AttachFile>
|
|
749
|
+
</OutsideAlerter>
|
|
750
|
+
<textarea
|
|
751
|
+
style={{ resize: "none", height: "50px" }}
|
|
752
|
+
placeholder="Type a message..."
|
|
753
|
+
name="text"
|
|
754
|
+
value={messageText}
|
|
755
|
+
onChange={(e) => setMessageText(e.target.value)}
|
|
756
|
+
onKeyDown={handleKeyDown}
|
|
757
|
+
onFocus={handleOnFocus}
|
|
758
|
+
/>
|
|
759
|
+
</ChatMessageWrapper>
|
|
760
|
+
</>
|
|
761
|
+
}
|
|
762
|
+
{
|
|
763
|
+
audioRecorderStatus &&
|
|
764
|
+
<AudioRecorder audioRecorderStatus={audioRecorderStatus} theme={theme} setAudioRecorderStatus={setAudioRecorderStatus} ref={submitAudioRecordingRef} setRecordedStream={setRecordedStream} conversationId={sidebarChatItem?.conversationId} onClose={() => audioCloseHandler()} setMessageText={setMessageText} recordedStream={recordedStream} />
|
|
765
|
+
}
|
|
766
|
+
<div>
|
|
767
|
+
<>
|
|
768
|
+
{
|
|
769
|
+
showAudioRecordButton && !messageText?.length &&
|
|
770
|
+
(
|
|
771
|
+
<span className="cursor-pointer">
|
|
772
|
+
<ImageComponent
|
|
773
|
+
onClick={() => audioHandler()}
|
|
774
|
+
src={VOICE}
|
|
775
|
+
className={props?.theme ? "dark_footer_icons" : "light_footer_icons"}
|
|
776
|
+
/>
|
|
777
|
+
</span>
|
|
778
|
+
)
|
|
779
|
+
}
|
|
780
|
+
</>
|
|
781
|
+
<>
|
|
782
|
+
{
|
|
783
|
+
(messageText?.length || messageText) &&
|
|
784
|
+
<ImageComponent
|
|
785
|
+
onClick={handleSubmit}
|
|
786
|
+
src={SENDICON}
|
|
787
|
+
className={props?.theme ? "dark_footer_icons" : "light_footer_icons"}
|
|
788
|
+
/>
|
|
789
|
+
}
|
|
790
|
+
</>
|
|
791
|
+
</div>
|
|
792
|
+
</div>
|
|
793
|
+
}
|
|
794
|
+
{/* <OutsideAlerter onClose={()=>setUploadFiles(false)}>
|
|
795
|
+
<AttachFile uploadFiles={uploadFiles}>
|
|
796
|
+
<PollImage >
|
|
797
|
+
<ImageComponent
|
|
798
|
+
onClick={()=>setUploadFiles(!uploadFiles)}
|
|
799
|
+
src={POll}
|
|
800
|
+
className="darkicons"
|
|
801
|
+
/>
|
|
802
|
+
</PollImage>
|
|
803
|
+
<UserImage>
|
|
804
|
+
<ImageComponent
|
|
805
|
+
onClick={()=>setUploadFiles(!uploadFiles)}
|
|
806
|
+
src={USER}
|
|
807
|
+
className="darkicons"
|
|
808
|
+
/>
|
|
809
|
+
</UserImage>
|
|
810
|
+
<DocumentImage>
|
|
811
|
+
<ImageComponent
|
|
812
|
+
onClick={()=>setUploadFiles(!uploadFiles)}
|
|
813
|
+
src={DOCUMENT}
|
|
814
|
+
className="darkicons"
|
|
815
|
+
/>
|
|
816
|
+
</DocumentImage>
|
|
817
|
+
<CameraImage>
|
|
818
|
+
<ImageComponent
|
|
819
|
+
onClick={()=>setUploadFiles(!uploadFiles)}
|
|
820
|
+
src={CAMERA}
|
|
821
|
+
className="darkicons"
|
|
822
|
+
/>
|
|
823
|
+
</CameraImage>
|
|
824
|
+
<StickerImage>
|
|
825
|
+
<ImageComponent
|
|
826
|
+
|
|
827
|
+
onClick={()=>setUploadFiles(!uploadFiles)}
|
|
828
|
+
src={STICKER}
|
|
829
|
+
className="darkicons"
|
|
830
|
+
/>
|
|
831
|
+
</StickerImage>
|
|
832
|
+
<GalleryImage>
|
|
833
|
+
<ImageComponent
|
|
834
|
+
onClick={()=>setUploadFiles(!uploadFiles)}
|
|
835
|
+
src={GALLERY}
|
|
836
|
+
className="darkicons"
|
|
837
|
+
/>
|
|
838
|
+
</GalleryImage>
|
|
839
|
+
</AttachFile>
|
|
840
|
+
</OutsideAlerter> */}
|
|
841
|
+
</FormContainer>
|
|
842
|
+
|
|
843
|
+
|
|
844
|
+
<CustomModal open={deleteMessage?.delete} >
|
|
845
|
+
<ModalDialog DeleteModal={"Delete messages"} isSelfMessage={isSelfMessage} handleOnCloseModal={cancleDeleteMessage} deleteMesageHandler={deleteMesageHandler} handleUnblockUser={deleteMessageEveryone} setToastStatus={setToastStatus}
|
|
846
|
+
/>
|
|
847
|
+
</CustomModal>
|
|
848
|
+
|
|
849
|
+
|
|
850
|
+
</>
|
|
851
|
+
}
|
|
852
|
+
</>
|
|
853
|
+
);
|
|
854
|
+
}
|
|
855
|
+
|
|
856
|
+
export default Chatbox;
|