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.
Files changed (188) hide show
  1. package/README.md +74 -0
  2. package/babel.config.js +6 -0
  3. package/dist/index.js +684 -0
  4. package/package.json +59 -0
  5. package/public/Logo-192x192.png +0 -0
  6. package/public/Logo-512x512.png +0 -0
  7. package/public/favicon.ico +0 -0
  8. package/public/fonts/BenjaminVictoria.ttf +0 -0
  9. package/public/icons/arrow_logo.svg +9 -0
  10. package/public/icons/assets/ic_placeholder_banner.svg +1 -0
  11. package/public/icons/attach-file.svg +9 -0
  12. package/public/icons/audio_pause.svg +1 -0
  13. package/public/icons/audio_play.svg +6 -0
  14. package/public/icons/back.svg +3 -0
  15. package/public/icons/bell.svg +1 -0
  16. package/public/icons/block.svg +1 -0
  17. package/public/icons/bottom-arrow.svg +1 -0
  18. package/public/icons/camera-switch.svg +12 -0
  19. package/public/icons/camera.svg +4 -0
  20. package/public/icons/cancel.svg +1 -0
  21. package/public/icons/chat empty placeholder.svg +58 -0
  22. package/public/icons/chat_audio_pause.png +0 -0
  23. package/public/icons/chat_audio_play.png +0 -0
  24. package/public/icons/close.svg +5 -0
  25. package/public/icons/crossCarousel.svg +3 -0
  26. package/public/icons/delete.svg +3 -0
  27. package/public/icons/disappear.svg +24 -0
  28. package/public/icons/document.png +0 -0
  29. package/public/icons/document.svg +1 -0
  30. package/public/icons/downloadCarousel.svg +6 -0
  31. package/public/icons/edit-pencil.svg +6 -0
  32. package/public/icons/emoji.svg +8 -0
  33. package/public/icons/emojiCarousel.svg +3 -0
  34. package/public/icons/filter.svg +1 -0
  35. package/public/icons/forwardCarousel.svg +3 -0
  36. package/public/icons/gallery.svg +1 -0
  37. package/public/icons/goToMessageCarousel.svg +3 -0
  38. package/public/icons/ic_uil_arrow-left.svg +1 -0
  39. package/public/icons/ic_uil_eye-slash.svg +1 -0
  40. package/public/icons/ic_uil_eye.svg +1 -0
  41. package/public/icons/leftArrowCarousel.svg +6 -0
  42. package/public/icons/light-mode.svg +14 -0
  43. package/public/icons/lock.svg +1 -0
  44. package/public/icons/login_background.png +0 -0
  45. package/public/icons/menu .svg +5 -0
  46. package/public/icons/menuCarousel.svg +5 -0
  47. package/public/icons/message.svg +3 -0
  48. package/public/icons/placeholder.svg +958 -0
  49. package/public/icons/poll.svg +1 -0
  50. package/public/icons/retake.png +0 -0
  51. package/public/icons/right-arrow.svg +3 -0
  52. package/public/icons/right.svg +3 -0
  53. package/public/icons/round-star.svg +1 -0
  54. package/public/icons/search.svg +3 -0
  55. package/public/icons/send.svg +10 -0
  56. package/public/icons/starCarousel.svg +3 -0
  57. package/public/icons/status.svg +1 -0
  58. package/public/icons/sticker.svg +1 -0
  59. package/public/icons/thumb-down.svg +1 -0
  60. package/public/icons/user.svg +1 -0
  61. package/public/icons/users.svg +1 -0
  62. package/public/icons/voice.png +0 -0
  63. package/public/index.html +38 -0
  64. package/public/logo192.png +0 -0
  65. package/public/logo512.png +0 -0
  66. package/public/manifest.json +25 -0
  67. package/public/offline.html +12 -0
  68. package/public/robots.txt +3 -0
  69. package/public/service-worker.js +81 -0
  70. package/src/App.js +15 -0
  71. package/src/App.test.js +8 -0
  72. package/src/Authpage.js +16 -0
  73. package/src/ChatContext.js +172 -0
  74. package/src/Data/index.js +110 -0
  75. package/src/assets/icons.js +49 -0
  76. package/src/assets/images/WhatsApp.html +258 -0
  77. package/src/assets/images/WhatsApp_files/301446776_522918349234681_1974693392291574064_n.jpg +0 -0
  78. package/src/assets/images/WhatsApp_files/app-bf223f825866ee433b07.css +242 -0
  79. package/src/assets/images/WhatsApp_files/app.77ee8aa7a4c593101105.js +77 -0
  80. package/src/assets/images/WhatsApp_files/lazy_loaded_high_priority_components.85a06e74a0a4ade1640b.css +16 -0
  81. package/src/assets/images/WhatsApp_files/lazy_loaded_low_priority_components.8621270bc215a9298a97.css +47 -0
  82. package/src/assets/images/WhatsApp_files/libsignal-protocol-ee5b8ba.min.js +21 -0
  83. package/src/assets/images/WhatsApp_files/main.48b845d68e066fb27a75.css +161 -0
  84. package/src/assets/images/WhatsApp_files/runtime.e6018f3c1e255e8f4dc7.js +2 -0
  85. package/src/assets/images/WhatsApp_files/stylex-d50abd61e6cf7eab2afd855adccf14e5.css +2841 -0
  86. package/src/assets/images/WhatsApp_files/vendor1_app.58a51d93a250f83ab555.js +79 -0
  87. package/src/assets/images/bg.jpeg +0 -0
  88. package/src/assets/images/drkbg.jpg +0 -0
  89. package/src/assets/images/notFound.jpeg +0 -0
  90. package/src/assets/images/watsapp.jpg +0 -0
  91. package/src/assets/images/watsappbg.png +0 -0
  92. package/src/assets/images/wb.jpg +0 -0
  93. package/src/assets/images/whatsapp.jpeg +0 -0
  94. package/src/components/ChatBox/AudioBubble.js +162 -0
  95. package/src/components/ChatBox/ChatBubble.js +232 -0
  96. package/src/components/ChatBox/DocumentBubble.js +87 -0
  97. package/src/components/ChatBox/MessagesBox.js +533 -0
  98. package/src/components/CustomModal.js +60 -0
  99. package/src/components/Icon.js +10 -0
  100. package/src/components/ImageComponent.js +24 -0
  101. package/src/components/MediaDocs.js +155 -0
  102. package/src/components/MediaDocumentContainer.js +55 -0
  103. package/src/components/MessageInfoDropdown.js +124 -0
  104. package/src/components/Modal/AllowMicPermissionModal.js +63 -0
  105. package/src/components/Modal/BlockUnblockChatModal.js +78 -0
  106. package/src/components/Modal/CameraPermissionBlockedModal.js +61 -0
  107. package/src/components/Modal/CameraPermissionRequestModal.js +60 -0
  108. package/src/components/Modal/ClearChatModal.js +78 -0
  109. package/src/components/Modal/DeleteChatModal.js +79 -0
  110. package/src/components/Modal/MicPermissionDisableModal.js +63 -0
  111. package/src/components/Modal/Modal.js +103 -0
  112. package/src/components/Modal/ModalDialog.js +103 -0
  113. package/src/components/Modal/ProfilePictureUploadPreview.js +160 -0
  114. package/src/components/OutsideAlerter/OutsideAlerter.js +38 -0
  115. package/src/components/ProfilePicture/ProfilePicture.js +127 -0
  116. package/src/components/Registration/Login.js +265 -0
  117. package/src/components/Registration/SignUp.js +322 -0
  118. package/src/components/SnackBar.js +42 -0
  119. package/src/components/common/Modal/useDetectOutsideClick.js +23 -0
  120. package/src/components/common/styled/PageWrapper.js +25 -0
  121. package/src/components/formcontrol/CustomButton.js +38 -0
  122. package/src/components/formcontrol/InputText.js +60 -0
  123. package/src/global-styles.js +42 -0
  124. package/src/hooks/useDeviceType.js +28 -0
  125. package/src/hooks/useThrottle.js +29 -0
  126. package/src/index.css +225 -0
  127. package/src/index.js +23 -0
  128. package/src/lib/constant.js +21 -0
  129. package/src/lib/functionality.js +13 -0
  130. package/src/lib/helpers.js +320 -0
  131. package/src/lib/mockData/index.js +76 -0
  132. package/src/lib/session/index.js +31 -0
  133. package/src/lib/validation.js +4 -0
  134. package/src/logo.svg +1 -0
  135. package/src/pages/WhatsappMainBox/index.js +574 -0
  136. package/src/reportWebVitals.js +13 -0
  137. package/src/services/deliveryStatus.js +27 -0
  138. package/src/setupTests.js +5 -0
  139. package/src/utils/chatSdk.js +14 -0
  140. package/src/utils/global.js +57 -0
  141. package/src/utils/media.js +79 -0
  142. package/src/view/component/BlockedContactSlide.js +134 -0
  143. package/src/view/component/Carousle/UpperMenuBar.js +106 -0
  144. package/src/view/component/Carousle/index.js +204 -0
  145. package/src/view/component/Chatbox.js/AudioRecorder.js +311 -0
  146. package/src/view/component/Chatbox.js/ChatBubbleReply.js +27 -0
  147. package/src/view/component/Chatbox.js/TakePhoto.js +363 -0
  148. package/src/view/component/Chatbox.js/index.js +856 -0
  149. package/src/view/component/Chatbox.js/styles.css +231 -0
  150. package/src/view/component/Contact/index.js +56 -0
  151. package/src/view/component/Contact/styles.css +208 -0
  152. package/src/view/component/ContactInfo/index.js +543 -0
  153. package/src/view/component/ContactInfo/styles.css +289 -0
  154. package/src/view/component/Context/index.js +3 -0
  155. package/src/view/component/DialogBox.js +15 -0
  156. package/src/view/component/ImageCropper/ImageCropper.js +128 -0
  157. package/src/view/component/Loader/Loader.js +52 -0
  158. package/src/view/component/Loader/UserPagingLoader.js +62 -0
  159. package/src/view/component/MainChatBox/index.js +819 -0
  160. package/src/view/component/MainChatBox/styles.css +124 -0
  161. package/src/view/component/Menu/index.js +261 -0
  162. package/src/view/component/Menu/styles.css +68 -0
  163. package/src/view/component/Profile/ProfileInfoContainer.js +112 -0
  164. package/src/view/component/Profile/ProfileUpdate.js +178 -0
  165. package/src/view/component/Profile/TakeProfilePhoto.js +391 -0
  166. package/src/view/component/Profile/index.js +550 -0
  167. package/src/view/component/Profile/styles.css +370 -0
  168. package/src/view/component/ReplyChatMessage/ReplyChatMessage.js +48 -0
  169. package/src/view/component/SeachBar/index.js +106 -0
  170. package/src/view/component/SeachBar/styles.css +53 -0
  171. package/src/view/component/Siderbar/index.js +512 -0
  172. package/src/view/component/Siderbar/styles.css +138 -0
  173. package/src/view/component/Toaster/Toaster.js +117 -0
  174. package/src/view/component/UserDetailsCard/UserDetailCard.js +337 -0
  175. package/src/view/component/deleteMessageMoal.js +80 -0
  176. package/src/view/component/emoji/index.js +22 -0
  177. package/src/view/component/emoji/sstyles.css +0 -0
  178. package/src/view/component/forwardData/index.js +327 -0
  179. package/src/view/component/forwardData/styles.css +112 -0
  180. package/src/view/component/forwardPopup/index.js +55 -0
  181. package/src/view/component/forwardPopup/styles.css +144 -0
  182. package/src/view/component/mediaList/index.js +92 -0
  183. package/src/view/component/menuDialog/index.js +71 -0
  184. package/src/view/component/menuDialog/styles.css +24 -0
  185. package/src/view/component/pagination/pagination.js +52 -0
  186. package/src/view/component/pagination/paginationForMsg.js +43 -0
  187. package/src/view/component/sidebarChat/index.js +321 -0
  188. package/src/view/component/sidebarChat/styles.css +109 -0
