favesalon-embed 1.0.3 → 1.0.4

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 (161) hide show
  1. package/dist/{favesalon-embed/_commonjsHelpers-9bc404fc.js → cjs/_commonjsHelpers-5cfcba41.js} +6 -14
  2. package/dist/cjs/chat-box_5.cjs.entry.js +17439 -0
  3. package/dist/cjs/chat-button.cjs.entry.js +55 -0
  4. package/dist/cjs/colors-38421769.js +69 -0
  5. package/dist/cjs/favesalon-embed.cjs.js +23 -0
  6. package/dist/cjs/google-map.cjs.entry.js +52 -0
  7. package/dist/{favesalon-embed/index-ac52896a.js → cjs/index-7f190886.js} +47 -454
  8. package/dist/cjs/index-dd8176c4.js +1531 -0
  9. package/dist/cjs/index.cjs.js +2 -0
  10. package/dist/cjs/loader.cjs.js +22 -0
  11. package/dist/cjs/relativeTime-3721080d.js +9 -0
  12. package/dist/cjs/salon-booking-modal.cjs.entry.js +30 -0
  13. package/dist/cjs/salon-booking.cjs.entry.js +51 -0
  14. package/dist/cjs/salon-gift-card-modal.cjs.entry.js +29 -0
  15. package/dist/cjs/salon-gift-card.cjs.entry.js +51 -0
  16. package/dist/cjs/salon-info.cjs.entry.js +33 -0
  17. package/dist/cjs/salon-latest-reviews.cjs.entry.js +97 -0
  18. package/dist/cjs/salon-latest-styles_3.cjs.entry.js +241 -0
  19. package/dist/cjs/salon-lookbook.cjs.entry.js +222 -0
  20. package/dist/cjs/salon-ranking.cjs.entry.js +60 -0
  21. package/dist/cjs/salon-reviews.cjs.entry.js +193 -0
  22. package/dist/cjs/salon-services.cjs.entry.js +81 -0
  23. package/dist/cjs/salon-stylists.cjs.entry.js +118 -0
  24. package/dist/{favesalon-embed/services-7cb8f2a6.js → cjs/services-d1bdf299.js} +55 -2415
  25. package/dist/cjs/style-detail.cjs.entry.js +312 -0
  26. package/dist/cjs/utils-c5a33b3c.js +23 -0
  27. package/dist/collection/collection-manifest.json +33 -0
  28. package/dist/collection/components/chat-box/index.css +105 -0
  29. package/dist/collection/components/chat-box/index.js +138 -0
  30. package/dist/collection/components/chat-button/index.css +101 -0
  31. package/dist/collection/components/chat-button/index.js +155 -0
  32. package/dist/collection/components/chat-form/index.css +40 -0
  33. package/dist/collection/components/chat-form/index.js +79 -0
  34. package/dist/collection/components/chat-messages/index.css +48 -0
  35. package/dist/collection/components/chat-messages/index.js +142 -0
  36. package/dist/collection/components/chat-rooms/index.css +102 -0
  37. package/dist/collection/components/chat-rooms/index.js +157 -0
  38. package/dist/collection/components/google-map/assets/map--placeholder.jpeg +0 -0
  39. package/dist/collection/components/google-map/index.css +5 -0
  40. package/dist/collection/components/google-map/index.js +90 -0
  41. package/dist/collection/components/salon-booking/index.css +30 -0
  42. package/dist/collection/components/salon-booking/index.js +126 -0
  43. package/dist/collection/components/salon-booking/salon-booking-modal.js +92 -0
  44. package/dist/collection/components/salon-gift-card/index.css +30 -0
  45. package/dist/collection/components/salon-gift-card/index.js +126 -0
  46. package/dist/collection/components/salon-gift-card/salon-gift-card-modal.js +73 -0
  47. package/dist/collection/components/salon-info/index.css +1 -0
  48. package/dist/collection/components/salon-info/index.js +77 -0
  49. package/dist/collection/components/salon-latest-reviews/index.css +11 -0
  50. package/dist/collection/components/salon-latest-reviews/index.js +163 -0
  51. package/dist/collection/components/salon-latest-styles/index.css +12 -0
  52. package/dist/{favesalon-embed/salon-latest-styles.entry.js → collection/components/salon-latest-styles/index.js} +99 -14
  53. package/dist/collection/components/salon-locations/index.css +24 -0
  54. package/dist/{favesalon-embed/salon-locations.entry.js → collection/components/salon-locations/index.js} +95 -15
  55. package/dist/collection/components/salon-lookbook/index.css +15 -0
  56. package/dist/collection/components/salon-lookbook/index.js +368 -0
  57. package/dist/collection/components/salon-ranking/index.css +3 -0
  58. package/dist/collection/components/salon-ranking/index.js +117 -0
  59. package/dist/collection/components/salon-reviews/index.css +18 -0
  60. package/dist/collection/components/salon-reviews/index.js +249 -0
  61. package/dist/collection/components/salon-schedules/index.css +18 -0
  62. package/dist/{favesalon-embed/salon-schedules.entry.js → collection/components/salon-schedules/index.js} +95 -14
  63. package/dist/collection/components/salon-services/index.css +1 -0
  64. package/dist/collection/components/salon-services/index.js +146 -0
  65. package/dist/collection/components/salon-stylists/index.css +43 -0
  66. package/dist/collection/components/salon-stylists/index.js +184 -0
  67. package/dist/collection/components/style-detail/index.css +76 -0
  68. package/dist/collection/components/style-detail/index.js +386 -0
  69. package/dist/collection/components/user-avatar/index.css +0 -0
  70. package/dist/collection/components/user-avatar/index.js +159 -0
  71. package/dist/collection/constants/colors.js +65 -0
  72. package/dist/collection/global/global.js +0 -0
  73. package/dist/collection/index.js +1 -0
  74. package/dist/collection/mocks/users.js +10 -0
  75. package/dist/collection/services/services.js +295 -0
  76. package/dist/collection/types/chat.js +23 -0
  77. package/dist/collection/types/common.js +11 -0
  78. package/dist/collection/types/review.js +39 -0
  79. package/dist/collection/types/salon.js +58 -0
  80. package/dist/collection/types/service.js +24 -0
  81. package/dist/collection/types/style.js +128 -0
  82. package/dist/collection/types/stylist.js +30 -0
  83. package/dist/collection/types/user.js +10 -0
  84. package/dist/collection/utils/utils.js +23 -0
  85. package/dist/custom-elements/index.js +44974 -0
  86. package/dist/{favesalon-embed/_commonjsHelpers-a4f66ccd.js → esm/_commonjsHelpers-66ac50f5.js} +2 -14
  87. package/dist/{favesalon-embed/chat-rooms.entry.js → esm/chat-box_5.entry.js} +182 -30
  88. package/dist/{favesalon-embed → esm}/chat-button.entry.js +3 -3
  89. package/dist/esm/favesalon-embed.js +18 -0
  90. package/dist/{favesalon-embed → esm}/google-map.entry.js +1 -1
  91. package/dist/esm/index-0494771f.js +1504 -0
  92. package/dist/{favesalon-embed/index-00b83e1c.js → esm/index-a1c7583c.js} +15 -425
  93. package/dist/esm/index.js +1 -0
  94. package/dist/esm/loader.js +18 -0
  95. package/dist/esm/polyfills/core-js.js +11 -0
  96. package/dist/esm/polyfills/css-shim.js +1 -0
  97. package/dist/esm/polyfills/dom.js +79 -0
  98. package/dist/esm/polyfills/es5-html-element.js +1 -0
  99. package/dist/esm/polyfills/index.js +34 -0
  100. package/dist/esm/polyfills/system.js +6 -0
  101. package/dist/esm/relativeTime-baa50aa2.js +7 -0
  102. package/dist/{favesalon-embed → esm}/salon-booking-modal.entry.js +1 -1
  103. package/dist/{favesalon-embed → esm}/salon-booking.entry.js +3 -3
  104. package/dist/{favesalon-embed → esm}/salon-gift-card-modal.entry.js +1 -1
  105. package/dist/{favesalon-embed → esm}/salon-gift-card.entry.js +3 -3
  106. package/dist/{favesalon-embed → esm}/salon-info.entry.js +3 -3
  107. package/dist/{favesalon-embed → esm}/salon-latest-reviews.entry.js +4 -4
  108. package/dist/esm/salon-latest-styles_3.entry.js +235 -0
  109. package/dist/{favesalon-embed → esm}/salon-lookbook.entry.js +3 -3
  110. package/dist/{favesalon-embed → esm}/salon-ranking.entry.js +1 -1
  111. package/dist/{favesalon-embed → esm}/salon-reviews.entry.js +3 -3
  112. package/dist/{favesalon-embed → esm}/salon-services.entry.js +3 -3
  113. package/dist/{favesalon-embed → esm}/salon-stylists.entry.js +3 -3
  114. package/dist/{favesalon-embed/services-7c46a2fd.js → esm/services-257442e2.js} +99 -2467
  115. package/dist/{favesalon-embed → esm}/style-detail.entry.js +4 -4
  116. package/dist/{favesalon-embed/utils-2c19db45.js → esm/utils-e97485e0.js} +0 -6
  117. package/dist/favesalon-embed/favesalon-embed.css +1 -2439
  118. package/dist/favesalon-embed/favesalon-embed.esm.js +1 -148
  119. package/dist/favesalon-embed/index.esm.js +0 -1
  120. package/dist/favesalon-embed/p-05a1c88a.entry.js +1 -0
  121. package/dist/favesalon-embed/p-0acf0447.entry.js +1 -0
  122. package/dist/favesalon-embed/p-0bc4f624.js +1 -0
  123. package/dist/favesalon-embed/p-1af1515f.entry.js +1 -0
  124. package/dist/favesalon-embed/p-1cba5fc9.entry.js +1 -0
  125. package/dist/favesalon-embed/p-39a4ef15.entry.js +1 -0
  126. package/dist/favesalon-embed/p-3e2cb05b.entry.js +1 -0
  127. package/dist/favesalon-embed/p-47e646f8.js +1 -0
  128. package/dist/favesalon-embed/p-487b311f.entry.js +1 -0
  129. package/dist/favesalon-embed/p-55387c2f.entry.js +1 -0
  130. package/dist/favesalon-embed/p-566f05b4.entry.js +1 -0
  131. package/dist/favesalon-embed/p-862a0de0.entry.js +1 -0
  132. package/dist/favesalon-embed/p-9fe0cbeb.js +2 -0
  133. package/dist/favesalon-embed/p-a33331cc.js +1 -0
  134. package/dist/favesalon-embed/p-aeeb7b5f.entry.js +1 -0
  135. package/dist/favesalon-embed/p-b08e5b54.js +6 -0
  136. package/dist/favesalon-embed/p-b5cca5fc.entry.js +1 -0
  137. package/dist/favesalon-embed/p-c7fb7af5.js +1580 -0
  138. package/dist/favesalon-embed/p-ccab56d8.js +1 -0
  139. package/dist/favesalon-embed/p-d6e13053.entry.js +1 -0
  140. package/dist/favesalon-embed/p-dee42d34.entry.js +1 -0
  141. package/dist/favesalon-embed/p-e661ca1d.entry.js +1 -0
  142. package/dist/favesalon-embed/p-eeceab9c.entry.js +1 -0
  143. package/dist/index.cjs.js +1 -0
  144. package/dist/index.js +1 -0
  145. package/package.json +1 -1
  146. package/dist/favesalon-embed/app-globals-437cc3f3.js +0 -712
  147. package/dist/favesalon-embed/app-globals-60769a2c.js +0 -712
  148. package/dist/favesalon-embed/chat-box.entry.js +0 -54
  149. package/dist/favesalon-embed/chat-form.entry.js +0 -39
  150. package/dist/favesalon-embed/chat-messages.entry.js +0 -53
  151. package/dist/favesalon-embed/css-shim-b7d3d95f.js +0 -4
  152. package/dist/favesalon-embed/dom-64053c71.js +0 -73
  153. package/dist/favesalon-embed/index-04c09911.js +0 -3371
  154. package/dist/favesalon-embed/index-888e99e3.js +0 -3371
  155. package/dist/favesalon-embed/isObject-13b86c17.js +0 -203
  156. package/dist/favesalon-embed/relativeTime-15477f02.js +0 -7
  157. package/dist/favesalon-embed/relativeTime-268e64b0.js +0 -7
  158. package/dist/favesalon-embed/services-55a87166.js +0 -23655
  159. package/dist/favesalon-embed/shadow-css-98135883.js +0 -387
  160. package/dist/favesalon-embed/user-avatar.entry.js +0 -50
  161. /package/dist/{favesalon-embed → esm}/colors-ea36347a.js +0 -0
