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,265 @@
1
+ import React, { useState } from "react";
2
+ import styled, { css } from "styled-components";
3
+ import PageWrapper from "../common/styled/PageWrapper";
4
+ import InputText from "../formcontrol/InputText";
5
+ import CustomButton from "../formcontrol/CustomButton";
6
+ import { ARROW_LOGO, HIDE_EYE_ICON, LOGIN_BACKGROUND, SHOW_EYE_ICON } from "../../utils/global";
7
+ import ImageComponent from "../ImageComponent";
8
+ import client from "../../utils/chatSdk";
9
+ import { setCookie } from "../../lib/session";
10
+ import { mobile } from "../../utils/media";
11
+ import {
12
+ digitsRegExp,
13
+ minLengthRegExp,
14
+ specialCharRegExp,
15
+ uppercaseRegExp,
16
+ } from "../../lib/validation";
17
+ import SnackBar from "../SnackBar";
18
+ import Toaster from "../../view/component/Toaster/Toaster";
19
+
20
+ const SectionTag = styled.section`
21
+ height: 100vh;
22
+ display: flex;
23
+ justify-content: space-between;
24
+ align-items: center;
25
+ background:url(${LOGIN_BACKGROUND});
26
+ object-fit: contain;
27
+ background-size: cover !important;
28
+ ${mobile(css`
29
+ padding: 1rem;
30
+ `)}
31
+ `;
32
+
33
+ const CardShadowLG = styled.div`
34
+ position: relative;
35
+ display: flex;
36
+ flex-direction: column;
37
+ min-width: 0;
38
+ word-wrap: break-word;
39
+ box-shadow: 0px 3px 6px #161148;
40
+ background:#fff;
41
+ border-radius: 20px;
42
+ max-width: 28rem;
43
+ margin: auto;
44
+
45
+ ${mobile(css`
46
+ border-radius: 10px;
47
+ `)}
48
+ `;
49
+
50
+ const CardBody = styled.div`
51
+ padding: 2rem;
52
+ flex: 1 1 auto;
53
+
54
+ ${mobile(css`
55
+ padding: 1rem;
56
+ `)}
57
+ `;
58
+
59
+ const LogoText = styled.div`
60
+ text-align: center;
61
+ font-size: 24px;
62
+ letter-spacing: 0px;
63
+ color: var(--black);
64
+ text-transform: capitalize;
65
+ opacity: 1;
66
+ `;
67
+ const ErrorText = styled.div`
68
+ text-align: center;
69
+ font-size: 26px;
70
+ letter-spacing: 0px;
71
+ color: red;
72
+ text-transform: capitalize;
73
+ opacity: 1;
74
+ `;
75
+
76
+
77
+ const Visibility = styled.div`
78
+ position: relative;
79
+ `;
80
+
81
+ const ShowHide = styled.span`
82
+ position: absolute;
83
+ top: 10px;
84
+ right: 16px;
85
+ color: #8b8b8b;
86
+ cursor: pointer;
87
+ `;
88
+
89
+ const SignUpRout = styled.div`
90
+ text-align: center;
91
+ letter-spacing: -0.22px;
92
+ color: #F53872;
93
+ padding: 10px 0 0 0;
94
+ cursor: pointer;
95
+ `;
96
+ const ShowErrorText = styled.p`
97
+ text-align: center;
98
+ color: var(--danger);
99
+ `;
100
+
101
+ const ArrowLOGO = styled.div`
102
+ text-align: center;
103
+ `;
104
+
105
+ const Login = (props) => {
106
+ const { setLoginPage, theme } = props;
107
+ const [passVisible, setPassVisible] = useState(false);
108
+ const [error, setError] = useState();
109
+ const [input, setInput] = useState({
110
+ email: "",
111
+ password: "",
112
+ });
113
+ const [toastStatus, setToastStatus] = useState({open: false, message: '', variant: ''});
114
+
115
+ // Error handlers for signup form
116
+ const [errors, setErrors] = useState({
117
+ email: "",
118
+ password: "",
119
+ });
120
+
121
+ const validate = (name, value) => {
122
+ switch (name) {
123
+ case "email":
124
+ if (!value) {
125
+ return "email is required";
126
+ } else if (
127
+ !value.match(/^\w+([.-]?\w+)*@\w+([.-]?\w+)*(\.\w{2,3})+$/)
128
+ ) {
129
+ return "Enter a valid email address";
130
+ } else {
131
+ return "";
132
+ }
133
+ case "password":
134
+ if (!value) {
135
+ return "Please enter your password";
136
+ } else if (!uppercaseRegExp.test(value)) {
137
+ return "Password should contain atleast one uppercase";
138
+ } else if (!digitsRegExp.test(value)) {
139
+ return "Password should contain atleast one digit";
140
+ } else if (!specialCharRegExp.test(value)) {
141
+ return "Password should contain one special character";
142
+ } else if (!minLengthRegExp.test(value)) {
143
+ return "Password length should be more than 8 characters";
144
+ } else {
145
+ return "";
146
+ }
147
+
148
+ default:
149
+ return "";
150
+ }
151
+ };
152
+
153
+ const handelLogin = (e) => {
154
+ e.preventDefault();
155
+
156
+ const validationErrors = {};
157
+
158
+ Object.keys(input).forEach((name) => {
159
+ const error = validate(name, input[name]);
160
+ if (error && error.length > 0) {
161
+ validationErrors[name] = error;
162
+ }
163
+ });
164
+
165
+ if (Object.keys(validationErrors).length > 0) {
166
+ setErrors(validationErrors);
167
+ return;
168
+ }
169
+
170
+ const body = {
171
+ userIdentifier: input?.email,
172
+ password: input?.password,
173
+ };
174
+
175
+ client.user
176
+ .postUserAuthenticate(body)
177
+ .then((res) => {
178
+ setToastStatus({open: true, variant:"success", message: res.msg });
179
+ setCookie("userToken", res?.userToken);
180
+ setCookie("userId", res?.userId);
181
+ window.location.href = "/";
182
+ })
183
+ // .catch(console.log("err"));
184
+ .catch((error) => {
185
+ console.log({ error });
186
+ setToastStatus({open: true, variant:"error", message: error?.message });
187
+ setError({ error }?.error?.errorMsg || { error }?.error?.message);
188
+ });
189
+ };
190
+
191
+ const handleChange = (e) => {
192
+ setInput({ ...input, [e.target.name]: e.target.value });
193
+ setErrors({
194
+ ...errors,
195
+ [e.target.name]: validate(e.target.name, e.target.value),
196
+ });
197
+ setError();
198
+ };
199
+
200
+ const snackbarClose = () => {
201
+ setError();
202
+ };
203
+
204
+ return (
205
+ <>
206
+ {/* {error && <SnackBar errorMessage={error} snackbarClose={snackbarClose} />} */}
207
+ <SectionTag>
208
+ <PageWrapper>
209
+ <CardShadowLG>
210
+ <CardBody>
211
+ <ArrowLOGO>
212
+ <ImageComponent
213
+ src={ARROW_LOGO}
214
+ />
215
+ </ArrowLOGO>
216
+ <LogoText>ISOMETRIK CHAT</LogoText>
217
+ <ShowErrorText>{error}</ShowErrorText>
218
+ <InputText
219
+ name="email"
220
+ type="email"
221
+ placeholder="Enter your email"
222
+ value={input.email}
223
+ error={errors?.email}
224
+ onChange={handleChange}
225
+ />
226
+
227
+ <Visibility>
228
+ <InputText
229
+ name="password"
230
+ type={!passVisible ? "password" : "text"}
231
+ placeholder="Enter your password"
232
+ value={input?.password}
233
+ error={errors?.password}
234
+ onChange={handleChange}
235
+ />
236
+ <div onClick={() => setPassVisible(!passVisible)}>
237
+ <ShowHide>
238
+ <ImageComponent
239
+ src={!passVisible ? HIDE_EYE_ICON : SHOW_EYE_ICON}
240
+ height="22px"
241
+ width="22px"
242
+ />
243
+ </ShowHide>
244
+ </div>
245
+ </Visibility>
246
+
247
+ <div onClick={handelLogin}>
248
+ <CustomButton title={"Log In"} />
249
+ </div>
250
+
251
+ <SignUpRout onClick={() => setLoginPage(false)}>
252
+ Sign Up
253
+ </SignUpRout>
254
+ </CardBody>
255
+ </CardShadowLG>
256
+ </PageWrapper>
257
+ </SectionTag>
258
+ {
259
+ <Toaster message={toastStatus.message} variant={toastStatus.variant} open={toastStatus.open} onClose={() => setToastStatus({open: false})} theme={theme} />
260
+ }
261
+ </>
262
+ );
263
+ };
264
+
265
+ export default Login;
@@ -0,0 +1,322 @@
1
+ import React, { useState } from "react";
2
+ import styled, { css } from "styled-components";
3
+ import PageWrapper from "../common/styled/PageWrapper";
4
+ import InputText from "../formcontrol/InputText";
5
+ import CustomButton from "../formcontrol/CustomButton";
6
+ import ImageComponent from "../ImageComponent";
7
+ import { ARROW_LOGO, HIDE_EYE_ICON, LOGIN_BACKGROUND, SHOW_EYE_ICON } from "../../utils/global";
8
+ import client from "../../utils/chatSdk";
9
+ import { setCookie } from "../../lib/session";
10
+ import {
11
+ digitsRegExp,
12
+ minLengthRegExp,
13
+ specialCharRegExp,
14
+ uppercaseRegExp,
15
+ } from "../../lib/validation";
16
+ import { mobile } from "../../utils/media";
17
+ import SnackBar from "../SnackBar";
18
+ import { checkLetterUppercase, userProfilePicturePlaceholder } from "../../lib/helpers";
19
+ import Toaster from "../../view/component/Toaster/Toaster";
20
+
21
+ const SectionTag = styled.form`
22
+ height: 100vh;
23
+ display: flex;
24
+ justify-content: space-between;
25
+ align-items: center;
26
+ background:url(${LOGIN_BACKGROUND});
27
+ object-fit: contain;
28
+ background-size: cover !important;
29
+ ${mobile(css`
30
+ padding:1rem;
31
+ `)}
32
+ `;
33
+
34
+ const CardShadowLG = styled.div`
35
+ position: relative;
36
+ display: flex;
37
+ flex-direction: column;
38
+ min-width: 0;
39
+ background:#fff;
40
+ word-wrap: break-word;
41
+ box-shadow: 0px 3px 6px #161148;
42
+ border-radius: 20px;
43
+ max-width: 28rem;
44
+ margin: auto;
45
+
46
+ ${mobile(css`
47
+ border-radius: 20px;
48
+ `)}
49
+ `;
50
+
51
+ const CardBody = styled.div`
52
+ padding: 2rem;
53
+ flex: 1 1 auto;
54
+
55
+ ${mobile(css`
56
+ padding: 1rem;
57
+ `)}
58
+ `;
59
+
60
+ const LogoText = styled.div`
61
+ text-align: center;
62
+ font-size: 24px;
63
+ letter-spacing: 0px;
64
+ color:var(--black);
65
+ font-family: LogoText;
66
+ text-transform: capitalize;
67
+ opacity: 1;
68
+ `;
69
+
70
+ const Visibility = styled.div`
71
+ position: relative;
72
+ `;
73
+
74
+ const ShowHide = styled.span`
75
+ position: absolute;
76
+ top: 10px;
77
+ right: 16px;
78
+ color: #8b8b8b;
79
+ cursor: pointer;
80
+ `;
81
+
82
+ const SignUpRout = styled.div`
83
+ text-align: center;
84
+ letter-spacing: -0.22px;
85
+ color: #F53872;
86
+ padding: 10px 0 0 0;
87
+ cursor: pointer;
88
+ `;
89
+
90
+ const ErrorText = styled.div`
91
+ text-align: center;
92
+ letter-spacing: -0.22px;
93
+ color:red;
94
+ padding: 10px 0 0 0;
95
+ `;
96
+ const ShowErrorText = styled.p`
97
+ text-align: center;
98
+ color: var(--danger);
99
+ `;
100
+ const ArrowLOGO = styled.div`
101
+ text-align: center;
102
+ `;
103
+
104
+ const SignUp = (props) => {
105
+ const { setLoginPage, theme } = props;
106
+ const [passVisible, setPassVisible] = useState(false);
107
+ const [secondPassVisible, setSecondPassVisible] = useState(false);
108
+ const [error, setError] = useState();
109
+ const [input, setInput] = useState({
110
+ fname: "",
111
+ email: "",
112
+ password: "",
113
+ confirmPassword: "",
114
+ });
115
+ const [toastStatus, setToastStatus] = useState({open: false, message: '', variant: ''});
116
+
117
+ // Error handlers for signup form
118
+ const [errors, setErrors] = useState({
119
+ fname: "",
120
+ email: "",
121
+ password: "",
122
+ confirmPassword: "",
123
+ });
124
+
125
+ const validate = (name, value) => {
126
+ switch (name) {
127
+ case "fname":
128
+ if (!value || value.trim() === "") {
129
+ return "User name is required";
130
+ } else if (!value.match(/^[A-Z ]{3,50}$/i)) {
131
+ return "User name should not contain any special characters";
132
+ } else if (!checkLetterUppercase(value) ) {
133
+ return "First letter should be capital in name";
134
+ }
135
+ else {
136
+ return "";
137
+ }
138
+ case "email":
139
+ if (!value) {
140
+ return "Email is required";
141
+ } else if (
142
+ !value.match(/^\w+([.-]?\w+)*@\w+([.-]?\w+)*(\.\w{2,3})+$/)
143
+ ) {
144
+ return "Enter a valid email address";
145
+ } else {
146
+ return "";
147
+ }
148
+ case "Password":
149
+ if (!value) {
150
+ return "Please enter your password";
151
+ } else if (!uppercaseRegExp.test(value)) {
152
+ return "Password should contain atleast one uppercase";
153
+ } else if (!digitsRegExp.test(value)) {
154
+ return "Password should contain atleast one digit";
155
+ } else if (!specialCharRegExp.test(value)) {
156
+ return "Password should contain one special character";
157
+ } else if (!minLengthRegExp.test(value)) {
158
+ return "Password length should be more than 8 characters";
159
+ } else {
160
+ return "";
161
+ }
162
+ case "confirmPassword":
163
+ if (!value) {
164
+ return "Confirm password is required";
165
+ } else if (value !== input.password) {
166
+ return "Confirm password did not match";
167
+ } else {
168
+ return "";
169
+ }
170
+ default:
171
+ return "";
172
+ }
173
+ };
174
+
175
+ const registerNewUser = (e) => {
176
+ e.preventDefault();
177
+
178
+ const validationErrors = {};
179
+
180
+ Object.keys(input).forEach((name) => {
181
+ const error = validate(name, input[name]);
182
+ if (error && error.length > 0) {
183
+ validationErrors[name] = error;
184
+ }
185
+ });
186
+
187
+ if (Object.keys(validationErrors).length > 0) {
188
+ setErrors(validationErrors);
189
+ return;
190
+ }
191
+
192
+ const body = {
193
+ userProfileImageUrl: userProfilePicturePlaceholder,
194
+ userName: input.fname,
195
+ userIdentifier: input.email,
196
+ password: input.password,
197
+ confirmPassword: input.confirmPassword,
198
+ metaData: {
199
+ country: "IN",
200
+ },
201
+ };
202
+ client.user
203
+ .postUser(body)
204
+ .then((res) => {
205
+ setCookie("userToken", res?.userToken);
206
+ setCookie("userId", res?.userId);
207
+ if(res){
208
+ // setLoginPage(true);
209
+ setToastStatus({open: true, variant:"success", message: res.msg });
210
+ window.location.href = "/";
211
+ }
212
+ })
213
+ .catch((error) => {
214
+ console.error( 'error', { error }, error);
215
+ setToastStatus({open: true, variant:"error", message: error?.message });
216
+ setError({ error }?.error?.errorMsg || { error }?.error?.message);
217
+ });
218
+ console.error({ error }, error);
219
+ };
220
+
221
+ const handleChange = (e) => {
222
+ setInput({ ...input, [e.target.name]: e.target.value });
223
+ setError();
224
+ setErrors({
225
+ ...errors,
226
+ [e.target.name]: validate(e.target.name, e.target.value),
227
+ });
228
+ };
229
+
230
+ const snackbarClose = () => {
231
+ setError();
232
+ };
233
+
234
+ return (
235
+ <React.Fragment>
236
+ {/* {error && <SnackBar errorMessage={error} snackbarClose={snackbarClose} />} */}
237
+ <SectionTag>
238
+ <PageWrapper>
239
+ <CardShadowLG>
240
+ <CardBody>
241
+ <ArrowLOGO>
242
+ <ImageComponent
243
+ src={ARROW_LOGO}
244
+ />
245
+ </ArrowLOGO>
246
+ <LogoText>ISOMETRIK CHAT</LogoText>
247
+ <ShowErrorText>{error}</ShowErrorText>
248
+ <InputText
249
+ name="fname"
250
+ type="text"
251
+ placeholder="Enter your name"
252
+ value={input?.fname}
253
+ onChange={handleChange}
254
+ error={errors?.fname}
255
+ />
256
+
257
+ <InputText
258
+ name="email"
259
+ type="email"
260
+ placeholder="Enter your email"
261
+ value={input?.email}
262
+ error={errors?.email}
263
+ onChange={handleChange}
264
+ />
265
+
266
+ <Visibility>
267
+ <InputText
268
+ name="password"
269
+ type={!passVisible ? "password" : "text"}
270
+ placeholder="Enter your password"
271
+ value={input?.password}
272
+ error={errors?.password}
273
+ onChange={handleChange}
274
+ />
275
+ <div onClick={() => setPassVisible(!passVisible)}>
276
+ <ShowHide>
277
+ <ImageComponent
278
+ src={!passVisible ? HIDE_EYE_ICON : SHOW_EYE_ICON}
279
+ height="22px"
280
+ width="22px"
281
+ />
282
+ </ShowHide>
283
+ </div>
284
+ </Visibility>
285
+
286
+ <Visibility>
287
+ <InputText
288
+ name="confirmPassword"
289
+ type={!secondPassVisible ? "password" : "text"}
290
+ placeholder="Enter your confirm password"
291
+ value={input?.confirmPassword}
292
+ error={errors?.confirmPassword}
293
+ onChange={handleChange}
294
+ />
295
+ <div onClick={() => setSecondPassVisible(!secondPassVisible)}>
296
+ <ShowHide>
297
+ <ImageComponent
298
+ src={!secondPassVisible ? HIDE_EYE_ICON : SHOW_EYE_ICON}
299
+ height="22px"
300
+ width="22px"
301
+ />
302
+ </ShowHide>
303
+ </div>
304
+ </Visibility>
305
+
306
+ <div onClick={registerNewUser}>
307
+ <CustomButton title={"Sign Up"} />
308
+ </div>
309
+ <SignUpRout onClick={() => setLoginPage(true)}>Log In</SignUpRout>
310
+ </CardBody>
311
+ </CardShadowLG>
312
+ </PageWrapper>
313
+ </SectionTag>
314
+
315
+ {
316
+ <Toaster message={toastStatus.message} variant={toastStatus.variant} open={toastStatus.open} onClose={() => setToastStatus({open: false})} theme={theme} />
317
+ }
318
+ </React.Fragment>
319
+ );
320
+ };
321
+
322
+ export default SignUp;
@@ -0,0 +1,42 @@
1
+ import React from 'react'
2
+ import { CANCEl } from '../utils/global'
3
+ import ImageComponent from './ImageComponent'
4
+ import styled, { css } from "styled-components";
5
+ import { mobile } from "../utils/media";
6
+
7
+ const ModalContainer = styled.div`
8
+ top: 20px;
9
+ display: flex;
10
+ align-items: center;
11
+ justify-content: space-between;
12
+ position: absolute;
13
+ border: 1px solid lightpink;
14
+ background: antiquewhite;
15
+ border-radius: 5px;
16
+ padding: 0px 20px;
17
+ display: flex;
18
+ transition: all 1s ease-in-out !important;
19
+
20
+ ${mobile(css`
21
+ width: 70%;
22
+ right: 20px;
23
+ `)}
24
+ `;
25
+
26
+ const ModalMessage = styled.div`
27
+ padding: 15px;
28
+ color: brown;
29
+ `;
30
+
31
+ export default function SnackBar(props) {
32
+ const { snackbarClose } = props;
33
+ return (
34
+ <ModalContainer>
35
+ <ModalMessage>{props?.errorMessage}</ModalMessage>
36
+ <div className="icon pointer">
37
+ <ImageComponent src={CANCEl} onClick={() => snackbarClose()} />
38
+ </div>
39
+ </ModalContainer>
40
+ );
41
+ }
42
+
@@ -0,0 +1,23 @@
1
+ import { useState, useEffect } from "react";
2
+
3
+ export const useDetectOutsideClick = (el, initialState) => {
4
+ const [isActive, setIsActive] = useState(initialState);
5
+
6
+ useEffect(() => {
7
+ const onClick = (e) => {
8
+ if (el.current !== null && !el.current.contains(e.target)) {
9
+ setIsActive(!isActive);
10
+ }
11
+ };
12
+
13
+ if (isActive) {
14
+ window.addEventListener("click", onClick);
15
+ }
16
+
17
+ return () => {
18
+ window.removeEventListener("click", onClick);
19
+ };
20
+ }, [isActive, el]);
21
+
22
+ return [isActive, setIsActive];
23
+ };
@@ -0,0 +1,25 @@
1
+ import styled, { css } from "styled-components";
2
+ import { mobile, tablet } from "../../../utils/media";
3
+
4
+ const PageWrapper = styled.div`
5
+ max-width: 100%;
6
+ position: relative;
7
+ margin-right: auto;
8
+ margin-left: auto;
9
+ padding-right: 0.5rem;
10
+ padding-left: 0.5rem;
11
+
12
+ @media only screen and (min-width: 75em) {
13
+ width: 72rem;
14
+ }
15
+
16
+ ${tablet(css`
17
+ width: 61rem;
18
+ `)}
19
+ ${mobile(css`
20
+ width: 70rem;
21
+ padding: 0.6rem;
22
+ `)}
23
+ `;
24
+
25
+ export default PageWrapper;
@@ -0,0 +1,38 @@
1
+ import React from "react";
2
+ import styled from "styled-components";
3
+
4
+ const MYButtons = styled.div`
5
+ margin: 10px 0;
6
+ `;
7
+
8
+ const CustomButtonLink = styled.a`
9
+ background: #F53872;
10
+ color: #fff;
11
+ border-radius: 10px;
12
+ font-size: 16px;
13
+ line-height: 22.4px;
14
+ padding: 10px 32px;
15
+ white-space: nowrap;
16
+ font-weight: 500;
17
+ text-decoration: none;
18
+ display: inline-block;
19
+ border: none;
20
+ transition: 0.125s;
21
+ text-align: center;
22
+ width: 100%;
23
+ cursor: pointer;
24
+
25
+ &:not(.disable):hover {
26
+ color: #fff;
27
+ }
28
+ `;
29
+
30
+ const CustomButton = (props) => {
31
+ return (
32
+ <MYButtons>
33
+ <CustomButtonLink href={props.url}>{props.title}</CustomButtonLink>
34
+ </MYButtons>
35
+ );
36
+ };
37
+
38
+ export default React.forwardRef(CustomButton);