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
File without changes
@@ -1,10 +0,0 @@
1
- export const consumerUser = {
2
- "id": 442558,
3
- "name": "Trung Luu",
4
- "avatar": "https://favesalon.s3.amazonaws.com/public/media/uploads/photos/-1/2022-08-23-a982011a-4d49-488b-8a28-343631avatar1.jpg",
5
- };
6
- export const salonOwner = {
7
- "id": 373905,
8
- "name": "Nick Test",
9
- "avatar": "https://d3m4d8z2xvy8tb.cloudfront.net/public/media/uploads/salon/profile/2018-11-13-575a6133-724f-4d63-8595-f545396ad96d.png",
10
- };
@@ -1,295 +0,0 @@
1
- var __rest = (this && this.__rest) || function (s, e) {
2
- var t = {};
3
- for (var p in s)
4
- if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
5
- t[p] = s[p];
6
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
7
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
8
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
9
- t[p[i]] = s[p[i]];
10
- }
11
- return t;
12
- };
13
- import get from 'lodash/get';
14
- import each from 'lodash/each';
15
- import sortBy from 'lodash/sortBy';
16
- import axios from 'axios';
17
- import { createSalon } from '../types/salon';
18
- import { initializeApp } from 'firebase/app';
19
- import { child, getDatabase, ref, onValue, push, update } from 'firebase/database';
20
- import { createFaveStyle, createFaveStyleComment } from '../types/style';
21
- import { createService } from '../types/service';
22
- import { createStylist } from '../types/stylist';
23
- import { createReview } from '../types/review';
24
- import { apiV1Prefix } from '../types/common';
25
- import { createChatMessage, createChatRoom } from '../types/chat';
26
- import dayjs from 'dayjs';
27
- const apiV2Prefix = 'api-ver2';
28
- const firebaseMessagesNode = 'favesalon--messages';
29
- class HttpService {
30
- constructor() {
31
- this.http = null;
32
- this.http = axios.create({
33
- baseURL: 'https://favesalon.com',
34
- // baseURL: 'http://13.57.216.170',
35
- headers: {},
36
- });
37
- try {
38
- if (!this.firebaseApp) {
39
- this.firebaseApp = initializeApp({
40
- apiKey: "AIzaSyD5IdiIA9QUZeguRbi8DEZ25TrNXPU3-uI",
41
- authDomain: "favestyle-b57d4.firebaseapp.com",
42
- databaseURL: "https://favestyle-b57d4.firebaseio.com",
43
- projectId: "favestyle-b57d4",
44
- storageBucket: "favestyle-b57d4.appspot.com",
45
- messagingSenderId: "105638847842",
46
- appId: "1:105638847842:web:35f50dfe0e8eb52f46783b",
47
- });
48
- }
49
- this.firebaseDatabase = getDatabase(this.firebaseApp);
50
- }
51
- catch (error) { }
52
- }
53
- fetchStyleDetail(styleId) {
54
- return this.http.get(`${apiV2Prefix}/style/${styleId}/detail`)
55
- .then((response) => {
56
- const { status, data } = response.data;
57
- if (status) {
58
- let styleInfo = null, similarStyles = [];
59
- try {
60
- styleInfo = createFaveStyle(data);
61
- similarStyles = (data.style_similars || []).map(createFaveStyle);
62
- }
63
- catch (e) { }
64
- return { styleInfo, similarStyles };
65
- }
66
- return { styleInfo: null, similarStyles: [] };
67
- })
68
- .catch(() => {
69
- return { styleInfo: null, similarStyles: [] };
70
- });
71
- }
72
- fetchSalonInfo(salonId) {
73
- const url = `${apiV2Prefix}/salon/${salonId}/detail`;
74
- return this.http.get(url)
75
- .then((response) => {
76
- const { status, data } = response.data;
77
- return status && data ? createSalon(data) : null;
78
- })
79
- .catch(() => (null));
80
- }
81
- fetchSalonLatestStyles(salonId, options) {
82
- const url = `${apiV2Prefix}/salon/${salonId}/styles`;
83
- return this.http.post(url, Object.assign(Object.assign({}, options), { sort: 'newest' }))
84
- .then(response => {
85
- const { data } = response.data;
86
- return (data || []).slice(0, options.limit).map(createFaveStyle);
87
- })
88
- .catch(() => ([]));
89
- }
90
- decorateServiceGroups(groups) {
91
- return groups.map((cate, index) => {
92
- const cateName = cate.name;
93
- const categoryId = `${cate.service_id}-${String(cateName).toLowerCase().split(' ').join('-')}-${cate.order}-index-${index}`;
94
- const sortedSubCates = sortBy(cate.service_groups, [subCate => subCate.order]);
95
- return {
96
- id: categoryId,
97
- name: cateName,
98
- type: 'category',
99
- data: sortedSubCates.map((subCate, subCateIndex) => {
100
- const subCateId = `${categoryId}-${String(subCate.name).toLowerCase().split(' ').join('-')}-${subCate.order}-index-${subCateIndex}`;
101
- return {
102
- key: subCateId,
103
- name: subCate.category,
104
- type: 'sub-category',
105
- data: (subCate.services || []).map(rawService => {
106
- const serviceObj = createService(rawService);
107
- return Object.assign(Object.assign({}, serviceObj), { type: 'service' });
108
- }),
109
- };
110
- }),
111
- };
112
- });
113
- }
114
- fetchSalonServices(salonId) {
115
- const url = `${apiV1Prefix}/salon/services?v=2&id=${salonId}`;
116
- return this.http.get(url)
117
- .then(response => {
118
- const { status, data } = response.data;
119
- if (status) {
120
- return this.decorateServiceGroups(data || []);
121
- }
122
- return [];
123
- })
124
- .catch(() => ([]));
125
- }
126
- fetchSalonStylists(salonId, options = { page: 1, limit: 12 }) {
127
- const url = `${apiV2Prefix}/salon/${salonId}/stylists?page=${options.page}&limit=${options.limit}`;
128
- return this.http.get(url)
129
- .then(response => {
130
- const { paging, data } = response.data;
131
- return {
132
- total: paging.total_item || data.length,
133
- data: data.map(createStylist),
134
- };
135
- })
136
- .catch(() => ({ total: 0, data: [] }));
137
- }
138
- fetchSalonReviews(salonId, options) {
139
- const url = `${apiV2Prefix}/salon/${salonId}/reviews`;
140
- return this.http.post(url, Object.assign({ avg_point_greater_than: 0 }, options))
141
- .then(response => {
142
- const { data, paging } = response.data || {};
143
- const { total_1star: onestar, total_2star: twoStar, total_3star: threeStar, total_4star: fourStar, total_5star: fiveStar, total_review: totalReviews, avg_point: reviewPoint, } = paging.review_detail || {};
144
- return {
145
- total: paging.total_item || 0,
146
- stats: {
147
- totalReviews,
148
- reviewPoint: reviewPoint ? Math.ceil(reviewPoint) : 0,
149
- '1': onestar ? Math.ceil(onestar) : 0,
150
- '2': twoStar ? Math.ceil(twoStar) : 0,
151
- '3': threeStar ? Math.ceil(threeStar) : 0,
152
- '4': fourStar ? Math.ceil(fourStar) : 0,
153
- '5': fiveStar ? Math.ceil(fiveStar) : 0,
154
- },
155
- data: data.map(createReview),
156
- };
157
- })
158
- .catch(() => ({ total: 0, stats: {}, data: [] }));
159
- }
160
- fetchSalonCategories() {
161
- return this.http.post(`${apiV2Prefix}/search/get-services`, { limit: 50 })
162
- .then((response) => {
163
- const { status, data } = response.data;
164
- if (status) {
165
- return (data || []).map(blob => {
166
- return {
167
- id: blob.id,
168
- name: blob.name,
169
- image: blob.full_image,
170
- imageThumb: blob.full_thumb_image,
171
- };
172
- });
173
- }
174
- return [];
175
- })
176
- .catch(() => ([]));
177
- }
178
- fetchSalonLookbooks(salonId, options) {
179
- const noResult = { total: 0, allLookbooks: [] };
180
- const url = `${apiV2Prefix}/salon/${salonId}/styles`;
181
- const postData = Object.assign({ page: 1, limit: 20 }, options);
182
- return this.http.post(url, postData)
183
- .then(response => {
184
- const { status, data, paging } = response.data;
185
- if (status) {
186
- return {
187
- total: paging.total_item || 0,
188
- allLookbooks: (data || []).map(createFaveStyle),
189
- };
190
- }
191
- return noResult;
192
- })
193
- .catch(() => (noResult));
194
- }
195
- fetchStyleComments(styleId) {
196
- const url = `${apiV2Prefix}/style/comment?photo_id=${styleId}`;
197
- return this.http.get(url)
198
- .then(response => {
199
- const { paging, data } = response.data;
200
- return {
201
- total: paging.total_item || 0,
202
- data: data.map(createFaveStyleComment),
203
- };
204
- })
205
- .catch(() => ({ total: 0, data: [] }));
206
- }
207
- createChatRoom(receiverId, accessToken) {
208
- const url = `${apiV2Prefix}/chatroom/create/${receiverId}?access_token=${accessToken}`;
209
- return this.http.get(url)
210
- .then(response => {
211
- const blob = get(response, 'data.data', {});
212
- return createChatRoom(blob);
213
- })
214
- .catch(() => (null));
215
- }
216
- fetchRooms(accessToken, page, allRooms = []) {
217
- const url = `${apiV2Prefix}/chatroom/get?page=${page}&limit=20&access_token=${accessToken}`;
218
- return this.http.get(url)
219
- .then(response => {
220
- const blobs = get(response, 'data.data', []);
221
- const chatRooms = blobs.map(createChatRoom);
222
- // fetch next page's styles
223
- if (chatRooms.length >= 20) {
224
- return this.fetchRooms(accessToken, page + 1, allRooms.concat(chatRooms));
225
- }
226
- return page === 1 ? chatRooms : allRooms.concat(chatRooms);
227
- });
228
- }
229
- fetchChatRooms(accessToken) {
230
- return this.fetchRooms(accessToken, 1)
231
- .catch(() => ([]));
232
- }
233
- fetchChatMessages(roomId, onDone) {
234
- if (this.firebaseDatabase) {
235
- try {
236
- const roomMessagesRef = ref(this.firebaseDatabase, `${firebaseMessagesNode}/${roomId}`);
237
- onValue(roomMessagesRef, (snapshot) => {
238
- const conversations = [];
239
- each(snapshot.val(), (message, key) => {
240
- const chatMessage = createChatMessage(Object.assign(Object.assign({}, message), { uid: key }));
241
- conversations.push(chatMessage);
242
- });
243
- onDone(sortBy(conversations, 'timestamp'));
244
- });
245
- }
246
- catch (error) {
247
- onDone([]);
248
- }
249
- }
250
- return Promise.resolve({});
251
- }
252
- markMessagesAsRead(roomId, roomMessages) {
253
- if (this.firebaseDatabase) {
254
- try {
255
- const roomMessagesRef = ref(this.firebaseDatabase, `${firebaseMessagesNode}/${roomId}`);
256
- const updates = {};
257
- roomMessages.forEach(message => {
258
- const { uid } = message, nestedMessage = __rest(message, ["uid"]);
259
- updates[`${message.uid}`] = Object.assign(Object.assign({}, nestedMessage), { unRead: 0 });
260
- });
261
- return update(roomMessagesRef, updates);
262
- }
263
- catch (error) { }
264
- }
265
- return Promise.reject();
266
- }
267
- sendChatMessage(options) {
268
- if (this.firebaseDatabase) {
269
- try {
270
- const { message, senderId, chatRoomId } = options;
271
- // Get a key for a new message.
272
- const roomMessagesRef = ref(this.firebaseDatabase, `${firebaseMessagesNode}`);
273
- const newMessageKey = push(child(roomMessagesRef, chatRoomId)).key;
274
- const newMessageKeyPath = `/${chatRoomId}/${newMessageKey}`;
275
- const newMessage = {
276
- message,
277
- unRead: 1,
278
- senderId,
279
- timestamp: dayjs().valueOf(),
280
- };
281
- // Store new message in Firebase
282
- const updates = {
283
- [newMessageKeyPath]: newMessage,
284
- };
285
- return update(roomMessagesRef, updates)
286
- .then(() => {
287
- return Object.assign(Object.assign({}, newMessage), { uid: newMessageKey });
288
- });
289
- }
290
- catch (error) { }
291
- }
292
- return Promise.reject();
293
- }
294
- }
295
- export default () => new HttpService();
@@ -1,23 +0,0 @@
1
- import { createUser } from './user';
2
- export function createChatMessage(blob) {
3
- return {
4
- uid: blob.uid,
5
- message: blob.message,
6
- timestamp: blob.timestamp,
7
- unRead: blob.unRead,
8
- senderId: Number(blob.senderId),
9
- };
10
- }
11
- export class ChatRoom {
12
- constructor(fields) {
13
- Object.assign(this, fields);
14
- }
15
- }
16
- export function createChatRoom(blob) {
17
- return new ChatRoom({
18
- id: blob.id,
19
- uid: blob.firebase_room_id,
20
- members: blob.from_user && blob.to_user ? [createUser(blob.from_user), createUser(blob.to_user)] : [],
21
- messages: [],
22
- });
23
- }
@@ -1,11 +0,0 @@
1
- export const timeFormat = 'HH:mm:ss';
2
- export const timeFormatAmPm = 'hh:mm A';
3
- export const dateName = 'dddd';
4
- export const dateFormat = 'YYYY-MM-DD';
5
- export const dateTimeFormat = 'YYYY-MM-DD HH:mm:ss';
6
- export const dateTimeFormatAmPm = 'YYYY-MM-DD hh:mm A';
7
- export const shortDateFormat = 'ddd, MMM DD';
8
- export const shortDateYearFormat = 'ddd, MMM DD YYYY';
9
- export const apiV1Prefix = 'api';
10
- export const apiV2Prefix = 'api-ver2';
11
- export const defaultImage = 'https://res.cloudinary.com/reckon-mini-sites/image/upload/v1636477599/FaveSalon%20Social%20Website/default/default--picture_w3jvfh.png';
@@ -1,39 +0,0 @@
1
- import dayjs from "dayjs";
2
- import { dateTimeFormat } from "./common";
3
- import { createSalon } from "./salon";
4
- import { createStylist } from "./stylist";
5
- import { createUser } from "./user";
6
- function createReviewPhoto(blob) {
7
- return {
8
- id: blob.id,
9
- caption: blob.caption,
10
- imageUrl: blob.full_image_url,
11
- imageUrlThumb: blob.full_image_url_thumb,
12
- };
13
- }
14
- export class Review {
15
- }
16
- export function createReview(blob) {
17
- const reviewPhotos = blob.review_photo || [];
18
- const [createdDay, createdTime] = String(blob.create_date).split(' ');
19
- const [updatedDay, updatedTime] = String(blob.update_date).split(' ');
20
- return {
21
- title: blob.title,
22
- description: blob.comment,
23
- createdDate: dayjs(`${createdDay} ${createdTime}`, dateTimeFormat).valueOf(),
24
- updatedDate: dayjs(`${updatedDay} ${updatedTime}`, dateTimeFormat).valueOf(),
25
- point: Math.ceil(Number(blob.avg_point)),
26
- pointView: blob.view_point,
27
- pointPrice: blob.price_point,
28
- pointProduct: blob.product_point,
29
- pointProfessional: blob.professional_point,
30
- like: blob.like,
31
- report: blob.report,
32
- helpful: blob.helpful,
33
- recommend: blob.recommend,
34
- user: blob.user ? createUser(blob.user) : null,
35
- salon: blob.salon ? createSalon(blob.salon) : null,
36
- stylist: blob.stylist && blob.stylist.user ? createStylist(blob.stylist) : null,
37
- photos: reviewPhotos.map(createReviewPhoto),
38
- };
39
- }
@@ -1,58 +0,0 @@
1
- import { Colors } from '../constants/colors';
2
- import { defaultImage } from './common';
3
- export var BusinessHourStatus;
4
- (function (BusinessHourStatus) {
5
- BusinessHourStatus[BusinessHourStatus["Open"] = 0] = "Open";
6
- BusinessHourStatus[BusinessHourStatus["Close"] = 1] = "Close";
7
- BusinessHourStatus[BusinessHourStatus["ByAppointment"] = 2] = "ByAppointment";
8
- })(BusinessHourStatus || (BusinessHourStatus = {}));
9
- export function createSalon(blob) {
10
- const geoLocations = blob.salon_geolocation || [];
11
- let salonImages = [];
12
- if (blob.salon_miniwebsite) {
13
- const activeSite = Array.isArray(blob.salon_miniwebsite) ? blob.salon_miniwebsite[0] : (blob.salon_miniwebsite || {});
14
- salonImages = [
15
- activeSite.full_small_slider_img1,
16
- activeSite.full_small_slider_img2,
17
- activeSite.full_small_slider_img3,
18
- ].filter(image => !!image);
19
- }
20
- return {
21
- id: blob.id,
22
- about: blob.about,
23
- email: blob.email,
24
- ownerName: blob.owner_name,
25
- fullProfileImage: blob.full_profile_image,
26
- fullCoverImage: blob.full_cover_image,
27
- subdomain: blob.subdomain,
28
- website: blob.website,
29
- businessName: blob.business_name,
30
- businessPhone: blob.business_phone,
31
- businessAddress: blob.business_address,
32
- businessLocationLat: geoLocations.length > 0 ? geoLocations[0].location_lat : null,
33
- businessLocationLng: geoLocations.length > 0 ? geoLocations[0].location_lng : null,
34
- city: blob.city,
35
- state: blob.state,
36
- zipcode: blob.zipcode ? Number(blob.zipcode) : null,
37
- businessHours: (blob.business_hours || blob.salon_working_time || []).map(bh => {
38
- return {
39
- dayName: bh.day_name,
40
- openTime: bh.open_time,
41
- closeTime: bh.close_time,
42
- status: bh.status,
43
- };
44
- }),
45
- rating: Number(blob.rating_point),
46
- primaryColor: blob.primary_color || Colors.Primary,
47
- salonImages,
48
- };
49
- }
50
- export function getSalonImage({ salonImages, fullProfileImage }) {
51
- if (salonImages && salonImages.length > 0) {
52
- return salonImages[0];
53
- }
54
- if (fullProfileImage) {
55
- return fullProfileImage;
56
- }
57
- return defaultImage;
58
- }
@@ -1,24 +0,0 @@
1
- export function createService(blob) {
2
- const photos = (blob.photo_link || []).map(photo => {
3
- return {
4
- id: photo.number,
5
- src: photo.src,
6
- caption: photo.caption,
7
- serviceId: photo.service_id,
8
- serviceName: photo.service_name,
9
- stylistId: photo.beautician_id,
10
- stylistName: photo.beautician_name,
11
- };
12
- });
13
- return {
14
- id: blob.id,
15
- name: blob.name,
16
- description: blob.description,
17
- price: Number(blob.price_info),
18
- isPriceUp: Boolean(blob.price_up),
19
- hidePrice: Boolean(blob.hide_price_from_public),
20
- duration: blob.time_info ? Number(blob.time_info) : 0,
21
- hideDuration: Boolean(blob.hide_duration_from_public),
22
- photos,
23
- };
24
- }
@@ -1,128 +0,0 @@
1
- import dayjs from 'dayjs';
2
- import { dateTimeFormat } from './common';
3
- import { createSalon } from './salon';
4
- import { createService } from './service';
5
- import { createStylistFromLookbook } from './stylist';
6
- import { createUser } from './user';
7
- export var MediaType;
8
- (function (MediaType) {
9
- MediaType[MediaType["Photo"] = 0] = "Photo";
10
- MediaType[MediaType["Video"] = 1] = "Video";
11
- })(MediaType || (MediaType = {}));
12
- export class AlbumMedia {
13
- constructor(fields) {
14
- Object.assign(this, fields);
15
- }
16
- }
17
- export function createAlbumMedia(blob) {
18
- const [createdDay, createdTime] = blob.create_date ? String(blob.create_date).split(' ') : [];
19
- const createdDateTime = createdDay && createdTime ? dayjs(`${createdDay} ${createdTime}`, dateTimeFormat).valueOf() : null;
20
- const [updatedDay, updatedTime] = blob.update_date ? String(blob.update_date).split(' ') : [];
21
- const updatedDateTime = updatedDay && updatedTime ? dayjs(`${updatedDay} ${updatedTime}`, dateTimeFormat).valueOf() : null;
22
- const isVideo = blob.media_type === MediaType.Video || blob.full_image_url.indexOf('.mp4') > -1;
23
- return new AlbumMedia({
24
- id: blob.id,
25
- caption: blob.caption,
26
- description: blob.description,
27
- createdDate: createdDateTime,
28
- updatedDate: updatedDateTime,
29
- mediaUrl: blob.full_image_url,
30
- imageThumb: !isVideo ? blob.full_image_url_thumb : null,
31
- imageThumbMedium: !isVideo ? blob.full_image_url_medium : null,
32
- imageWidth: !isVideo ? blob.img_w : 400,
33
- imageHeight: !isVideo ? blob.img_h : 300,
34
- mediaType: isVideo ? MediaType.Video : blob.media_type,
35
- totalLike: blob.total_like,
36
- totalDislike: blob.total_dislike,
37
- totalShare: blob.total_shared,
38
- totalView: blob.view_count,
39
- totalBooking: blob.total_booking,
40
- });
41
- }
42
- export class Album {
43
- constructor(fields) {
44
- Object.assign(this, fields);
45
- }
46
- }
47
- export function createAlbum(blob) {
48
- return new Album({
49
- id: blob.id,
50
- name: blob.name,
51
- caption: blob.caption,
52
- description: blob.description,
53
- tags: blob.tags ? blob.tags.filter(tag => !!tag) : [],
54
- salonId: blob.salon_id,
55
- stylistId: blob.stylist_id,
56
- totalMedias: blob.total_medias || 0,
57
- service: blob.service ? createService(blob.service) : null,
58
- isPublic: (typeof blob.is_public !== 'undefined') ? Boolean(blob.is_public) : true,
59
- });
60
- }
61
- export class FaveStyleComment {
62
- constructor(fields) {
63
- Object.assign(this, fields);
64
- }
65
- }
66
- export function createFaveStyleComment(blob) {
67
- const [createdDay, createdTime] = blob.create_date ? String(blob.create_date).split(' ') : [];
68
- const createdDateTime = createdDay && createdTime ? dayjs(`${createdDay} ${createdTime}`, dateTimeFormat).valueOf() : null;
69
- const [updatedDay, updatedTime] = blob.update_date ? String(blob.update_date).split(' ') : [];
70
- const updatedDateTime = updatedDay && updatedTime ? dayjs(`${updatedDay} ${updatedTime}`, dateTimeFormat).valueOf() : null;
71
- return new FaveStyleComment({
72
- id: blob.id,
73
- type: blob.type,
74
- title: blob.content,
75
- description: blob.description,
76
- createdDate: createdDateTime,
77
- updatedDate: updatedDateTime,
78
- parentCommentId: blob.parentCommentId,
79
- childComments: blob.child_comment ? blob.child_comment.map(createFaveStyleComment) : [],
80
- user: createUser(blob.user),
81
- });
82
- }
83
- export class FaveStyle {
84
- constructor(fields) {
85
- Object.assign(this, fields);
86
- }
87
- }
88
- export function createFaveStyle(blob) {
89
- const [createdDay, createdTime] = blob.create_date ? String(blob.create_date).split(' ') : [];
90
- const createdDateTime = createdDay && createdTime ? dayjs(`${createdDay} ${createdTime}`, dateTimeFormat).valueOf() : null;
91
- const [updatedDay, updatedTime] = blob.update_date ? String(blob.update_date).split(' ') : [];
92
- const updatedDateTime = updatedDay && updatedTime ? dayjs(`${updatedDay} ${updatedTime}`, dateTimeFormat).valueOf() : null;
93
- const albumMedias = [createAlbumMedia(blob)].concat(blob.album_medias ? blob.album_medias.map(createAlbumMedia).filter(ap => ap.id !== blob.id) : []);
94
- const { total_booked: totalBooked, total_like: totalLike, total_share: totalShare, total_view: totalView, } = blob.style_activity || {};
95
- return new FaveStyle({
96
- id: blob.id,
97
- caption: blob.caption,
98
- description: blob.description,
99
- createdDate: createdDateTime,
100
- updatedDate: updatedDateTime,
101
- imageUrl: blob.full_image_url,
102
- imageThumb: blob.full_image_url_thumb,
103
- imageThumbMedium: blob.full_image_url_medium,
104
- imageWidth: blob.img_w,
105
- imageHeight: blob.img_h,
106
- mediaType: blob.media_type,
107
- isPublic: (typeof blob.is_public !== 'undefined') ? Boolean(blob.is_public) : true,
108
- totalBooking: totalBooked || 0,
109
- totalLike: totalLike || 0,
110
- totalDislike: blob.total_dislike || 0,
111
- totalShare: totalShare || 0,
112
- totalView: totalView || 0,
113
- albumMedias,
114
- album: blob.album ? createAlbum(blob.album) : null,
115
- owner: blob.user ? createUser(blob.user) : null,
116
- salonId: blob.salon_id ? Number(blob.salon_id) : null,
117
- salon: blob.salon ? createSalon(blob.salon) : null,
118
- stylistId: blob.stylist_id ? Number(blob.stylist_id) : null,
119
- stylist: blob.stylist ? createStylistFromLookbook(blob.stylist) : null,
120
- isLiked: blob.my_activity && blob.my_activity.liked,
121
- serviceId: blob.service_id ? Number(blob.service_id) : null,
122
- salonServiceId: blob.category_service_id ? Number(blob.category_service_id) : null,
123
- productBrand: blob.product_brand_used || '',
124
- });
125
- }
126
- export function isVideoMedia({ mediaType }) {
127
- return mediaType === MediaType.Video;
128
- }
@@ -1,30 +0,0 @@
1
- export function createStylist(blob) {
2
- const ratingPercentage = blob.rating_percent ? Number(blob.rating_percent) : 0;
3
- const { first_name, last_name, mobile_phone, avatar, full_profile_image, } = blob.user || {};
4
- const userNames = [first_name, last_name].filter(name => !!name);
5
- return {
6
- id: Number(blob.id),
7
- firstName: first_name,
8
- lastName: last_name,
9
- fullName: userNames.length > 0 ? userNames.join(' ') : blob.email,
10
- avatar: avatar || full_profile_image,
11
- phone: mobile_phone,
12
- expertise: Boolean(blob.expertise),
13
- rating: Math.ceil((ratingPercentage * 5) / 100),
14
- };
15
- }
16
- export function createStylistFromLookbook(blob) {
17
- const { user } = blob;
18
- const ratingPercentage = blob.rating_percent ? Number(blob.rating_percent) : 0;
19
- const userNames = [user.first_name, user.last_name].filter(name => !!name);
20
- return {
21
- id: Number(blob.id),
22
- firstName: user.first_name,
23
- lastName: user.last_name,
24
- fullName: userNames.length > 0 ? userNames.join(' ') : (blob.fullName || blob.name || blob.title),
25
- avatar: user.full_avatar || user.full_profile_image_thumb,
26
- phone: user.mobile_phone,
27
- expertise: Boolean(blob.expertise),
28
- rating: Math.ceil((ratingPercentage * 5) / 100),
29
- };
30
- }
@@ -1,10 +0,0 @@
1
- export function createUser(blob) {
2
- const userNames = [blob.first_name, blob.last_name].filter(name => !!name);
3
- return {
4
- id: blob.id || blob.user_id,
5
- firstName: blob.first_name,
6
- lastName: blob.last_name,
7
- fullName: userNames.length > 0 ? userNames.join(' ') : (blob.fullName || blob.name || blob.username),
8
- avatar: blob.avatar || blob.full_profile_image_thumb,
9
- };
10
- }