@@ -0,0 +1,159 @@
1
+ import { h } from '@stencil/core';
2
+ import { Colors } from '../../constants/colors';
3
+ export class UserAvatar {
4
+ constructor() {
5
+ this.size = 24;
6
+ this.name = undefined;
7
+ this.description = undefined;
8
+ this.nameStyle = undefined;
9
+ this.shortName = undefined;
10
+ this.avatar = undefined;
11
+ }
12
+ render() {
13
+ return (h("div", { style: { display: "flex", alignItems: "center" } }, this.avatar && (h("div", { style: {
14
+ border: `1px solid ${Colors.White}`,
15
+ backgroundImage: `url("${this.avatar}")`,
16
+ backgroundColor: Colors.Gray01,
17
+ backgroundPosition: 'center center',
18
+ backgroundSize: 'cover',
19
+ borderRadius: '50%',
20
+ height: `${this.size}px`,
21
+ width: `${this.size}px`,
22
+ minWidth: `${this.size}px`,
23
+ } })), !this.avatar && (h("div", { style: {
24
+ border: `1px solid ${Colors.White}`,
25
+ backgroundColor: Colors.Gray01,
26
+ borderRadius: '50%',
27
+ display: 'flex',
28
+ alignItems: 'center',
29
+ justifyContent: 'center',
30
+ height: `${this.size}px`,
31
+ width: `${this.size}px`,
32
+ minWidth: `${this.size}px`,
33
+ } }, this.shortName)), this.name && (h("div", { style: {
34
+ flexShrink: '1',
35
+ flexGrow: '1',
36
+ marginLeft: '12px',
37
+ overflow: 'hidden',
38
+ whiteSpace: 'nowrap',
39
+ textOverflow: 'ellipsis',
40
+ } }, h("div", { style: Object.assign({}, this.nameStyle) }, this.name), this.description && h("div", { style: { color: '#999999' } }, this.description)))));
41
+ }
42
+ static get is() { return "user-avatar"; }
43
+ static get originalStyleUrls() {
44
+ return {
45
+ "$": ["index.css"]
46
+ };
47
+ }
48
+ static get styleUrls() {
49
+ return {
50
+ "$": ["index.css"]
51
+ };
52
+ }
53
+ static get properties() {
54
+ return {
55
+ "size": {
56
+ "type": "number",
57
+ "mutable": false,
58
+ "complexType": {
59
+ "original": "number",
60
+ "resolved": "number",
61
+ "references": {}
62
+ },
63
+ "required": false,
64
+ "optional": false,
65
+ "docs": {
66
+ "tags": [],
67
+ "text": ""
68
+ },
69
+ "attribute": "size",
70
+ "reflect": false,
71
+ "defaultValue": "24"
72
+ },
73
+ "name": {
74
+ "type": "string",
75
+ "mutable": false,
76
+ "complexType": {
77
+ "original": "string",
78
+ "resolved": "string",
79
+ "references": {}
80
+ },
81
+ "required": false,
82
+ "optional": true,
83
+ "docs": {
84
+ "tags": [],
85
+ "text": ""
86
+ },
87
+ "attribute": "name",
88
+ "reflect": false
89
+ },
90
+ "description": {
91
+ "type": "string",
92
+ "mutable": false,
93
+ "complexType": {
94
+ "original": "string",
95
+ "resolved": "string",
96
+ "references": {}
97
+ },
98
+ "required": false,
99
+ "optional": true,
100
+ "docs": {
101
+ "tags": [],
102
+ "text": ""
103
+ },
104
+ "attribute": "description",
105
+ "reflect": false
106
+ },
107
+ "nameStyle": {
108
+ "type": "unknown",
109
+ "mutable": false,
110
+ "complexType": {
111
+ "original": "object",
112
+ "resolved": "object",
113
+ "references": {}
114
+ },
115
+ "required": false,
116
+ "optional": true,
117
+ "docs": {
118
+ "tags": [],
119
+ "text": ""
120
+ }
121
+ },
122
+ "shortName": {
123
+ "type": "string",
124
+ "mutable": false,
125
+ "complexType": {
126
+ "original": "string",
127
+ "resolved": "string",
128
+ "references": {}
129
+ },
130
+ "required": false,
131
+ "optional": false,
132
+ "docs": {
133
+ "tags": [],
134
+ "text": ""
135
+ },
136
+ "attribute": "short-name",
137
+ "reflect": false
138
+ },
139
+ "avatar": {
140
+ "type": "string",
141
+ "mutable": false,
142
+ "complexType": {
143
+ "original": "string",
144
+ "resolved": "string",
145
+ "references": {}
146
+ },
147
+ "required": false,
148
+ "optional": false,
149
+ "docs": {
150
+ "tags": [],
151
+ "text": ""
152
+ },
153
+ "attribute": "avatar",
154
+ "reflect": false
155
+ }
156
+ };
157
+ }
158
+ }
159
+ ;
@@ -0,0 +1,65 @@
1
+ export const Colors = {
2
+ TextColor: '#141414',
3
+ Black: '#000000',
4
+ White: '#ffffff',
5
+ Primary: '#F05A61',
6
+ Secondary: '#001529',
7
+ Black01: '#262626',
8
+ Black02: '#1f1f1f',
9
+ Black03: '#141414',
10
+ Gray01: '#F5F5F5',
11
+ Gray02: '#EFEFEF',
12
+ Gray03: '#DBDBDB',
13
+ Gray04: '#999999',
14
+ Gray05: '#666666',
15
+ Red01: '#FEEFEF',
16
+ Red02: '#F9BDC0',
17
+ Red03: '#F05A61',
18
+ Red04: '#C0484E',
19
+ Red05: '#90363A',
20
+ Orange01: '#FFF4F0',
21
+ Orange02: '#FFD1C3',
22
+ Orange03: '#FF8D69',
23
+ Orange04: '#CC7154',
24
+ Orange05: '#99553F',
25
+ Yellow01: '#FDFBF4',
26
+ Yellow02: '#F8EDD3',
27
+ Yellow03: '#EED291',
28
+ Yellow04: '#BEA874',
29
+ Yellow05: '#8F7E57',
30
+ Lilac01: '#F3F0F4',
31
+ Lilac02: '#CFC1D4',
32
+ Lilac03: '#886594',
33
+ Lilac04: '#6D5176',
34
+ Lilac05: '#523D59',
35
+ Blue01: '#EAECEE',
36
+ Blue02: '#AAB1BD',
37
+ Blue03: '#2B3C59',
38
+ Blue04: '#223047',
39
+ Blue05: '#1A2435',
40
+ Green01: '#ECF7ED',
41
+ Green02: '#B2E1B9',
42
+ Green03: '#3FB34F',
43
+ Green04: '#328F3F',
44
+ Green05: '#266B2F',
45
+ Success01: '#EEF9E8',
46
+ Success02: '#BAE7A3',
47
+ Success03: '#52C41A',
48
+ Success04: '#429D15',
49
+ Success05: '#317610',
50
+ Error01: '#FFEDED',
51
+ Error02: '#FFB8B9',
52
+ Error03: '#FF4D4F',
53
+ Error04: '#CC3E3F',
54
+ Error05: '#992E2F',
55
+ Warning01: '#FFF7E8',
56
+ Warning02: '#FDDEA1',
57
+ Warning03: '#FAAD14',
58
+ Warning04: '#C88A10',
59
+ Warning05: '#96680C',
60
+ Info01: '#E8F4FF',
61
+ Info02: '#A3D3FF',
62
+ Info03: '#1890FF',
63
+ Info04: '#1373CC',
64
+ Info05: '#0E5699',
65
+ };
File without changes
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,10 @@
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
+ };
@@ -0,0 +1,295 @@
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();
@@ -0,0 +1,23 @@
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
+ }
@@ -0,0 +1,11 @@
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';
@@ -0,0 +1,39 @@
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
+ }
@@ -0,0 +1,58 @@
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
+ }
@@ -0,0 +1,24 @@
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
+ }