favesalon-embed 1.0.4 → 1.0.6

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 (183) hide show
  1. package/dist/custom-elements/index.d.ts +42 -0
  2. package/dist/{cjs/_commonjsHelpers-5cfcba41.js → favesalon-embed/_commonjsHelpers-a4f66ccd.js} +14 -6
  3. package/dist/favesalon-embed/activate-form.entry.js +70 -0
  4. package/dist/favesalon-embed/app-globals-74127f4b.js +7 -0
  5. package/dist/favesalon-embed/app-globals-f954a22f.js +7 -0
  6. package/dist/favesalon-embed/change-password-form.entry.js +81 -0
  7. package/dist/favesalon-embed/chat-box.entry.js +55 -0
  8. package/dist/{esm → favesalon-embed}/chat-button.entry.js +36 -13
  9. package/dist/favesalon-embed/chat-form.entry.js +39 -0
  10. package/dist/favesalon-embed/chat-messages.entry.js +71 -0
  11. package/dist/favesalon-embed/chat-rooms.entry.js +111 -0
  12. package/dist/favesalon-embed/css-shim-b7d3d95f.js +4 -0
  13. package/dist/favesalon-embed/dom-64053c71.js +73 -0
  14. package/dist/favesalon-embed/favesalon-embed.css +114 -1
  15. package/dist/favesalon-embed/favesalon-embed.esm.js +148 -1
  16. package/dist/{esm → favesalon-embed}/google-map.entry.js +1 -1
  17. package/dist/{esm/index-a1c7583c.js → favesalon-embed/index-00b83e1c.js} +425 -15
  18. package/dist/favesalon-embed/index-888e99e3.js +3371 -0
  19. package/dist/favesalon-embed/index-a229b3b5.js +3371 -0
  20. package/dist/favesalon-embed/index.esm.js +1 -0
  21. package/dist/{esm/chat-box_5.entry.js → favesalon-embed/lodash-d5526b38.js} +27 -243
  22. package/dist/favesalon-embed/login-form.entry.js +67 -0
  23. package/dist/{cjs/chat-button.cjs.entry.js → favesalon-embed/notify-sounds.entry.js} +20 -44
  24. package/dist/favesalon-embed/register-form.entry.js +88 -0
  25. package/dist/favesalon-embed/relativeTime-268e64b0.js +7 -0
  26. package/dist/favesalon-embed/reset-password-form.entry.js +47 -0
  27. package/dist/{esm → favesalon-embed}/salon-booking-modal.entry.js +1 -1
  28. package/dist/{esm → favesalon-embed}/salon-booking.entry.js +4 -4
  29. package/dist/{esm → favesalon-embed}/salon-gift-card-modal.entry.js +1 -1
  30. package/dist/{esm → favesalon-embed}/salon-gift-card.entry.js +4 -4
  31. package/dist/{esm → favesalon-embed}/salon-info.entry.js +3 -3
  32. package/dist/{esm → favesalon-embed}/salon-latest-reviews.entry.js +22 -6
  33. package/dist/{collection/components/salon-latest-styles/index.js → favesalon-embed/salon-latest-styles.entry.js} +27 -105
  34. package/dist/{collection/components/salon-locations/index.js → favesalon-embed/salon-locations.entry.js} +15 -95
  35. package/dist/{esm → favesalon-embed}/salon-lookbook.entry.js +18 -6
  36. package/dist/{esm → favesalon-embed}/salon-ranking.entry.js +1 -1
  37. package/dist/{esm → favesalon-embed}/salon-reviews.entry.js +20 -6
  38. package/dist/{collection/components/salon-schedules/index.js → favesalon-embed/salon-schedules.entry.js} +14 -95
  39. package/dist/{esm → favesalon-embed}/salon-services.entry.js +25 -13
  40. package/dist/{esm → favesalon-embed}/salon-stylists.entry.js +3 -3
  41. package/dist/{esm/services-257442e2.js → favesalon-embed/services-5a4c43a6.js} +2608 -188
  42. package/dist/{cjs/services-d1bdf299.js → favesalon-embed/services-d71be591.js} +2616 -191
  43. package/dist/favesalon-embed/shadow-css-98135883.js +387 -0
  44. package/dist/{esm → favesalon-embed}/style-detail.entry.js +29 -11
  45. package/dist/favesalon-embed/user-avatar.entry.js +52 -0
  46. package/dist/favesalon-embed/user-form.entry.js +44 -0
  47. package/dist/{collection/utils/utils.js → favesalon-embed/utils-fd30fb29.js} +14 -5
  48. package/dist/types/components/activate-form/activate-form.d.ts +12 -0
  49. package/dist/types/components/activate-form/test/activate-form.spec.d.ts +1 -0
  50. package/dist/types/components/change-password-form/change-password-form.d.ts +12 -0
  51. package/dist/types/components/chat-box/index.d.ts +1 -0
  52. package/dist/types/components/chat-button/index.d.ts +6 -2
  53. package/dist/types/components/chat-button/notify-sounds.d.ts +5 -0
  54. package/dist/types/components/chat-rooms/index.d.ts +6 -0
  55. package/dist/types/components/login-form/login-form.d.ts +10 -0
  56. package/dist/types/components/register-form/register-form.d.ts +13 -0
  57. package/dist/types/components/reset-password-form/reset-password-form.d.ts +9 -0
  58. package/dist/types/components/user-form/user-form.d.ts +7 -0
  59. package/dist/types/components.d.ts +127 -2
  60. package/dist/types/services/services.d.ts +17 -0
  61. package/dist/types/types/chat.d.ts +1 -0
  62. package/dist/types/types/user.d.ts +16 -0
  63. package/dist/types/utils/utils.d.ts +1 -0
  64. package/dist/types/utils/utils.spec.d.ts +1 -0
  65. package/package.json +1 -1
  66. package/dist/cjs/chat-box_5.cjs.entry.js +0 -17439
  67. package/dist/cjs/colors-38421769.js +0 -69
  68. package/dist/cjs/favesalon-embed.cjs.js +0 -23
  69. package/dist/cjs/google-map.cjs.entry.js +0 -52
  70. package/dist/cjs/index-7f190886.js +0 -4396
  71. package/dist/cjs/index-dd8176c4.js +0 -1531
  72. package/dist/cjs/index.cjs.js +0 -2
  73. package/dist/cjs/loader.cjs.js +0 -22
  74. package/dist/cjs/relativeTime-3721080d.js +0 -9
  75. package/dist/cjs/salon-booking-modal.cjs.entry.js +0 -30
  76. package/dist/cjs/salon-booking.cjs.entry.js +0 -51
  77. package/dist/cjs/salon-gift-card-modal.cjs.entry.js +0 -29
  78. package/dist/cjs/salon-gift-card.cjs.entry.js +0 -51
  79. package/dist/cjs/salon-info.cjs.entry.js +0 -33
  80. package/dist/cjs/salon-latest-reviews.cjs.entry.js +0 -97
  81. package/dist/cjs/salon-latest-styles_3.cjs.entry.js +0 -241
  82. package/dist/cjs/salon-lookbook.cjs.entry.js +0 -222
  83. package/dist/cjs/salon-ranking.cjs.entry.js +0 -60
  84. package/dist/cjs/salon-reviews.cjs.entry.js +0 -193
  85. package/dist/cjs/salon-services.cjs.entry.js +0 -81
  86. package/dist/cjs/salon-stylists.cjs.entry.js +0 -118
  87. package/dist/cjs/style-detail.cjs.entry.js +0 -312
  88. package/dist/cjs/utils-c5a33b3c.js +0 -23
  89. package/dist/collection/collection-manifest.json +0 -33
  90. package/dist/collection/components/chat-box/index.css +0 -105
  91. package/dist/collection/components/chat-box/index.js +0 -138
  92. package/dist/collection/components/chat-button/index.css +0 -101
  93. package/dist/collection/components/chat-button/index.js +0 -155
  94. package/dist/collection/components/chat-form/index.css +0 -40
  95. package/dist/collection/components/chat-form/index.js +0 -79
  96. package/dist/collection/components/chat-messages/index.css +0 -48
  97. package/dist/collection/components/chat-messages/index.js +0 -142
  98. package/dist/collection/components/chat-rooms/index.css +0 -102
  99. package/dist/collection/components/chat-rooms/index.js +0 -157
  100. package/dist/collection/components/google-map/assets/map--placeholder.jpeg +0 -0
  101. package/dist/collection/components/google-map/index.css +0 -5
  102. package/dist/collection/components/google-map/index.js +0 -90
  103. package/dist/collection/components/salon-booking/index.css +0 -30
  104. package/dist/collection/components/salon-booking/index.js +0 -126
  105. package/dist/collection/components/salon-booking/salon-booking-modal.js +0 -92
  106. package/dist/collection/components/salon-gift-card/index.css +0 -30
  107. package/dist/collection/components/salon-gift-card/index.js +0 -126
  108. package/dist/collection/components/salon-gift-card/salon-gift-card-modal.js +0 -73
  109. package/dist/collection/components/salon-info/index.css +0 -1
  110. package/dist/collection/components/salon-info/index.js +0 -77
  111. package/dist/collection/components/salon-latest-reviews/index.css +0 -11
  112. package/dist/collection/components/salon-latest-reviews/index.js +0 -163
  113. package/dist/collection/components/salon-latest-styles/index.css +0 -12
  114. package/dist/collection/components/salon-locations/index.css +0 -24
  115. package/dist/collection/components/salon-lookbook/index.css +0 -15
  116. package/dist/collection/components/salon-lookbook/index.js +0 -368
  117. package/dist/collection/components/salon-ranking/index.css +0 -3
  118. package/dist/collection/components/salon-ranking/index.js +0 -117
  119. package/dist/collection/components/salon-reviews/index.css +0 -18
  120. package/dist/collection/components/salon-reviews/index.js +0 -249
  121. package/dist/collection/components/salon-schedules/index.css +0 -18
  122. package/dist/collection/components/salon-services/index.css +0 -1
  123. package/dist/collection/components/salon-services/index.js +0 -146
  124. package/dist/collection/components/salon-stylists/index.css +0 -43
  125. package/dist/collection/components/salon-stylists/index.js +0 -184
  126. package/dist/collection/components/style-detail/index.css +0 -76
  127. package/dist/collection/components/style-detail/index.js +0 -386
  128. package/dist/collection/components/user-avatar/index.css +0 -0
  129. package/dist/collection/components/user-avatar/index.js +0 -159
  130. package/dist/collection/constants/colors.js +0 -65
  131. package/dist/collection/global/global.js +0 -0
  132. package/dist/collection/mocks/users.js +0 -10
  133. package/dist/collection/services/services.js +0 -295
  134. package/dist/collection/types/chat.js +0 -23
  135. package/dist/collection/types/common.js +0 -11
  136. package/dist/collection/types/review.js +0 -39
  137. package/dist/collection/types/salon.js +0 -58
  138. package/dist/collection/types/service.js +0 -24
  139. package/dist/collection/types/style.js +0 -128
  140. package/dist/collection/types/stylist.js +0 -30
  141. package/dist/collection/types/user.js +0 -10
  142. package/dist/custom-elements/index.js +0 -44974
  143. package/dist/esm/_commonjsHelpers-66ac50f5.js +0 -32
  144. package/dist/esm/favesalon-embed.js +0 -18
  145. package/dist/esm/index-0494771f.js +0 -1504
  146. package/dist/esm/index.js +0 -1
  147. package/dist/esm/loader.js +0 -18
  148. package/dist/esm/polyfills/core-js.js +0 -11
  149. package/dist/esm/polyfills/css-shim.js +0 -1
  150. package/dist/esm/polyfills/dom.js +0 -79
  151. package/dist/esm/polyfills/es5-html-element.js +0 -1
  152. package/dist/esm/polyfills/index.js +0 -34
  153. package/dist/esm/polyfills/system.js +0 -6
  154. package/dist/esm/relativeTime-baa50aa2.js +0 -7
  155. package/dist/esm/salon-latest-styles_3.entry.js +0 -235
  156. package/dist/esm/utils-e97485e0.js +0 -19
  157. package/dist/favesalon-embed/p-05a1c88a.entry.js +0 -1
  158. package/dist/favesalon-embed/p-0acf0447.entry.js +0 -1
  159. package/dist/favesalon-embed/p-0bc4f624.js +0 -1
  160. package/dist/favesalon-embed/p-1af1515f.entry.js +0 -1
  161. package/dist/favesalon-embed/p-1cba5fc9.entry.js +0 -1
  162. package/dist/favesalon-embed/p-39a4ef15.entry.js +0 -1
  163. package/dist/favesalon-embed/p-3e2cb05b.entry.js +0 -1
  164. package/dist/favesalon-embed/p-47e646f8.js +0 -1
  165. package/dist/favesalon-embed/p-487b311f.entry.js +0 -1
  166. package/dist/favesalon-embed/p-55387c2f.entry.js +0 -1
  167. package/dist/favesalon-embed/p-566f05b4.entry.js +0 -1
  168. package/dist/favesalon-embed/p-862a0de0.entry.js +0 -1
  169. package/dist/favesalon-embed/p-9fe0cbeb.js +0 -2
  170. package/dist/favesalon-embed/p-a33331cc.js +0 -1
  171. package/dist/favesalon-embed/p-aeeb7b5f.entry.js +0 -1
  172. package/dist/favesalon-embed/p-b08e5b54.js +0 -6
  173. package/dist/favesalon-embed/p-b5cca5fc.entry.js +0 -1
  174. package/dist/favesalon-embed/p-c7fb7af5.js +0 -1580
  175. package/dist/favesalon-embed/p-ccab56d8.js +0 -1
  176. package/dist/favesalon-embed/p-d6e13053.entry.js +0 -1
  177. package/dist/favesalon-embed/p-dee42d34.entry.js +0 -1
  178. package/dist/favesalon-embed/p-e661ca1d.entry.js +0 -1
  179. package/dist/favesalon-embed/p-eeceab9c.entry.js +0 -1
  180. package/dist/index.cjs.js +0 -1
  181. package/dist/index.js +0 -1
  182. /package/dist/{esm → favesalon-embed}/colors-ea36347a.js +0 -0
  183. /package/dist/{collection/index.js → types/components/activate-form/test/activate-form.e2e.d.ts} +0 -0
