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