@@ -0,0 +1,574 @@
1
+ import React, { useEffect, useRef } from "react";
2
+ import Siderbar from "../../view/component/Siderbar";
3
+ import MainChatBox from "../../view/component/MainChatBox";
4
+ import { useState } from "react";
5
+ import client from "../../utils/chatSdk";
6
+ import styled, { css } from "styled-components";
7
+ import { mobile, tabletOnly } from "../../utils/media";
8
+ import { authClear, removeLocalStorage } from "../../lib/session";
9
+ import ImageComponent from "../../components/ImageComponent";
10
+ import {
11
+ clearConversationSelfMessages,
12
+ debounce,
13
+ deleteConversationSelfMessages,
14
+ // getTimeWithMeridian,
15
+ getUserConversationDetails,
16
+ postBlockUser,
17
+ postUnblockUser,
18
+ } from "../../lib/helpers";
19
+ import ClearChatModal from "../../components/Modal/ClearChatModal";
20
+ import CustomModal from "../../components/CustomModal";
21
+ import DeleteChatModal from "../../components/Modal/DeleteChatModal";
22
+ import BlockUnblockChatModal from "../../components/Modal/BlockUnblockChatModal";
23
+ import Toaster from "../../view/component/Toaster/Toaster";
24
+ import { CONVERSATION_NOT_FOUND } from "../../lib/constant";
25
+ import ProfilePicture from "../../components/ProfilePicture/ProfilePicture";
26
+ import Loader from "../../view/component/Loader/Loader";
27
+ import { ChatState } from "../../ChatContext";
28
+ import Authpage from "../../Authpage";
29
+
30
+ const WhatsappSection = styled.section`
31
+ height: 100%;
32
+ background-color: #dadbd3;
33
+ display: grid;
34
+ `;
35
+ const WhatsappRightTag = styled.div`
36
+ background: var(--gray_color);
37
+ `;
38
+
39
+ const SignOut = styled.div`
40
+ display: none;
41
+ background-color: var(--modal_color);
42
+ position: absolute;
43
+ bottom: 0px;
44
+ padding: 20px 75px 20px 20px;
45
+ width: 100%;
46
+ align-items: center;
47
+
48
+ .userImg {
49
+ height: 65px;
50
+ width: 65px;
51
+ border-radius: 60px;
52
+ background-size: cover;
53
+ background-repeat: no-repeat;
54
+ }
55
+
56
+ ${tabletOnly(css`
57
+ display: none;
58
+ `)}
59
+
60
+ ${mobile(css`
61
+ display: flex;
62
+ `)}
63
+ `;
64
+
65
+ const ButtonAction = styled.div`
66
+ display: flex;
67
+ justify-content: flex-end;
68
+ margin-bottom: 20px;
69
+ color: white;
70
+
71
+ .cancleBtn {
72
+ background: var(--white);
73
+ color: var(--button-primary-background);
74
+ border: 1px solid var(--border_color);
75
+ }
76
+
77
+ .logoutBtn {
78
+ background-color: var(--button-primary-background);
79
+ color: var(--white);
80
+ }
81
+ `;
82
+
83
+ const ButtonMobileAction = styled.div`
84
+ display:flex;
85
+ `;
86
+
87
+
88
+ const UserDetails = styled.div`
89
+ color:var(--black);
90
+ width:72%;
91
+
92
+ .signOutBtn{
93
+ padding:7px 15px;
94
+ border:none;
95
+ border-radius:20px;
96
+ background:var(--button-primary-background);
97
+ color:white;
98
+ margin-left:0px;
99
+ }
100
+
101
+ .cancelBtn{
102
+ padding:7px 15px;
103
+ border:none;
104
+ border-radius:20px;
105
+ background:var(--button-primary-background);
106
+ color:white;
107
+ margin-left:10px;
108
+ }
109
+ `;
110
+
111
+ const Button = styled.button`
112
+ margin-left: 15px;
113
+ border-radius: 20px;
114
+ border: none;
115
+ padding: 5px 20px 5px 20px;
116
+ `;
117
+
118
+ const DesktopLogOut = styled.div`
119
+ width:100%;
120
+ height:100%;
121
+ top:0;
122
+ background-color:var(--modal-backDrop);
123
+ position:absolute;
124
+ border:none;
125
+ .logoutModal{
126
+ background-color: var(--modal_color);
127
+ color:var(--black);
128
+ position: absolute;
129
+ box-shadow: 0 4px 8px 0 rgb(0 0 0 / 20%), 0 6px 20px 0 rgb(0 0 0 / 19%);
130
+ width:32rem;
131
+ top:50%;
132
+ left:50%;
133
+ z-index:999;
134
+ transform: translate(-50%,-50%);
135
+ padding:20px 24px 6px 22px;
136
+ line-height: 1.7;
137
+ max-height:14rem
138
+ box-shadow: 0 4px 8px 0 rgb(0 0 0 / 20%), 0 6px 20px 0 rgb(0 0 0 / 19%);
139
+
140
+ ${mobile(css`
141
+ display: none;
142
+ `)}
143
+ }`;
144
+
145
+ function WhatsappMainBox(props) {
146
+ const { showLoader, setShowLoader, theme, userDetails, setUserDetails, findUserId, state, setState, userloggedIn, loading } = ChatState();
147
+ const {
148
+ showSideChatHeader,
149
+ } = props;
150
+ const [sidebarChatItem, setSidebarChatItem] = useState();
151
+ const [disabledKey, setDisabledKey] = useState(false);
152
+ const preventConversationRef = useRef(false);
153
+ const [isSidebarShow, setIsSidebarShow] = useState(false);
154
+ const [isLogOut, setIsLogOut] = useState(false);
155
+ const [showConversationPagingLoader, setShowConversationPagingLoader] = useState(false);
156
+ const preventMessageRef = useRef(false);
157
+ const [clearChatModal, setClearChatModal] = useState(false);
158
+ const [deleteChatModal, setDeleteChatModal] = useState(false);
159
+ const [userBlockModal, setUserBlockModal] = useState(false);
160
+ const [userConversationDetail, setUserConversationDetail] = useState({});
161
+ const [slideShow, setslideShow] = useState(false);
162
+ const [searchShow, setSearchShow] = useState(false);
163
+ const [messageInfo, setMessageInfo] = useState(false);
164
+ const [toastStatus, setToastStatus] = useState({open: false, message: '', variant: ''});
165
+ const [searchedMessageArray, setSearchedMessageArray] = useState([]);
166
+ const [searchMessageLoaderStatus, setSearchMessageLoaderStatus] = useState(false);
167
+ const [conversationNotFound, setConversationNotFound] = useState(false);
168
+ const [mediaDocs , setMediaDocs] = useState();
169
+ const [enteredSearchQuery, setEnteredSearchQuery] = useState('');
170
+ const [showProfilePicture, setShowProfilePicture] = useState({
171
+ showProfile: false,
172
+ userName: "",
173
+ userImageSrc: "",
174
+ theme: theme,
175
+ });
176
+
177
+ const sidebarData = (sidebarChatItem) => {
178
+ setSidebarChatItem(sidebarChatItem);
179
+ };
180
+ const body = {
181
+ limit: 20,
182
+ skip: 0,
183
+ isGroup: false,
184
+ };
185
+ const payload = {
186
+ limit: 20,
187
+ skip: 0,
188
+ isGroup: false,
189
+ conversationId: sidebarChatItem?.conversationId,
190
+ };
191
+ const getHomePageConversationData = async (body, pagingStatus) => {
192
+ try {
193
+ if (pagingStatus) {
194
+ setShowConversationPagingLoader(true);
195
+ } else {
196
+ setShowLoader(true);
197
+ }
198
+ preventConversationRef.current = true;
199
+ const res = await client?.Conversation?.getConversations(body);
200
+ setState((prev) => {
201
+ return {
202
+ ...prev,
203
+ conversations: [...prev.conversations, ...res?.conversations]
204
+ };
205
+ });
206
+ setShowLoader(false);
207
+ setShowConversationPagingLoader(false);
208
+ } catch (error) {
209
+ setState((prev) => {
210
+ return {
211
+ ...prev,
212
+ conversations: [...prev.conversations]
213
+ };
214
+ });
215
+ setConversationNotFound(error?.message === CONVERSATION_NOT_FOUND);
216
+ setShowLoader(false);
217
+ setShowConversationPagingLoader(false);
218
+ console.log(error?.msg , error?.message , "err");
219
+ } finally {
220
+ setShowLoader(false);
221
+ setShowConversationPagingLoader(false);
222
+ preventConversationRef.current = false;
223
+ }
224
+ };
225
+
226
+ const getSearchMessages = async (value) => {
227
+ setEnteredSearchQuery(value);
228
+ const payload = {
229
+ conversationId: sidebarChatItem?.conversationId,
230
+ searchTag: btoa(value),
231
+ }
232
+ try {
233
+ if (value?.length) {
234
+ setSearchMessageLoaderStatus(true);
235
+ const res = await client?.message?.getMessages(payload);
236
+ setSearchedMessageArray([...res?.messages]);
237
+ setSearchMessageLoaderStatus(false);
238
+ }else{
239
+ setSearchedMessageArray([]);
240
+ }
241
+ } catch (error) {
242
+ console.error('error', error);
243
+ setSearchedMessageArray([]);
244
+ setSearchMessageLoaderStatus(false);
245
+ }
246
+ }
247
+
248
+ const debounceSearchMessages = debounce(getSearchMessages, 500);
249
+
250
+
251
+ const getMessageData = async (payload) => {
252
+ try {
253
+ if (preventMessageRef.current) return;
254
+ preventMessageRef.current = true;
255
+ const res = await client?.message?.getMessages(payload);
256
+ const filteredResponseData = res.messages.filter(data => data?.body?.length > 0);
257
+ setState((prev) => {
258
+ return {
259
+ ...prev,
260
+ messages: {
261
+ ...prev.messages,
262
+ [sidebarChatItem?.conversationId]: [
263
+ ...prev.messages[sidebarChatItem?.conversationId],
264
+ ...filteredResponseData,
265
+ ],
266
+ },
267
+ };
268
+ });
269
+ } catch (error) {
270
+ console.log(error, "err");
271
+ setToastStatus({ open: true, variant: "error", message: error.messages });
272
+ } finally {
273
+ preventMessageRef.current = false;
274
+ }
275
+ };
276
+
277
+ useEffect(() => {
278
+ // Users Chat Conversations API
279
+ getHomePageConversationData(body);
280
+ }, []);
281
+
282
+ const getPaginationHomePageData = () => {
283
+ if (
284
+ preventConversationRef.current ||
285
+ state?.conversations?.length < body.limit ||
286
+ state?.conversations?.length % body.limit !== 0
287
+ )
288
+ return;
289
+ body.skip = (state?.conversations?.length / body.limit) * body.limit;
290
+ !conversationNotFound && getHomePageConversationData(body, true);
291
+ };
292
+
293
+ const logOutClick = () => {
294
+ setIsLogOut(false);
295
+ setTimeout(() => {
296
+ setShowLoader(true);
297
+ authClear();
298
+ }, 100);
299
+ setShowLoader(false);
300
+ };
301
+
302
+ const handleClosee = () => {
303
+ setslideShow(false);
304
+ setSearchShow(false);
305
+ };
306
+ const getPaginationMessagesData = () => {
307
+ // API called every time message hits top, need to resolve state not updating issue
308
+ if (
309
+ preventMessageRef.current ||
310
+ Object.keys(state?.messages).length === 0 ||
311
+ state?.messages[sidebarChatItem?.conversationId]?.length <
312
+ payload.limit ||
313
+ state?.messages[sidebarChatItem?.conversationId]?.length %
314
+ payload.limit !==
315
+ 0
316
+ )
317
+ return;
318
+ payload.skip =
319
+ (state?.messages[sidebarChatItem?.conversationId]?.length /
320
+ payload.limit) *
321
+ payload.limit;
322
+ getMessageData(payload);
323
+ };
324
+ const clearChatMessages = async () => {
325
+ try {
326
+ setClearChatModal(false);
327
+ const res = await clearConversationSelfMessages(sidebarChatItem?.conversationId);
328
+ setToastStatus({ open: true, variant: "success", message: res.msg });
329
+ const getLastIndexValue = state.messages[sidebarChatItem?.conversationId].pop();
330
+ state.messages[sidebarChatItem?.conversationId] = [getLastIndexValue];
331
+ setState((prev) => {
332
+ return {
333
+ ...prev,
334
+ messages: {
335
+ [sidebarChatItem?.conversationId]: [getLastIndexValue]
336
+ }
337
+ }
338
+ })
339
+ } catch (error) {
340
+ setClearChatModal(false);
341
+ setToastStatus({ open: true, variant: "error", message: error.messages });
342
+ }
343
+
344
+
345
+ }
346
+ const handleBlockUser = async () => {
347
+ try {
348
+ setUserBlockModal(false);
349
+ const res = await postBlockUser(sidebarChatItem?.opponentDetails?.userId);
350
+ const response = await getUserConversationDetails(sidebarChatItem?.conversationId);
351
+ setUserConversationDetail(response);
352
+ setToastStatus({ open: true, variant: "success", message: res.msg });
353
+ } catch (error) {
354
+ setUserBlockModal(false);
355
+ setToastStatus({ open: true, variant: "error", message: error.messages });
356
+ console.error('error', error)
357
+ }
358
+ }
359
+
360
+ const handleUnblockUser = async () => {
361
+ try {
362
+ setUserBlockModal(false);
363
+ const res = await postUnblockUser(sidebarChatItem?.opponentDetails?.userId);
364
+ setToastStatus({ open: true, variant: "success", message: res.msg });
365
+ const response = await getUserConversationDetails(sidebarChatItem?.conversationId);
366
+ setUserConversationDetail(response);
367
+ } catch (error) {
368
+ setUserBlockModal(false);
369
+ setToastStatus({ open: true, variant: "error", message: error.messages });
370
+ console.error('error', error);
371
+ }
372
+ }
373
+
374
+ const deleteChatMessages = async () => {
375
+ try {
376
+ setDeleteChatModal(false);
377
+ const res = await deleteConversationSelfMessages(sidebarChatItem?.conversationId);
378
+ setToastStatus({ open: true, variant: "success", message: res.msg });
379
+ handleClosee();
380
+ } catch (error) {
381
+ console.error('error', error);
382
+ setToastStatus({ open: true, variant: "error", message: error.messages });
383
+ setDeleteChatModal(false);
384
+ handleClosee();
385
+ }
386
+ };
387
+ return (
388
+ <>
389
+ <WhatsappSection className="overflow-hidden">
390
+ {
391
+ userloggedIn && !loading &&
392
+ <div className="d-flex" onClick={() => setDisabledKey(!disabledKey)}>
393
+ <Siderbar
394
+ state={state}
395
+ setState={setState}
396
+ sideData={state?.conversations}
397
+ sidebarData={sidebarData}
398
+ disabledKey={disabledKey}
399
+ userDetails={userDetails}
400
+ getPaginationHomePageData={getPaginationHomePageData}
401
+ preventConversationRef={preventConversationRef}
402
+ setIsSidebarShow={setIsSidebarShow}
403
+ isSidebarShow={isSidebarShow}
404
+ isLogOut={isLogOut}
405
+ setIsLogOut={setIsLogOut}
406
+ findUserId={findUserId}
407
+ sidebarChatItem={sidebarChatItem}
408
+ getHomePageConversationData={getHomePageConversationData}
409
+ setUserDetails={setUserDetails}
410
+ setShowLoader={setShowLoader}
411
+ setShowProfilePicture={setShowProfilePicture}
412
+ showConversationPagingLoader={showConversationPagingLoader}
413
+ setToastStatus={setToastStatus}
414
+ setUserConversationDetail={setUserConversationDetail}
415
+ profileClose={handleClosee}
416
+ setMediaDocs={setMediaDocs}
417
+ showSideChatHeader={showSideChatHeader}
418
+ />
419
+ <WhatsappRightTag>
420
+ <MainChatBox
421
+ theme={theme}
422
+ setClearChatModal={setClearChatModal}
423
+ setDeleteChatModal={setDeleteChatModal}
424
+ setUserBlockModal={setUserBlockModal}
425
+ state={state}
426
+ setState={setState}
427
+ sidebarChatItem={sidebarChatItem}
428
+ setIsSidebarShow={setIsSidebarShow}
429
+ isSidebarShow={isSidebarShow}
430
+ getPaginationMessagesData={getPaginationMessagesData}
431
+ preventMessageRef={preventMessageRef}
432
+ setShowProfilePicture={setShowProfilePicture}
433
+ findUserId={findUserId}
434
+ sidebarData={sidebarData}
435
+ setToastStatus={setToastStatus}
436
+ setslideShow={setslideShow}
437
+ slideShow={slideShow}
438
+ setSearchShow={setSearchShow}
439
+ searchShow={searchShow}
440
+ setUserConversationDetail={setUserConversationDetail}
441
+ userConversationDetail={userConversationDetail}
442
+ setMessageInfo={setMessageInfo}
443
+ messageInfo={messageInfo}
444
+ debounceSearchMessages={debounceSearchMessages}
445
+ searchedMessageArray={searchedMessageArray}
446
+ searchMessageLoaderStatus={searchMessageLoaderStatus}
447
+ handleClosee={handleClosee}
448
+ setMediaDocs={setMediaDocs}
449
+ mediaDocs={mediaDocs}
450
+ userDetails={userDetails}
451
+ enteredSearchQuery={enteredSearchQuery}
452
+ />
453
+ </WhatsappRightTag>
454
+ </div>
455
+ }
456
+ {isLogOut ? (
457
+ <DesktopLogOut>
458
+ <div className="logoutModal">
459
+ <h5>Log out? </h5>
460
+ <p>Are you sure you want to logout</p>
461
+ <div>
462
+ <ButtonAction className="logoutActionbtn">
463
+ <Button
464
+ className="cancleBtn"
465
+ onClick={() => setIsLogOut(false)}
466
+ >
467
+ Cancel
468
+ </Button>
469
+ <Button className="logoutBtn" onClick={logOutClick}>
470
+ Log out
471
+ </Button>
472
+ </ButtonAction>
473
+ </div>
474
+ </div>
475
+ </DesktopLogOut>
476
+ ) : (
477
+ ""
478
+ )}
479
+ {isLogOut && (
480
+ <SignOut className="signOut">
481
+ <div style={{ width: "28%" }}>
482
+ <ImageComponent
483
+ className="userImg"
484
+ src={props?.userDetails?.userProfileImageUrl}
485
+ ></ImageComponent>
486
+ </div>
487
+ <UserDetails className="actionBtn">
488
+ <h5>{props?.userDetails?.userName}</h5>
489
+ <p>{props?.userDetails?.metaData?.description}</p>
490
+ <ButtonMobileAction>
491
+ <Button className="signOutBtn" onClick={logOutClick}>
492
+ Sign Out
493
+ </Button>
494
+ <Button
495
+ className="cancelBtn"
496
+ onClick={() => setIsLogOut(false)}
497
+ >
498
+ Cancel
499
+ </Button>
500
+ </ButtonMobileAction>
501
+ </UserDetails>
502
+ </SignOut>
503
+ )}
504
+ {
505
+ clearChatModal &&
506
+ <CustomModal open={clearChatModal} backDropClick={true} onClose={() => setClearChatModal(false)} >
507
+ <ClearChatModal cancelButtonClick={() => setClearChatModal(false)} confirmButtonClick={clearChatMessages} />
508
+ </CustomModal>
509
+ }
510
+
511
+ {
512
+ deleteChatModal &&
513
+ <CustomModal open={deleteChatModal} backDropClick={true} onClose={() => setDeleteChatModal(false)} >
514
+ <DeleteChatModal
515
+ cancelButtonClick={() => setDeleteChatModal(false)}
516
+ confirmButtonClick={deleteChatMessages}
517
+ />
518
+ </CustomModal>
519
+ }
520
+
521
+ {
522
+ userBlockModal &&
523
+ <CustomModal open={userBlockModal} backDropClick={true} onClose={() => setUserBlockModal(false)} >
524
+ <BlockUnblockChatModal isUserBlocked={userConversationDetail?.messagingDisabled} userName={sidebarChatItem?.opponentDetails?.userName}
525
+ cancelButtonClick={() => setUserBlockModal(false)}
526
+ confirmButtonClick={userConversationDetail?.messagingDisabled ? handleUnblockUser : handleBlockUser}
527
+ />
528
+ </CustomModal>
529
+ }
530
+ {
531
+
532
+ <Toaster message={toastStatus.message} variant={toastStatus.variant } open={toastStatus.open} onClose={() => setToastStatus({open: false})} />
533
+
534
+ }
535
+ { showProfilePicture.showProfile && (
536
+ <ProfilePicture
537
+ userName={showProfilePicture.userName}
538
+ userImageSrc={showProfilePicture.userImageSrc}
539
+ theme={showProfilePicture.theme}
540
+ closeHandler={() => setShowProfilePicture({ showProfile: false })}
541
+ />
542
+ )}
543
+
544
+ {showLoader && <Loader />}
545
+
546
+ {!userloggedIn && !loading && <Authpage theme={theme}
547
+ />}
548
+ </WhatsappSection>
549
+ <style jsx>
550
+ {`
551
+ .logoutModal * {
552
+ margin-top: 20px;
553
+ }
554
+
555
+ @media (max-width: 48rem) {
556
+ .sidebar_header {
557
+ width: 100vw;
558
+ }
559
+ }
560
+ @media (max-width: 48rem) {
561
+ .sidebar .sidebar_header .sliderr {
562
+ width: 100vw;
563
+ }
564
+ .sidebar {
565
+ display: ${isSidebarShow ? "none" : "block"};
566
+ }
567
+ }
568
+ `}
569
+ </style>
570
+ </>
571
+ );
572
+ }
573
+
574
+ export default WhatsappMainBox;
@@ -0,0 +1,13 @@
1
+ const reportWebVitals = onPerfEntry => {
2
+ if (onPerfEntry && onPerfEntry instanceof Function) {
3
+ import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => {
4
+ getCLS(onPerfEntry);
5
+ getFID(onPerfEntry);
6
+ getFCP(onPerfEntry);
7
+ getLCP(onPerfEntry);
8
+ getTTFB(onPerfEntry);
9
+ });
10
+ }
11
+ };
12
+
13
+ export default reportWebVitals;
@@ -0,0 +1,27 @@
1
+ import client from "../utils/chatSdk";
2
+
3
+
4
+ export const markMessagesAsRead = async (data) => {
5
+ try {
6
+ const res = await client.message.putRead({
7
+ timestamp: data.getTime,
8
+ conversationId: data?.conversationId,
9
+ });
10
+ return res;
11
+ } catch (error) {
12
+ console.log(error, "error");
13
+ }
14
+ };
15
+
16
+ export const putIndicateMessageRead = async (messageId, conversationId) => {
17
+ const payload = {
18
+ messageId: messageId,
19
+ conversationId: conversationId
20
+ }
21
+ try {
22
+ const res = await client.message.putIndicateRead(payload);
23
+ return res;
24
+ } catch (error) {
25
+ console.log(error, "error");
26
+ }
27
+ };
@@ -0,0 +1,5 @@
1
+ // jest-dom adds custom jest matchers for asserting on DOM nodes.
2
+ // allows you to do things like:
3
+ // expect(element).toHaveTextContent(/react/i)
4
+ // learn more: https://github.com/testing-library/jest-dom
5
+ import '@testing-library/jest-dom';
@@ -0,0 +1,14 @@
1
+ import ChatSdk from 'test-iso-chat-sdk';
2
+ import { getCookie } from '../lib/session';
3
+ const userToken = getCookie('userToken');
4
+ const token =
5
+ 'SFMyNTY.g3QAAAACZAAEZGF0YXQAAAADbQAAAAlhY2NvdW50SWRtAAAAGDYwYjFlZjcwZmZjZjc1MDAwMWQwNDQwZG0AAAAIa2V5c2V0SWRtAAAAJDJmN2QyMmQ3LWI3NDMtNDcxNC04MzdlLWFmMGIxMjliZDU0Mm0AAAAJcHJvamVjdElkbQAAACRmYzRiZmMwOC0zMjQzLTQyMGYtODg0ZC0xY2UzN2QzZjQ1M2JkAAZzaWduZWRuBgDQbglBgwE.bWfQpMCFERbltvCTtWe6vFo7nSgqP3x9GxdOPHDshTs';
6
+ const client = new ChatSdk({
7
+ baseUrl: 'https://apis.isometrik.io',
8
+ licenseKey: 'lic-IMKw4CVRR6IHZ26+FhU7S+eG2Egi9NIHjMB',
9
+ appSecret:
10
+ 'SFMyNTY.g3QAAAACZAAEZGF0YXQAAAADbQAAAAlhY2NvdW50SWRtAAAAGDYwYjFlZjcwZmZjZjc1MDAwMWQwNDQwZG0AAAAIa2V5c2V0SWRtAAAAJDJmN2QyMmQ3LWI3NDMtNDcxNC04MzdlLWFmMGIxMjliZDU0Mm0AAAAJcHJvamVjdElkbQAAACRmYzRiZmMwOC0zMjQzLTQyMGYtODg0ZC0xY2UzN2QzZjQ1M2JkAAZzaWduZWRuBgDIbglBgwE.iMeGupqXUwr5LqeQmq3dquLG5I3IX9eHjlPfegYY-x4',
11
+ userSecret: token,
12
+ userToken: userToken,
13
+ });
14
+ export default client;
@@ -0,0 +1,57 @@
1
+ export const WhatsappPlaceholderBanner =
2
+ "/icons/assets/ic_placeholder_banner.svg";
3
+ export const APP_NAME = "whatsapp clone";
4
+ export const placeholdeImage = "/icons/placeholder.svg"
5
+ export const ARROW_LOGO = "/icons/arrow_logo.svg"
6
+ export const SHOW_EYE_ICON = "/icons/ic_uil_eye.svg";
7
+ export const HIDE_EYE_ICON = "/icons/ic_uil_eye-slash.svg";
8
+ export const ARROW_LEFT_ICON = "/icons/ic_uil_arrow-left.svg";
9
+ export const SEARCH_ICON = "/icons/ic_uil_search.svg";
10
+ export const LIGHT_MODE = "/icons/light-mode.svg";
11
+ export const USERS = "/icons/users.svg";
12
+ export const STATUS = "/icons/status.svg";
13
+ export const BACKICON = "/icons/back.svg";
14
+ export const DELETEICON = "/icons/delete.svg";
15
+ export const CLOSE_ICON = "/icons/close.svg";
16
+ export const LOCKICON = "/icons/lock.svg";
17
+ export const EDITPENCILICON = "/icons/edit-pencil.svg";
18
+ export const BLOCKICON = "/icons/block.svg";
19
+ export const THUMB_DOWN = "/icons/thumb-down.svg";
20
+ export const FILTER = "/icons/filter.svg";
21
+ export const ATTACH_FILE = "/icons/attach-file.svg";
22
+ export const BELL_ICON = "/icons/bell.svg";
23
+ export const BOTTOM_ARROW = "/icons/bottom-arrow.svg";
24
+ export const MESSAGE = "/icons/message.svg";
25
+ export const ROUND_STAR = "/icons/round-star.svg";
26
+ export const MENU_ICON = "/icons/menu .svg";
27
+ export const SEARCH = "/icons/search.svg";
28
+ export const EMOJI_ICON = "/icons/emoji.svg";
29
+ export const SENDICON = "/icons/send.svg";
30
+ export const RIGHT_ARROW = "/icons/right-arrow.svg";
31
+ export const DISAPEAR_ICON = "/icons/disappear.svg";
32
+ export const CORRECT_ICON = "/icons/right.svg";
33
+ export const CANCEl = "/icons/cancel.svg";
34
+ export const POll = "/icons/poll.svg";
35
+ export const CAMERA = "/icons/camera.svg";
36
+ export const DOCUMENT = "/icons/document.png";
37
+ export const GALLERY = "/icons/gallery.svg";
38
+ export const USER = "/icons/user.svg";
39
+ export const STICKER = "./icons/sticker.svg";
40
+ export const CAMERA_RETAKE = "/icons/retake.png";
41
+ export const Empty_Chat_Placeholder = "/icons/chat empty placeholder.svg";
42
+ export const VOICE = "/icons/voice.png";
43
+ export const CROSS_CAROUSEL = "/icons/crossCarousel.svg";
44
+ export const DOWNLOAD_CAROUSEL = "/icons/downloadCarousel.svg";
45
+ export const EMOJI_FACE_CAROUSEL = "/icons/emojiCarousel.svg";
46
+ export const FORWARD_CAROUSEL = "/icons/forwardCarousel.svg";
47
+ export const GO_TO_MESSAGE_CAROUSEL = "/icons/goToMessageCarousel.svg";
48
+ export const LEFT_ARROW_CAROUSEL = "/icons/leftArrowCarousel.svg";
49
+ export const MENU_CAROUSEL = "/icons/menuCarousel.svg";
50
+ export const STAR_CAROUSEL = "/icons/starCarousel.svg";
51
+ export const LOGIN_BACKGROUND = "/icons/login_background.png";
52
+
53
+ export const CHAT_AUDIO_PLAY = '/icons/chat_audio_play.png';
54
+ export const CHAT_AUDIO_PAUSE = '/icons/chat_audio_pause.png';
55
+ export const CAMERA_SWITCH = '/icons/camera-switch.svg';
56
+ export const AUDIO_PAUSE = '/icons/audio_pause.svg';
57
+ export const AUDIO_PLAY = '/icons/audio_play.svg';