@@ -2,6 +2,18 @@
2
2
 
3
3
  import type { Components, JSX } from "../types/components";
4
4
 
5
+ interface ActivateForm extends Components.ActivateForm, HTMLElement {}
6
+ export const ActivateForm: {
7
+ prototype: ActivateForm;
8
+ new (): ActivateForm;
9
+ };
10
+
11
+ interface ChangePasswordForm extends Components.ChangePasswordForm, HTMLElement {}
12
+ export const ChangePasswordForm: {
13
+ prototype: ChangePasswordForm;
14
+ new (): ChangePasswordForm;
15
+ };
16
+
5
17
  interface ChatBox extends Components.ChatBox, HTMLElement {}
6
18
  export const ChatBox: {
7
19
  prototype: ChatBox;
@@ -38,6 +50,30 @@ export const GoogleMap: {
38
50
  new (): GoogleMap;
39
51
  };
40
52
 
53
+ interface LoginForm extends Components.LoginForm, HTMLElement {}
54
+ export const LoginForm: {
55
+ prototype: LoginForm;
56
+ new (): LoginForm;
57
+ };
58
+
59
+ interface NotifySounds extends Components.NotifySounds, HTMLElement {}
60
+ export const NotifySounds: {
61
+ prototype: NotifySounds;
62
+ new (): NotifySounds;
63
+ };
64
+
65
+ interface RegisterForm extends Components.RegisterForm, HTMLElement {}
66
+ export const RegisterForm: {
67
+ prototype: RegisterForm;
68
+ new (): RegisterForm;
69
+ };
70
+
71
+ interface ResetPasswordForm extends Components.ResetPasswordForm, HTMLElement {}
72
+ export const ResetPasswordForm: {
73
+ prototype: ResetPasswordForm;
74
+ new (): ResetPasswordForm;
75
+ };
76
+
41
77
  interface SalonBooking extends Components.SalonBooking, HTMLElement {}
42
78
  export const SalonBooking: {
43
79
  prototype: SalonBooking;
@@ -134,6 +170,12 @@ export const UserAvatar: {
134
170
  new (): UserAvatar;
135
171
  };
136
172
 
173
+ interface UserForm extends Components.UserForm, HTMLElement {}
174
+ export const UserForm: {
175
+ prototype: UserForm;
176
+ new (): UserForm;
177
+ };
178
+
137
179
  /**
138
180
  * Utility to define all custom elements within this package using the tag name provided in the component's source.
139
181
  * When defining each custom element, it will also check it's safe to define by:
@@ -1,17 +1,27 @@
1
- 'use strict';
2
-
3
1
  var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
4
2
 
3
+ function getDefaultExportFromCjs (x) {
4
+ return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
5
+ }
6
+
5
7
  function createCommonjsModule(fn, basedir, module) {
6
8
  return module = {
7
9
  path: basedir,
8
10
  exports: {},
9
11
  require: function (path, base) {
10
- return commonjsRequire();
12
+ return commonjsRequire(path, (base === undefined || base === null) ? module.path : base);
11
13
  }
12
14
  }, fn(module, module.exports), module.exports;
13
15
  }
14
16
 
17
+ function getDefaultExportFromNamespaceIfPresent (n) {
18
+ return n && Object.prototype.hasOwnProperty.call(n, 'default') ? n['default'] : n;
19
+ }
20
+
21
+ function getDefaultExportFromNamespaceIfNotNamed (n) {
22
+ return n && Object.prototype.hasOwnProperty.call(n, 'default') && Object.keys(n).length === 1 ? n['default'] : n;
23
+ }
24
+
15
25
  function getAugmentedNamespace(n) {
16
26
  if (n.__esModule) return n;
17
27
  var a = Object.defineProperty({}, '__esModule', {value: true});
@@ -31,6 +41,4 @@ function commonjsRequire () {
31
41
  throw new Error('Dynamic requires are not currently supported by @rollup/plugin-commonjs');
32
42
  }
33
43
 
34
- exports.commonjsGlobal = commonjsGlobal;
35
- exports.createCommonjsModule = createCommonjsModule;
36
- exports.getAugmentedNamespace = getAugmentedNamespace;
44
+ export { createCommonjsModule as a, getAugmentedNamespace as b, commonjsGlobal as c, getDefaultExportFromCjs as g };
@@ -0,0 +1,70 @@
1
+ import { r as registerInstance, h } from './index-888e99e3.js';
2
+ import { C as Colors } from './colors-ea36347a.js';
3
+ import { H as HttpService } from './services-d71be591.js';
4
+ import './_commonjsHelpers-a4f66ccd.js';
5
+
6
+ const activateFormCss = ".form--user-activate-account .form--login-label{cursor:pointer;display:block;margin-bottom:6px}.form--user-activate-account input,.form--user-activate-account button{border:1px solid #cecece;box-sizing:border-box;display:inline-block;width:100%;padding:4px 11px;min-height:40px;-moz-transition:all 0.3s;-webkit-transition:all 0.3s;transition:all 0.3s;-moz-border-radius:6px;-webkit-border-radius:6px;border-radius:6px}.form--user-activate-account button{background-color:#001529;border:1px solid #001529;color:#fff;cursor:pointer}.form--user-activate-account button.btn--default{background-color:#fff;border:1px solid #F5F5F5;color:#141414}.form--user-activate-account button:disabled{background-color:#cecece;border:1px solid #cecece;color:#212121}";
7
+
8
+ const ActivateForm = class {
9
+ constructor(hostRef) {
10
+ registerInstance(this, hostRef);
11
+ this.username = undefined;
12
+ this.password = undefined;
13
+ this.onSuccess = undefined;
14
+ this.isSubmitting = undefined;
15
+ this.error = undefined;
16
+ this.confirmCode = undefined;
17
+ }
18
+ async onSubmit(evt) {
19
+ evt.preventDefault();
20
+ this.error = null;
21
+ this.isSubmitting = true;
22
+ if (this.username && this.confirmCode && this.password) {
23
+ try {
24
+ await HttpService().activateAccount(this.username, this.confirmCode);
25
+ const apiUrl = window.location.origin.indexOf('localhost') > -1 || window.location.origin.indexOf('favesalon.com')
26
+ ? 'https://favesalon.com'
27
+ : window.location.origin;
28
+ const userInfo = await HttpService().login(apiUrl, {
29
+ email: this.username,
30
+ password: this.password,
31
+ });
32
+ this.onSuccess(userInfo);
33
+ }
34
+ catch (e) {
35
+ this.error = e.message || `Something went wrong when changing your new password`;
36
+ }
37
+ }
38
+ else {
39
+ this.error = 'Please enter your received code or password to change your password';
40
+ }
41
+ this.isSubmitting = false;
42
+ }
43
+ async resendCode(evt) {
44
+ evt.preventDefault();
45
+ this.error = null;
46
+ try {
47
+ await HttpService().resendActivateCode(this.username);
48
+ }
49
+ catch (e) {
50
+ this.error = e.message || `Something went wrong when sending the confirm code`;
51
+ }
52
+ }
53
+ render() {
54
+ return (h("form", { class: "form--user-activate-account", onSubmit: (evt) => this.onSubmit(evt) }, this.error && (h("div", { style: {
55
+ backgroundColor: Colors.Red01,
56
+ border: `1px solid ${Colors.Red02}`,
57
+ marginBottom: '24px',
58
+ padding: '12px',
59
+ } }, this.error)), h("div", { style: { marginBottom: '24px' } }, h("label", { ...{ for: "form--login-username" }, class: "form--login-label" }, "Confirmation code"), h("input", { id: "form--login-username", type: "text", onInput: (evt) => {
60
+ this.confirmCode = evt.target.value;
61
+ } })), h("div", { style: { marginBottom: '24px' } }, h("button", { type: "submit", disabled: this.isSubmitting }, "SUBMIT")), h("div", { style: { marginTop: '32px', marginBottom: '24px', textAlign: 'center' } }, "I didn\u2019t receive my confirmation code yet?"), h("div", { style: { marginBottom: '24px' } }, h("button", { class: "btn--default", style: {
62
+ backgrourColor: `${Colors.Gray02} !important`,
63
+ border: `1px solid ${Colors.Gray02} !important`,
64
+ color: `${Colors.TextColor} !important`,
65
+ }, onClick: (evt) => this.resendCode(evt) }, "Resend"))));
66
+ }
67
+ };
68
+ ActivateForm.style = activateFormCss;
69
+
70
+ export { ActivateForm as activate_form };
@@ -0,0 +1,7 @@
1
+ import './index-888e99e3.js';
2
+
3
+ const globalFn = () => { };
4
+
5
+ const globalScripts = globalFn;
6
+
7
+ export { globalScripts as g };
@@ -0,0 +1,7 @@
1
+ import './index-a229b3b5.js';
2
+
3
+ const globalFn = () => { };
4
+
5
+ const globalScripts = globalFn;
6
+
7
+ export { globalScripts as g };
@@ -0,0 +1,81 @@
1
+ import { r as registerInstance, h } from './index-888e99e3.js';
2
+ import { C as Colors } from './colors-ea36347a.js';
3
+ import { H as HttpService } from './services-d71be591.js';
4
+ import './_commonjsHelpers-a4f66ccd.js';
5
+
6
+ const changePasswordFormCss = ".form--user-change-password .form--login-label{cursor:pointer;display:block;margin-bottom:6px}.form--user-change-password input,.form--user-change-password button{border:1px solid #cecece;box-sizing:border-box;display:inline-block;width:100%;padding:4px 11px;min-height:40px;-moz-transition:all 0.3s;-webkit-transition:all 0.3s;transition:all 0.3s;-moz-border-radius:6px;-webkit-border-radius:6px;border-radius:6px}.form--user-change-password button{background-color:#001529;border:1px solid #001529;color:#fff;cursor:pointer}.form--user-change-password button.btn--default{background-color:#fff;border:1px solid #F5F5F5;color:#141414}.form--user-change-password button:disabled{background-color:#cecece;border:1px solid #cecece;color:#212121}";
7
+
8
+ const ChangePasswordForm = class {
9
+ constructor(hostRef) {
10
+ registerInstance(this, hostRef);
11
+ this.username = undefined;
12
+ this.onSuccess = undefined;
13
+ this.isSubmitting = undefined;
14
+ this.error = undefined;
15
+ this.confirmCode = undefined;
16
+ this.password = undefined;
17
+ }
18
+ async onSubmit(evt) {
19
+ evt.preventDefault();
20
+ this.error = null;
21
+ this.isSubmitting = true;
22
+ if (this.username && this.confirmCode && this.password) {
23
+ try {
24
+ await HttpService().onChangePassword({
25
+ email: this.username,
26
+ password: this.password,
27
+ code: this.confirmCode,
28
+ });
29
+ const apiUrl = window.location.origin.indexOf('localhost') > -1 || window.location.origin.indexOf('favesalon.com')
30
+ ? 'https://favesalon.com'
31
+ : window.location.origin;
32
+ const userInfo = await HttpService().login(apiUrl, {
33
+ email: this.username,
34
+ password: this.password,
35
+ });
36
+ this.onSuccess(userInfo);
37
+ }
38
+ catch (e) {
39
+ this.error = e.message || `Something went wrong when changing your new password`;
40
+ }
41
+ }
42
+ else {
43
+ this.error = 'Please enter your received code or password to change your password';
44
+ }
45
+ this.isSubmitting = false;
46
+ }
47
+ async resendCode(evt) {
48
+ evt.preventDefault();
49
+ this.error = null;
50
+ if (this.username) {
51
+ try {
52
+ await HttpService().resetPassword(this.username);
53
+ }
54
+ catch (e) {
55
+ this.error = e.message || `Something went wrong when sending the confirm code`;
56
+ }
57
+ }
58
+ else {
59
+ this.error = 'Please enter your phone or email to reset your password';
60
+ }
61
+ }
62
+ render() {
63
+ return (h("form", { class: "form--user-change-password", onSubmit: (evt) => this.onSubmit(evt) }, this.error && (h("div", { style: {
64
+ backgroundColor: Colors.Red01,
65
+ border: `1px solid ${Colors.Red02}`,
66
+ marginBottom: '24px',
67
+ padding: '12px',
68
+ } }, this.error)), h("div", { style: { marginBottom: '24px' } }, h("label", { ...{ for: "form--login-username" }, class: "form--login-label" }, "Confirmation code"), h("input", { id: "form--login-username", type: "text", onInput: (evt) => {
69
+ this.confirmCode = evt.target.value;
70
+ } })), h("div", { style: { marginBottom: '24px' } }, h("label", { ...{ for: "form--login-password" }, class: "form--login-label" }, "Password"), h("input", { id: "form--login-password", type: "password", onInput: (evt) => {
71
+ this.password = evt.target.value;
72
+ } })), h("div", { style: { marginBottom: '24px' } }, h("button", { type: "submit", disabled: this.isSubmitting }, "SAVE")), h("div", { style: { marginTop: '32px', marginBottom: '24px', textAlign: 'center' } }, "I didn\u2019t receive my confirmation code yet?"), h("div", { style: { marginBottom: '24px' } }, h("button", { class: "btn--default", style: {
73
+ backgrourColor: `${Colors.Gray02} !important`,
74
+ border: `1px solid ${Colors.Gray02} !important`,
75
+ color: `${Colors.TextColor} !important`,
76
+ }, onClick: (evt) => this.resendCode(evt) }, "Resend"))));
77
+ }
78
+ };
79
+ ChangePasswordForm.style = changePasswordFormCss;
80
+
81
+ export { ChangePasswordForm as change_password_form };
@@ -0,0 +1,55 @@
1
+ import { r as registerInstance, h } from './index-888e99e3.js';
2
+ import { C as Colors } from './colors-ea36347a.js';
3
+ import { H as HttpService } from './services-d71be591.js';
4
+ import './_commonjsHelpers-a4f66ccd.js';
5
+
6
+ const indexCss = ".chat-widget,.chat-widget--sidebar,.chat-widget--content{display:flex;height:100%;width:100%}.chat-widget{font-size:16px;position:relative;font-family:'Roboto', sans-serif;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.chat-widget--sidebar,.chat-widget--content{background-color:#fff;border:1px solid #EFEFEF;position:absolute;inset:0;flex-direction:column}.chat-widget .chat-widget--sidebar{z-index:10}.chat-widget .chat-widget--content{z-index:5}.chat-widget.has-chat-room .chat-widget--content{z-index:10}.chat-widget--content-header{background-color:#001529;border-bottom:1px solid #EFEFEF;display:flex;align-items:center;justify-content:space-between;padding:16px}.chat-widget--content-title{font-size:20px;font-weight:600;line-height:1;margin:0}.chat-widget--content-close{border:1px solid #fff;cursor:pointer;display:block;position:absolute;z-index:1000;top:50%;right:0;width:30px;height:30px;transform:translate(0, -50%);-moz-border-radius:30px;-webkit-border-radius:30px;border-radius:30px;background-size:contain;background-repeat:no-repeat;background-position:center center;background-image:url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADwAAAA8CAYAAAA6/NlyAAAAAXNSR0IArs4c6QAAA3hJREFUaAXlm8+K00Acx7MiCIJH/yw+gA9g25O49SL4AO3Bp1jw5NvktC+wF88qevK4BU97EmzxUBCEolK/n5gp3W6TTJPfpNPNF37MNsl85/vN/DaTmU6PknC4K+pniqeKJ3k8UnkvDxXJzzy+q/yaxxeVHxW/FNHjgRSeKt4rFoplzaAuHHDBGR2eS9G54reirsmienDCTRt7xwsp+KAoEmt9nLaGitZxrBbPFNaGfPloGw2t4JVamSt8xYW6Dg1oCYo3Yv+rCGViV160oMkcd8SYKnYV1Nb1aEOjCe6L5ZOiLfF120EjWhuBu3YIZt1NQmujnk5F4MgOpURzLfAwOBSTmzp3fpDxuI/pabxpqOoz2r2HLAb0GMbZKlNV5/Hg9XJypguryA7lPF5KMdTZQzHjqxNPhWhzIuAruOl1eNqKEx1tSh5rfbxdw7mOxCq4qS68ZTjKS1YVvilu559vWvFHhh4rZrdyZ69Vmpgdj8fJbDZLJpNJ0uv1cnr/gjrUhQMuI+ANjyuwftQ0bbL6Erp0mM/ny8Fg4M3LtdRxgMtKl3jwmIHVxYXChFy94/Rmpa/pTbNUhstKV+4Rr8lLQ9KlUvJKLyG8yvQ2s9SBy1Jb7jV5a0yapfF6apaZLjLLcWtd4sNrmJUMHyM+1xibTjH82Zh01TNlhsrOhdKTe00uAzZQmN6+KW+sDa/JD2PSVQ873m29yf+1Q9VDzfEYlHi1G5LKBBWZbtEsHbFwb1oYDwr1ZiF/2bnCSg1OBE/pfr9/bWx26UxJL3ONPISOLKUvQza0LZUxSKyjpdTGa/vDEr25rddbMM0Q3O6Lx3rqFvU+x6UrRKQY7tyrZecmD9FODy8uLizTmilwNj0kraNcAJhOp5aGVwsAGD5VmJBrWWbJSgWT9zrzWepQF47RaGSiKfeGx6Szi3gzmX/HHbihwBser4B9UJYpFBNX4R6vTn3VQnez0SymnrHQMsRYGTr1dSk34ljRqS/EMd2pLQ8YBp3a1PLfcqCpo8gtHkZFHKkTX6fs3MY0blKnth66rKCnU0VRGu37ONrQaA4eZDFtWAu2fXj9zjFkxTBOo8F7t926gTp/83Kyzzcy2kZD6xiqxTYnHLRFm3vHiRSwNSjkz3hoIzo8lCKWUlg/YtGs7tObunDAZfpDLbfEI15zsEIY3U/x/gHHc/G1zltnAgAAAABJRU5ErkJggg==')}@media (min-width: 992px){.chat-widget--sidebar,.chat-widget--content{position:static;width:auto;-moz-border-radius:8px;-webkit-border-radius:8px;border-radius:8px}.chat-widget--sidebar{min-width:320px;max-width:320px;margin-right:24px}.chat-widget--content{flex-grow:1;flex-shrink:1}.chat-rooms--search,.chat-widget--content-header{-moz-border-radius:8px 8px 0 0;-webkit-border-radius:8px 8px 0 0;border-radius:8px 8px 0 0}}";
7
+
8
+ const ChatBox = class {
9
+ constructor(hostRef) {
10
+ registerInstance(this, hostRef);
11
+ this.onClickRoom = (chatRoom) => {
12
+ this.activeRoom = chatRoom;
13
+ };
14
+ this.primaryColor = undefined;
15
+ this.accessToken = undefined;
16
+ this.senderId = undefined;
17
+ this.salonId = undefined;
18
+ this.chatRooms = undefined;
19
+ this.activeRoom = undefined;
20
+ }
21
+ componentWillLoad() {
22
+ this.fetchData();
23
+ }
24
+ async fetchData() {
25
+ try {
26
+ this.chatRooms = await HttpService().fetchChatRooms(this.accessToken);
27
+ (this.chatRooms || []).forEach((chatRoom) => {
28
+ HttpService().fetchChatMessages(chatRoom.uid, (messages) => {
29
+ this.chatRooms = [...(this.chatRooms || [])].map((room) => {
30
+ if (chatRoom.uid === room.uid) {
31
+ room.messages = messages;
32
+ }
33
+ return room;
34
+ });
35
+ });
36
+ });
37
+ }
38
+ catch (e) {
39
+ this.chatRooms = [];
40
+ }
41
+ }
42
+ render() {
43
+ const senderInfo = this.activeRoom ? (this.activeRoom.members || []).find(user => user.id === Number(this.senderId)) : null;
44
+ const receiverInfo = this.activeRoom ? (this.activeRoom.members || []).find(user => user.id !== Number(this.senderId)) : null;
45
+ return (h("div", { class: `chat-widget ${this.activeRoom ? 'has-chat-room' : ''}` }, h("div", { class: "chat-widget--sidebar" }, h("chat-rooms", { "access-token": this.accessToken, "salon-id": Number(this.salonId), "sender-id": Number(this.senderId), activeRoom: this.activeRoom, chatRooms: this.chatRooms, onClickRoom: this.onClickRoom })), h("div", { class: "chat-widget--content" }, receiverInfo && (h("div", { class: "chat-widget--content-header" }, h("user-avatar", { size: 40, avatar: receiverInfo.avatar, name: h("div", { class: "chat-room--user-name", style: { color: '#fff' } }, receiverInfo.fullName), shortName: String(receiverInfo.fullName || '').charAt(0) }), h("div", { style: { position: 'relative' } }, h("div", { class: "chat-widget--content-close", onClick: () => this.onClickRoom(null) })))), h("div", { style: {
46
+ flexShrink: '1',
47
+ flexGrow: '1',
48
+ overflowY: 'auto',
49
+ padding: '16px',
50
+ } }, this.activeRoom && (h("chat-messages", { sender: senderInfo, receiver: receiverInfo, messages: this.activeRoom.messages || [], "chat-room-id": this.activeRoom.uid })), !this.activeRoom && (h("div", { style: { paddingTop: '72px', textAlign: 'center' } }, h("div", { class: "chat-widget--content-title" }, "Welcome back!"), h("div", { style: { marginTop: "12px" } }, "Select any user in left hand side to get started.")))), this.activeRoom && (h("div", { style: { borderTop: `1px solid ${Colors.Gray02}` } }, h("chat-form", { "sender-id": Number(senderInfo.id), "chat-room-id": this.activeRoom.uid }))))));
51
+ }
52
+ };
53
+ ChatBox.style = indexCss;
54
+
55
+ export { ChatBox as chat_box };
@@ -1,7 +1,7 @@
1
- import { r as registerInstance, h } from './index-0494771f.js';
1
+ import { r as registerInstance, h } from './index-888e99e3.js';
2
2
  import { C as Colors } from './colors-ea36347a.js';
3
- import { H as HttpService } from './services-257442e2.js';
4
- import './_commonjsHelpers-66ac50f5.js';
3
+ import { H as HttpService } from './services-d71be591.js';
4
+ import './_commonjsHelpers-a4f66ccd.js';
5
5
 
6
6
  const indexCss = "@import url('https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,400;0,500;0,700;1,400;1,500;1,700&display=swap'); chat-button{position:relative}.chat-button--indicator{cursor:pointer;position:absolute;inset:0}.chat-button--counter{background-color:rgb(240, 90, 97);border:1px solid rgb(255, 255, 255);position:absolute;right:6px;top:0px;height:8px;width:8px;-moz-border-radius:8px;-webkit-border-radius:8px;border-radius:8px}.chat-box{font-family:'Roboto', sans-serif;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;background-color:#fff;display:flex;flex-direction:column;position:fixed;inset:0px;z-index:20000;font-size:16px;text-align:left;color:#141414}.chat-box--header{display:flex;justify-content:space-between;padding:16px;position:relative}.chat-box--title{color:#fff;font-size:20px;font-weight:600;line-height:1;display:flex;align-items:center;justify-content:space-between;margin:0}.chat-box--close{cursor:pointer;display:block;position:absolute;z-index:1000;top:50%;right:0;width:30px;height:30px;transform:translate(0, -50%);background-size:contain;background-repeat:no-repeat;background-position:center center;background-image:url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADwAAAA8CAYAAAA6/NlyAAAAAXNSR0IArs4c6QAAA3hJREFUaAXlm8+K00Acx7MiCIJH/yw+gA9g25O49SL4AO3Bp1jw5NvktC+wF88qevK4BU97EmzxUBCEolK/n5gp3W6TTJPfpNPNF37MNsl85/vN/DaTmU6PknC4K+pniqeKJ3k8UnkvDxXJzzy+q/yaxxeVHxW/FNHjgRSeKt4rFoplzaAuHHDBGR2eS9G54reirsmienDCTRt7xwsp+KAoEmt9nLaGitZxrBbPFNaGfPloGw2t4JVamSt8xYW6Dg1oCYo3Yv+rCGViV160oMkcd8SYKnYV1Nb1aEOjCe6L5ZOiLfF120EjWhuBu3YIZt1NQmujnk5F4MgOpURzLfAwOBSTmzp3fpDxuI/pabxpqOoz2r2HLAb0GMbZKlNV5/Hg9XJypguryA7lPF5KMdTZQzHjqxNPhWhzIuAruOl1eNqKEx1tSh5rfbxdw7mOxCq4qS68ZTjKS1YVvilu559vWvFHhh4rZrdyZ69Vmpgdj8fJbDZLJpNJ0uv1cnr/gjrUhQMuI+ANjyuwftQ0bbL6Erp0mM/ny8Fg4M3LtdRxgMtKl3jwmIHVxYXChFy94/Rmpa/pTbNUhstKV+4Rr8lLQ9KlUvJKLyG8yvQ2s9SBy1Jb7jV5a0yapfF6apaZLjLLcWtd4sNrmJUMHyM+1xibTjH82Zh01TNlhsrOhdKTe00uAzZQmN6+KW+sDa/JD2PSVQ873m29yf+1Q9VDzfEYlHi1G5LKBBWZbtEsHbFwb1oYDwr1ZiF/2bnCSg1OBE/pfr9/bWx26UxJL3ONPISOLKUvQza0LZUxSKyjpdTGa/vDEr25rddbMM0Q3O6Lx3rqFvU+x6UrRKQY7tyrZecmD9FODy8uLizTmilwNj0kraNcAJhOp5aGVwsAGD5VmJBrWWbJSgWT9zrzWepQF47RaGSiKfeGx6Szi3gzmX/HHbihwBser4B9UJYpFBNX4R6vTn3VQnez0SymnrHQMsRYGTr1dSk34ljRqS/EMd2pLQ8YBp3a1PLfcqCpo8gtHkZFHKkTX6fs3MY0blKnth66rKCnU0VRGu37ONrQaA4eZDFtWAu2fXj9zjFkxTBOo8F7t926gTp/83Kyzzcy2kZD6xiqxTYnHLRFm3vHiRSwNSjkz3hoIzo8lCKWUlg/YtGs7tObunDAZfpDLbfEI15zsEIY3U/x/gHHc/G1zltnAgAAAABJRU5ErkJggg==')}@media (min-width: 768px){.chat-box{border:1px solid #fff;left:unset;top:unset;right:1px;bottom:0px;height:420px;max-height:90vh;width:600px;-moz-border-radius:8px 8px 0px 0px;-webkit-border-radius:8px 8px 0px 0px;border-radius:8px 8px 0px 0px;-moz-box-shadow:rgba(0, 0, 0, 0.1) 0px 0px 24px;-webkit-box-shadow:rgba(0, 0, 0, 0.1) 0px 0px 24px;box-shadow:rgba(0, 0, 0, 0.1) 0px 0px 24px}.chat-box--header{-moz-border-radius:8px 8px 0px 0px;-webkit-border-radius:8px 8px 0px 0px;border-radius:8px 8px 0px 0px}}";
7
7
 
@@ -9,9 +9,12 @@ const ChatButton = class {
9
9
  constructor(hostRef) {
10
10
  registerInstance(this, hostRef);
11
11
  this.primaryColor = undefined;
12
+ this.receiverId = undefined;
12
13
  this.accessToken = undefined;
13
14
  this.senderId = undefined;
14
- this.receiverId = undefined;
15
+ this.senderIdState = undefined;
16
+ this.accessTokenState = undefined;
17
+ this.isChatVerificationExpanded = undefined;
15
18
  this.senderInfo = {};
16
19
  this.receiverInfo = {};
17
20
  this.chatRoom = {};
@@ -19,31 +22,51 @@ const ChatButton = class {
19
22
  this.isChatExpanded = undefined;
20
23
  }
21
24
  componentWillLoad() {
22
- this.fetchData();
25
+ this.senderIdState = this.senderId;
26
+ this.accessTokenState = this.accessToken;
27
+ this.senderIdState && this.accessTokenState && this.fetchData();
23
28
  }
24
29
  async fetchData() {
25
30
  try {
26
- this.chatRoom = await HttpService().createChatRoom(this.receiverId, this.accessToken);
31
+ this.chatRoom = await HttpService().createChatRoom(this.receiverId, this.accessTokenState);
27
32
  if (this.chatRoom) {
28
33
  HttpService().fetchChatMessages(this.chatRoom.uid, (messages) => this.chatMessages = messages);
29
- this.senderInfo = this.chatRoom.members.find(user => user.id === Number(this.senderId));
34
+ this.senderInfo = this.chatRoom.members.find(user => user.id === Number(this.senderIdState));
30
35
  this.receiverInfo = this.chatRoom.members.find(user => user.id === Number(this.receiverId));
31
36
  }
32
37
  }
33
38
  catch (e) { }
34
39
  }
40
+ onVerificationSuccess(user) {
41
+ if (user.id && user.accessToken) {
42
+ this.isChatExpanded = true;
43
+ this.senderIdState = String(user.id);
44
+ this.accessTokenState = user.accessToken;
45
+ setTimeout(() => this.fetchData(), 350);
46
+ }
47
+ }
35
48
  render() {
36
- const unreadMessages = (this.chatMessages || []).filter(message => {
37
- return Boolean(message.unRead) && message.senderId !== this.senderInfo.id;
38
- });
39
- return (h("div", null, h("div", { class: "chat-button--indicator", onClick: () => this.isChatExpanded = true }, unreadMessages.length > 0 && h("span", { class: "chat-button--counter" })), h("div", { class: "chat-box", style: this.isChatExpanded ? {} : { display: 'none' } }, h("div", { class: "chat-box--header", style: {
49
+ if (this.senderIdState && this.accessTokenState) {
50
+ const unreadMessages = (this.chatMessages || []).filter(message => {
51
+ return Boolean(message.unRead) && message.senderId !== this.senderInfo.id;
52
+ });
53
+ return (h("div", null, unreadMessages.length > 0 && h("notify-sounds", null), h("div", { class: "chat-button--indicator", onClick: () => this.isChatExpanded = true }, unreadMessages.length > 0 && h("span", { class: "chat-button--counter" })), h("div", { class: "chat-box", style: this.isChatExpanded ? {} : { display: 'none' } }, h("div", { class: "chat-box--header", style: {
54
+ backgroundColor: this.primaryColor || '#f05a61',
55
+ } }, h("h3", { class: "chat-box--title" }, "Chat"), h("div", { style: { position: 'relative' } }, h("div", { class: "chat-box--close", onClick: () => this.isChatExpanded = false }))), h("div", { style: {
56
+ flexShrink: '1',
57
+ flexGrow: '1',
58
+ overflowY: 'auto',
59
+ padding: '16px',
60
+ } }, h("chat-messages", { sender: this.senderInfo, receiver: this.receiverInfo, messages: this.chatMessages || [], "chat-room-id": this.chatRoom.uid })), h("div", { style: { borderTop: `1px solid ${Colors.Gray02}` } }, h("chat-form", { "sender-id": this.senderInfo.id ? Number(this.senderInfo.id) : null, "chat-room-id": this.chatRoom.uid })))));
61
+ }
62
+ return (h("div", null, h("div", { class: "chat-button--indicator", onClick: () => this.isChatVerificationExpanded = true }), h("div", { class: "chat-box", style: this.isChatVerificationExpanded ? {} : { display: 'none' } }, h("div", { class: "chat-box--header", style: {
40
63
  backgroundColor: this.primaryColor || '#f05a61',
41
- } }, h("h3", { class: "chat-box--title" }, "Chat"), h("div", { style: { position: 'relative' } }, h("div", { class: "chat-box--close", onClick: () => this.isChatExpanded = false }))), h("div", { style: {
64
+ } }, h("h3", { class: "chat-box--title" }, "Chat"), h("div", { style: { position: 'relative' } }, h("div", { class: "chat-box--close", onClick: () => this.isChatVerificationExpanded = false }))), h("div", { style: {
42
65
  flexShrink: '1',
43
66
  flexGrow: '1',
44
67
  overflowY: 'auto',
45
68
  padding: '16px',
46
- } }, h("chat-messages", { sender: this.senderInfo, receiver: this.receiverInfo, messages: this.chatMessages || [], "chat-room-id": this.chatRoom.uid })), h("div", { style: { borderTop: `1px solid ${Colors.Gray02}` } }, h("chat-form", { "sender-id": this.senderInfo.id ? Number(this.senderInfo.id) : null, "chat-room-id": this.chatRoom.uid })))));
69
+ } }, h("user-form", { onSuccess: user => this.onVerificationSuccess(user) })))));
47
70
  }
48
71
  };
49
72
  ChatButton.style = indexCss;
@@ -0,0 +1,39 @@
1
+ import { r as registerInstance, h } from './index-888e99e3.js';
2
+ import { H as HttpService } from './services-d71be591.js';
3
+ import './_commonjsHelpers-a4f66ccd.js';
4
+ import './colors-ea36347a.js';
5
+
6
+ const indexCss = ".chat-form{display:flex;height:56px;width:100%}.chat-form #chat-form--input{border:none;outline:none;flex-shrink:1;flex-grow:1;height:100%;font-size:16px;padding-left:16px;padding-right:16px;-moz-border-radius:6px;-webkit-border-radius:6px;border-radius:6px}.chat-form>button{background-color:#001529;border:none;color:#fff;cursor:pointer;font-size:16px;min-width:80px;height:42px;margin:7px;-moz-border-radius:4px;-webkit-border-radius:4px;border-radius:4px}.chat-form>button:hover,.chat-form>button:focus,.chat-form>button:active{background-color:#001529}";
7
+
8
+ const ChatForm = class {
9
+ constructor(hostRef) {
10
+ registerInstance(this, hostRef);
11
+ this.onSubmitMessage = async () => {
12
+ try {
13
+ const elNewMessage = document.getElementById('chat-form--input');
14
+ if (!!elNewMessage.value) {
15
+ await HttpService().sendChatMessage({
16
+ message: elNewMessage.value,
17
+ senderId: this.senderId,
18
+ chatRoomId: this.chatRoomId,
19
+ });
20
+ elNewMessage.value = '';
21
+ }
22
+ }
23
+ catch (error) { }
24
+ };
25
+ this.senderId = undefined;
26
+ this.chatRoomId = undefined;
27
+ }
28
+ render() {
29
+ return (h("div", { class: "chat-form" }, h("input", { id: "chat-form--input", type: "text", placeholder: "Enter a message...", onKeyPress: (evt) => {
30
+ if (evt.key === 'Enter') {
31
+ evt.preventDefault();
32
+ this.onSubmitMessage();
33
+ }
34
+ } }), h("button", { type: "button", onClick: () => this.onSubmitMessage() }, "Send")));
35
+ }
36
+ };
37
+ ChatForm.style = indexCss;
38
+
39
+ export { ChatForm as chat_form };
@@ -0,0 +1,71 @@
1
+ import { r as registerInstance, h } from './index-888e99e3.js';
2
+ import { d as dayjs_min, H as HttpService, t as timeFormatAmPm } from './services-d71be591.js';
3
+ import { l as lodash } from './lodash-d5526b38.js';
4
+ import { C as Colors } from './colors-ea36347a.js';
5
+ import { r as relativeTime } from './relativeTime-268e64b0.js';
6
+ import './_commonjsHelpers-a4f66ccd.js';
7
+
8
+ const indexCss = ".chat-message{overflow:hidden;clear:both;min-width:240px}.chat-message+.chat-message{margin-top:6px}.chat-message--meta{display:flex}.chat-message--title{background-color:#F1F1F1;padding:8px 12px;position:relative;float:left;margin-top:6px;-moz-border-radius:0 10px 10px 10px;-webkit-border-radius:0 10px 10px 10px;border-radius:0 10px 10px 10px}.chat-message--time{clear:both;color:#999;font-size:75%;padding-top:2px}.chat-message.is-owner .chat-message--content{margin-left:12px}.chat-message.is-guest .chat-message--meta{flex-direction:row-reverse}.chat-message.is-guest .chat-message--title{background-color:#EFF7FF;float:right;margin-right:12px;text-align:right;-moz-border-radius:10px 0 10px 10px;-webkit-border-radius:10px 0 10px 10px;border-radius:10px 0 10px 10px}";
9
+
10
+ dayjs_min.extend(relativeTime);
11
+ const ChatMessages = class {
12
+ constructor(hostRef) {
13
+ registerInstance(this, hostRef);
14
+ this.markMessagesAsRead = async () => {
15
+ try {
16
+ const unreadMessages = (this.messages || []).filter(message => {
17
+ return Boolean(message.unRead) && message.senderId !== this.sender.id;
18
+ });
19
+ if (unreadMessages.length > 0) {
20
+ await HttpService().markMessagesAsRead(this.chatRoomId, unreadMessages);
21
+ }
22
+ }
23
+ catch (e) { }
24
+ };
25
+ this.scrollToLastMessage = () => {
26
+ const targetElement = document.getElementById('chat--last-message');
27
+ targetElement && targetElement.scrollIntoView();
28
+ };
29
+ this.renderMessage = (chatMessage) => {
30
+ const { message, senderId, timestamp } = chatMessage;
31
+ const isOwner = this.sender.id === senderId;
32
+ return (h("div", { class: `chat-message ${isOwner ? 'is-owner' : 'is-guest'}` }, h("div", { class: "chat-message--meta" }, h("user-avatar", { size: 40, shortName: String(((isOwner ? this.sender : this.receiver) || {}).fullName || '').charAt(0), avatar: ((isOwner ? this.sender : this.receiver) || {}).avatar }), h("div", { class: "chat-message--content" }, h("div", { class: "chat-message--title" }, message), timestamp && (h("div", { class: "chat-message--time" }, dayjs_min(timestamp).format(timeFormatAmPm)))))));
33
+ };
34
+ this.sender = {};
35
+ this.receiver = {};
36
+ this.messages = [];
37
+ this.chatRoomId = undefined;
38
+ }
39
+ componentDidLoad() {
40
+ this.markMessagesAsRead();
41
+ }
42
+ componentDidUpdate() {
43
+ this.scrollToLastMessage();
44
+ }
45
+ render() {
46
+ const isEmpty = (this.messages || []).length === 0;
47
+ const chatMessagesMapping = lodash.groupBy((this.messages || []), m => m.dateName);
48
+ return (h("div", { class: "chat-messages" }, !isEmpty && (h("div", null, lodash.keys(chatMessagesMapping).map(dateName => {
49
+ return (h("div", null, h("div", { style: {
50
+ backgroundColor: Colors.Gray01,
51
+ position: 'relative',
52
+ height: '1px',
53
+ marginTop: '24px',
54
+ marginBottom: '12px',
55
+ } }, h("span", { style: {
56
+ backgroundColor: Colors.White,
57
+ fontSize: '90%',
58
+ position: 'absolute',
59
+ left: '50%',
60
+ top: '50%',
61
+ transform: 'translate(-50%, -50%)',
62
+ paddingLeft: '4px',
63
+ paddingRight: '4px',
64
+ marginTop: '-2px',
65
+ } }, dateName)), h("div", null, (chatMessagesMapping[dateName] || []).map(this.renderMessage))));
66
+ }))), isEmpty && (h("div", { style: { padding: '48px', textAlign: 'center' } }, h("div", { style: { color: Colors.Green04 } }, "No messages yet"))), h("div", { id: "chat--last-message" })));
67
+ }
68
+ };
69
+ ChatMessages.style = indexCss;
70
+
71
+ export { ChatMessages as chat_messages };
@@ -0,0 +1,111 @@
1
+ import { r as registerInstance, h } from './index-888e99e3.js';
2
+ import { l as lodash } from './lodash-d5526b38.js';
3
+ import { C as Colors } from './colors-ea36347a.js';
4
+ import { H as HttpService } from './services-d71be591.js';
5
+ import { f as formatPhoneNumber } from './utils-fd30fb29.js';
6
+ import './_commonjsHelpers-a4f66ccd.js';
7
+
8
+ const indexCss = "chat-rooms,.chat-rooms{display:flex;flex-direction:column;height:100%;width:100%}.chat-rooms--search{background-color:#001529;border-bottom:1px solid #EFEFEF;display:flex;padding:16px}.chat-rooms--search>input{background-color:#F5F5F5;border:1px solid #EFEFEF;height:40px;width:100%;font-size:16px;padding-left:16px;padding-right:16px;-moz-border-radius:4px;-webkit-border-radius:4px;border-radius:4px}.chat-rooms--search>input:hover,.chat-rooms--search>input:active{border:1px solid #DBDBDB}.chat-rooms--search>button{background-color:#F5F5F5;border:1px solid #EFEFEF;font-size:16px;min-width:80px;height:40px;margin-left:12px;-moz-border-radius:4px;-webkit-border-radius:4px;border-radius:4px}.chat-rooms--list{flex-grow:1;flex-shrink:1;overflow-y:auto}.chat-room{cursor:pointer;display:flex;position:relative;margin-bottom:1px;padding:12px 16px}.chat-room:hover,.chat-room.is-active{background-color:#F5F5F5}.chat-room--user{flex-grow:1;flex-shrink:1;overflow:hidden}.chat-room--user-name{font-size:16px;font-weight:600;line-height:18px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.chat-room--latest-message{font-size:12px;line-height:14px;margin-top:4px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.chat-room--user-indicator{background-color:rgb(240, 90, 97);border:1px solid rgb(255, 255, 255);height:8px;width:8px;position:absolute;right:8px;top:50%;transform:translate(0, -50%);-moz-border-radius:8px;-webkit-border-radius:8px;border-radius:8px}";
9
+
10
+ const ChatRooms = class {
11
+ constructor(hostRef) {
12
+ registerInstance(this, hostRef);
13
+ this.clickRoom = (chatRoom) => {
14
+ this.onClickRoom(chatRoom);
15
+ };
16
+ this.onSearchRooms = lodash.debounce(async (keyword) => {
17
+ this.keyword = keyword;
18
+ this.clients = [];
19
+ if (!!keyword) {
20
+ try {
21
+ this.clients = await HttpService().fetchClients(this.salonId, keyword, this.accessToken);
22
+ }
23
+ catch (e) { }
24
+ }
25
+ }, 350);
26
+ this.renderChatRoom = (chatRoom, index) => {
27
+ const { uid, members, messages } = chatRoom;
28
+ const receiverUser = members.find(user => user.id !== this.senderId);
29
+ const isActiveRoom = (this.activeRoom || {}).uid === uid;
30
+ let unreadMessages = 0;
31
+ const lastMessage = lodash.last(messages || []);
32
+ (messages || []).forEach(message => {
33
+ if (Boolean(message.unRead) && message.senderId !== this.senderId) {
34
+ unreadMessages += 1;
35
+ }
36
+ });
37
+ return (h("div", { key: `chat-room--${uid}-${index}`, class: `chat-room ${isActiveRoom ? 'is-active' : ''}`, onClick: () => !isActiveRoom && this.clickRoom(chatRoom) }, h("div", { class: "chat-room--user" }, h("user-avatar", { size: 48, avatar: receiverUser.avatar, name: h("div", { class: "chat-room--user-name" }, receiverUser.fullName), description: lastMessage && (h("div", { class: "chat-room--latest-message" }, lastMessage.senderId === this.senderId ? 'You: ' : '', lastMessage.message)), shortName: String(receiverUser.fullName || '').charAt(0) })), unreadMessages > 0 && (h("div", { class: "chat-room--user-indicator" }))));
38
+ };
39
+ this.initChatRoom = async (user) => {
40
+ let activeChatRoom = (this.chatRooms || []).find(room => {
41
+ return (room.members || []).find(member => member.id === user.id);
42
+ });
43
+ try {
44
+ if (!activeChatRoom && user.id) {
45
+ activeChatRoom = await HttpService().createChatRoom(user.id, this.accessToken);
46
+ this.chatRooms = this.chatRooms.concat([activeChatRoom]);
47
+ }
48
+ }
49
+ catch (e) { }
50
+ this.onClickRoom(activeChatRoom);
51
+ };
52
+ this.renderClient = (user, index) => {
53
+ const { id, avatar, fullName } = user;
54
+ return (h("div", { key: `chat-room--client-${id}-${index}`, class: "chat-room", onClick: () => this.initChatRoom(user) }, h("div", { class: "chat-room--user" }, h("user-avatar", { size: 48, avatar: avatar, name: h("div", { class: "chat-room--user-name" }, fullName), shortName: String(fullName || '').charAt(0) }))));
55
+ };
56
+ this.senderId = undefined;
57
+ this.salonId = undefined;
58
+ this.chatRooms = undefined;
59
+ this.clients = undefined;
60
+ this.activeRoom = undefined;
61
+ this.accessToken = undefined;
62
+ this.onClickRoom = undefined;
63
+ this.keyword = undefined;
64
+ }
65
+ render() {
66
+ const visibleRooms = (this.chatRooms || []).filter(chatRoom => {
67
+ if (this.keyword) {
68
+ const receiverUser = chatRoom.members.find(user => user.id !== this.senderId) || {};
69
+ return String(receiverUser.fullName).toLowerCase().indexOf(String(this.keyword).toLowerCase()) > -1
70
+ || String(formatPhoneNumber(receiverUser.mobilePhone)).toLowerCase().indexOf(formatPhoneNumber(String(this.keyword).toLowerCase())) > -1;
71
+ }
72
+ return true;
73
+ });
74
+ return (h("div", { class: "chat-rooms" }, h("div", { class: "chat-rooms--search" }, h("input", { autoComplete: "off", placeholder: "Enter a name...", onInput: evt => this.onSearchRooms(evt.target.value) })), h("div", { class: "chat-rooms--list" }, !this.chatRooms && [1, 2, 3, 4].map(fakeId => (h("div", { key: `chat-room--${fakeId}`, class: "chat-room" }, h("div", { class: "chat-room--user" }, h("div", { style: { display: "flex", alignItems: "center" } }, h("div", { style: {
75
+ backgroundColor: Colors.Gray02,
76
+ borderRadius: '50%',
77
+ height: `48px`,
78
+ width: `48px`,
79
+ minWidth: `48px`,
80
+ } }), h("div", { style: {
81
+ flexShrink: '1',
82
+ flexGrow: '1',
83
+ marginLeft: '12px',
84
+ } }, h("div", { style: {
85
+ backgroundColor: Colors.Gray02,
86
+ height: '16px',
87
+ width: '30%',
88
+ } }), h("div", { style: {
89
+ backgroundColor: Colors.Gray01,
90
+ marginTop: '12px',
91
+ height: '16px',
92
+ width: '60%',
93
+ } }))))))), this.chatRooms && this.keyword && (h("div", { style: {
94
+ borderBottom: `1px solid ${Colors.Gray01}`,
95
+ color: Colors.Primary,
96
+ fontSize: '12px',
97
+ fontWeight: '700',
98
+ padding: '12px 16px',
99
+ } }, "PEOPLE")), this.chatRooms && visibleRooms.length > 0 && visibleRooms.map(this.renderChatRoom), this.chatRooms && visibleRooms.length === 0 && (h("div", { style: { color: Colors.Gray04, padding: '64px 24px', textAlign: 'center' } }, "No available users")), this.keyword && (this.clients || []).length > 0 && (h("div", null, h("div", { style: {
100
+ borderBottom: `1px solid ${Colors.Gray01}`,
101
+ color: Colors.Primary,
102
+ fontSize: '12px',
103
+ fontWeight: '700',
104
+ padding: '12px 16px',
105
+ marginTop: '24px',
106
+ } }, "YOUR CLIENTS"), this.clients.map(this.renderClient))))));
107
+ }
108
+ };
109
+ ChatRooms.style = indexCss;
110
+
111
+ export { ChatRooms as chat_rooms };