@sprucelabs/spruce-people-utils 6.0.1 → 6.0.3
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.
@@ -12,7 +12,8 @@ class SpyInviteInviteViewController extends InvitePersonCard_vc_1.default {
|
|
12
12
|
return this.organizationId;
|
13
13
|
}
|
14
14
|
async clickDone(personId) {
|
15
|
-
|
15
|
+
var _a;
|
16
|
+
await ((_a = this.doneHandler) === null || _a === void 0 ? void 0 : _a.call(this, personId));
|
16
17
|
}
|
17
18
|
}
|
18
19
|
exports.default = SpyInviteInviteViewController;
|
@@ -31,20 +31,13 @@ const schema_1 = require("@sprucelabs/schema");
|
|
31
31
|
const InvitePersonCard_vc_1 = __importDefault(require("../inviting/InvitePersonCard.vc"));
|
32
32
|
const searchPeopleToSuggestions_1 = __importStar(require("./searchPeopleToSuggestions"));
|
33
33
|
class PersonSelectInputViewController extends heartwood_view_controllers_1.AbstractViewController {
|
34
|
-
static id = 'person-select-input';
|
35
|
-
autoCompleteVc;
|
36
|
-
organizationId;
|
37
|
-
locationId;
|
38
|
-
shouldIgnoreNextChange = false;
|
39
|
-
lastLoadedPersonId;
|
40
|
-
shouldAllowAddAnonymous;
|
41
|
-
loadingPromise;
|
42
34
|
constructor(options) {
|
43
35
|
super(options);
|
36
|
+
this.shouldIgnoreNextChange = false;
|
44
37
|
const { organizationId, locationId, shouldAllowAddAnonymous } = options;
|
45
38
|
this.organizationId = organizationId;
|
46
39
|
this.locationId = locationId;
|
47
|
-
this.shouldAllowAddAnonymous = shouldAllowAddAnonymous
|
40
|
+
this.shouldAllowAddAnonymous = shouldAllowAddAnonymous !== null && shouldAllowAddAnonymous !== void 0 ? shouldAllowAddAnonymous : true;
|
48
41
|
this.autoCompleteVc = this.Controller('autocompleteInput', {
|
49
42
|
...options,
|
50
43
|
onChangeRenderedValue: this.handleOnChangeRenderedValue.bind(this),
|
@@ -104,7 +97,8 @@ class PersonSelectInputViewController extends heartwood_view_controllers_1.Abstr
|
|
104
97
|
}
|
105
98
|
}
|
106
99
|
isErrorUnauthorized(err) {
|
107
|
-
|
100
|
+
var _a;
|
101
|
+
return ((_a = err === null || err === void 0 ? void 0 : err.options) === null || _a === void 0 ? void 0 : _a.code) === 'UNAUTHORIZED_ACCESS';
|
108
102
|
}
|
109
103
|
setHandlers(options) {
|
110
104
|
this.autoCompleteVc.setHandlers(options);
|
@@ -232,4 +226,5 @@ class PersonSelectInputViewController extends heartwood_view_controllers_1.Abstr
|
|
232
226
|
return this.autoCompleteVc.render();
|
233
227
|
}
|
234
228
|
}
|
229
|
+
PersonSelectInputViewController.id = 'person-select-input';
|
235
230
|
exports.default = PersonSelectInputViewController;
|
@@ -9,11 +9,12 @@ function searchPersonToSuggestion(person, cb) {
|
|
9
9
|
return {
|
10
10
|
id: person.id,
|
11
11
|
label: renderLabel(person),
|
12
|
-
onClick: () => cb
|
12
|
+
onClick: () => cb === null || cb === void 0 ? void 0 : cb(person),
|
13
13
|
};
|
14
14
|
}
|
15
15
|
exports.searchPersonToSuggestion = searchPersonToSuggestion;
|
16
16
|
function renderLabel(p) {
|
17
|
-
|
17
|
+
var _a;
|
18
|
+
return `${(_a = p.fullName) !== null && _a !== void 0 ? _a : 'friend'} (${p.phone})`;
|
18
19
|
}
|
19
20
|
exports.renderLabel = renderLabel;
|
@@ -4,21 +4,9 @@ const heartwood_view_controllers_1 = require("@sprucelabs/heartwood-view-control
|
|
4
4
|
const schema_1 = require("@sprucelabs/schema");
|
5
5
|
const inviteCardHeaders_1 = require("./inviteCardHeaders");
|
6
6
|
class InvitePersonCardViewController extends heartwood_view_controllers_1.AbstractViewController {
|
7
|
-
static id = 'invite-person-card';
|
8
|
-
swipeVc;
|
9
|
-
organizationId;
|
10
|
-
locationId;
|
11
|
-
formVc;
|
12
|
-
waitingTalkingVc;
|
13
|
-
successTalkingVc;
|
14
|
-
pendingInvite;
|
15
|
-
doneHandler;
|
16
|
-
isLoaded = false;
|
17
|
-
client;
|
18
|
-
invitedPersonId;
|
19
|
-
startingPhone;
|
20
7
|
constructor(options) {
|
21
8
|
super(options);
|
9
|
+
this.isLoaded = false;
|
22
10
|
const required = [];
|
23
11
|
if (!options.locationId) {
|
24
12
|
required.push('organizationId');
|
@@ -106,7 +94,7 @@ class InvitePersonCardViewController extends heartwood_view_controllers_1.Abstra
|
|
106
94
|
case 1:
|
107
95
|
this.waitingTalkingVc.setSentences([
|
108
96
|
{
|
109
|
-
words: `Tell ${name
|
97
|
+
words: `Tell ${name !== null && name !== void 0 ? name : 'your new friend'} to check their phone and to click the link I just sent!`,
|
110
98
|
},
|
111
99
|
]);
|
112
100
|
await this.waitingTalkingVc.play();
|
@@ -114,7 +102,7 @@ class InvitePersonCardViewController extends heartwood_view_controllers_1.Abstra
|
|
114
102
|
case 2:
|
115
103
|
this.successTalkingVc.setSentences([
|
116
104
|
{
|
117
|
-
words: `${name
|
105
|
+
words: `${name !== null && name !== void 0 ? name : 'Your friend'} has accepted your invite! Lets go! 👇`,
|
118
106
|
},
|
119
107
|
]);
|
120
108
|
await this.successTalkingVc.play();
|
@@ -141,16 +129,18 @@ class InvitePersonCardViewController extends heartwood_view_controllers_1.Abstra
|
|
141
129
|
}
|
142
130
|
}
|
143
131
|
async handleClickDone() {
|
144
|
-
|
132
|
+
var _a;
|
133
|
+
await ((_a = this.doneHandler) === null || _a === void 0 ? void 0 : _a.call(this, this.invitedPersonId));
|
145
134
|
}
|
146
135
|
async handleClickBack() {
|
147
136
|
this.pendingInvite = undefined;
|
148
137
|
await this.swipeVc.jumpToSlide(0);
|
149
138
|
}
|
150
139
|
updateHeader() {
|
140
|
+
var _a, _b;
|
151
141
|
const header = inviteCardHeaders_1.inviteCardHeaders[this.slideIdx];
|
152
|
-
this.swipeVc.setHeaderTitle(header.title
|
153
|
-
this.swipeVc.setHeaderSubtitle(header.subtitle
|
142
|
+
this.swipeVc.setHeaderTitle((_a = header.title) !== null && _a !== void 0 ? _a : null);
|
143
|
+
this.swipeVc.setHeaderSubtitle((_b = header.subtitle) !== null && _b !== void 0 ? _b : null);
|
154
144
|
}
|
155
145
|
get slideIdx() {
|
156
146
|
return this.swipeVc.getPresentSlide();
|
@@ -175,6 +165,7 @@ class InvitePersonCardViewController extends heartwood_view_controllers_1.Abstra
|
|
175
165
|
return super.destroy();
|
176
166
|
}
|
177
167
|
async handleSubmitNamePhoneForm() {
|
168
|
+
var _a, _b;
|
178
169
|
this.swipeVc.setIsBusy(true);
|
179
170
|
await this.swipeVc.jumpToSlide(1);
|
180
171
|
try {
|
@@ -194,12 +185,12 @@ class InvitePersonCardViewController extends heartwood_view_controllers_1.Abstra
|
|
194
185
|
},
|
195
186
|
});
|
196
187
|
if (invite.autoAcceptedPersonId) {
|
197
|
-
return this.doneHandler
|
188
|
+
return (_a = this.doneHandler) === null || _a === void 0 ? void 0 : _a.call(this, invite.autoAcceptedPersonId);
|
198
189
|
}
|
199
190
|
this.pendingInvite = invite;
|
200
191
|
}
|
201
192
|
catch (err) {
|
202
|
-
console.error(err.stack
|
193
|
+
console.error((_b = err.stack) !== null && _b !== void 0 ? _b : err.message);
|
203
194
|
await this.alert({ title: 'Invite failed!', message: err.message });
|
204
195
|
await this.swipeVc.jumpToSlide(0);
|
205
196
|
}
|
@@ -218,7 +209,8 @@ class InvitePersonCardViewController extends heartwood_view_controllers_1.Abstra
|
|
218
209
|
return this.handleDidAcceptInvite(payload.inviteId, payload.personId);
|
219
210
|
}
|
220
211
|
async handleDidAcceptInvite(inviteId, personId) {
|
221
|
-
|
212
|
+
var _a;
|
213
|
+
if (((_a = this.pendingInvite) === null || _a === void 0 ? void 0 : _a.id) === inviteId) {
|
222
214
|
await this.swipeVc.jumpToSlide(2);
|
223
215
|
this.invitedPersonId = personId;
|
224
216
|
this.updateFooter();
|
@@ -228,6 +220,7 @@ class InvitePersonCardViewController extends heartwood_view_controllers_1.Abstra
|
|
228
220
|
return this.swipeVc.render();
|
229
221
|
}
|
230
222
|
}
|
223
|
+
InvitePersonCardViewController.id = 'invite-person-card';
|
231
224
|
exports.default = InvitePersonCardViewController;
|
232
225
|
const inviteFormSchema = (0, schema_1.buildSchema)({
|
233
226
|
id: 'inviteForm',
|