@sprucelabs/spruce-invite-utils 10.0.3 → 10.0.5
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.
|
@@ -4,11 +4,6 @@ const test_utils_1 = require("@sprucelabs/test-utils");
|
|
|
4
4
|
const test_utils_2 = require("@sprucelabs/test-utils");
|
|
5
5
|
const LoginAndConfirmJoinController_1 = require("../../loggingInAndConfirmingJoin/LoginAndConfirmJoinController");
|
|
6
6
|
class LoginAndConfirmTestFixture {
|
|
7
|
-
static hitCount = 0;
|
|
8
|
-
static wasBeforeEachCalled = false;
|
|
9
|
-
static lastPromptOptions;
|
|
10
|
-
static lastFactoryOptions;
|
|
11
|
-
static loginAndJoinResponse = undefined;
|
|
12
7
|
static beforeEach() {
|
|
13
8
|
this.setClass(CountingLoginAndConfirmController);
|
|
14
9
|
this.hitCount = 0;
|
|
@@ -34,9 +29,11 @@ class LoginAndConfirmTestFixture {
|
|
|
34
29
|
LoginAndConfirmJoinController_1.LoginAndConfirmJoinControllerFactory.setClass(Class);
|
|
35
30
|
}
|
|
36
31
|
}
|
|
32
|
+
LoginAndConfirmTestFixture.hitCount = 0;
|
|
33
|
+
LoginAndConfirmTestFixture.wasBeforeEachCalled = false;
|
|
34
|
+
LoginAndConfirmTestFixture.loginAndJoinResponse = undefined;
|
|
37
35
|
exports.default = LoginAndConfirmTestFixture;
|
|
38
36
|
class CountingLoginAndConfirmController {
|
|
39
|
-
auth;
|
|
40
37
|
constructor(options) {
|
|
41
38
|
LoginAndConfirmTestFixture.lastFactoryOptions = options;
|
|
42
39
|
this.auth = options.authenticator;
|
|
@@ -27,20 +27,9 @@ const heartwood_view_controllers_1 = require("@sprucelabs/heartwood-view-control
|
|
|
27
27
|
const schema_1 = require("@sprucelabs/schema");
|
|
28
28
|
const renderAcceptCardSections_1 = __importStar(require("./renderAcceptCardSections"));
|
|
29
29
|
class ConfirmJoinCardViewController extends heartwood_view_controllers_1.AbstractViewController {
|
|
30
|
-
static id = 'confirm-join-card';
|
|
31
|
-
cardVc;
|
|
32
|
-
isLoaded = false;
|
|
33
|
-
organizationId;
|
|
34
|
-
org;
|
|
35
|
-
location;
|
|
36
|
-
locationId;
|
|
37
|
-
onErrorHandler;
|
|
38
|
-
onAcceptHandler;
|
|
39
|
-
onDeclineHandler;
|
|
40
|
-
viewContext;
|
|
41
|
-
authenticator;
|
|
42
30
|
constructor(options) {
|
|
43
31
|
super(options);
|
|
32
|
+
this.isLoaded = false;
|
|
44
33
|
(0, schema_1.assertOptions)(options, [
|
|
45
34
|
'organizationId',
|
|
46
35
|
'onAccept',
|
|
@@ -94,6 +83,7 @@ class ConfirmJoinCardViewController extends heartwood_view_controllers_1.Abstrac
|
|
|
94
83
|
return this.isLoaded;
|
|
95
84
|
}
|
|
96
85
|
async load() {
|
|
86
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
97
87
|
try {
|
|
98
88
|
const client = await this.connectToApi();
|
|
99
89
|
await Promise.all([
|
|
@@ -103,9 +93,9 @@ class ConfirmJoinCardViewController extends heartwood_view_controllers_1.Abstrac
|
|
|
103
93
|
this.isLoaded = true;
|
|
104
94
|
const person = this.authenticator.getPerson();
|
|
105
95
|
const listVc = this.Controller('list', (0, renderAcceptCardSections_1.renderPermsList)({
|
|
106
|
-
firstName: person
|
|
107
|
-
lastName: person
|
|
108
|
-
phone: person
|
|
96
|
+
firstName: (_a = person === null || person === void 0 ? void 0 : person.firstName) !== null && _a !== void 0 ? _a : '',
|
|
97
|
+
lastName: (_b = person === null || person === void 0 ? void 0 : person.lastName) !== null && _b !== void 0 ? _b : '',
|
|
98
|
+
phone: (_c = person === null || person === void 0 ? void 0 : person.phone) !== null && _c !== void 0 ? _c : '',
|
|
109
99
|
onClickToggle: () => this.askForAVote({
|
|
110
100
|
featureKey: 'selectable-perms',
|
|
111
101
|
skillNamespace: 'invite',
|
|
@@ -114,9 +104,9 @@ class ConfirmJoinCardViewController extends heartwood_view_controllers_1.Abstrac
|
|
|
114
104
|
}));
|
|
115
105
|
this.cardVc.setSections([
|
|
116
106
|
...(0, renderAcceptCardSections_1.default)({
|
|
117
|
-
orgName: this.org
|
|
118
|
-
roleName: this.viewContext.roleName
|
|
119
|
-
locationAddress: this.location
|
|
107
|
+
orgName: (_e = (_d = this.org) === null || _d === void 0 ? void 0 : _d.name) !== null && _e !== void 0 ? _e : 'a company',
|
|
108
|
+
roleName: (_f = this.viewContext.roleName) !== null && _f !== void 0 ? _f : 'Guest',
|
|
109
|
+
locationAddress: (_g = this.location) === null || _g === void 0 ? void 0 : _g.address,
|
|
120
110
|
}),
|
|
121
111
|
{
|
|
122
112
|
list: listVc.render(),
|
|
@@ -126,10 +116,11 @@ class ConfirmJoinCardViewController extends heartwood_view_controllers_1.Abstrac
|
|
|
126
116
|
}
|
|
127
117
|
catch (err) {
|
|
128
118
|
await this.alert({ message: err.message });
|
|
129
|
-
await this.onErrorHandler
|
|
119
|
+
await ((_h = this.onErrorHandler) === null || _h === void 0 ? void 0 : _h.call(this, err));
|
|
130
120
|
}
|
|
131
121
|
}
|
|
132
122
|
async loadOrg(client) {
|
|
123
|
+
var _a;
|
|
133
124
|
try {
|
|
134
125
|
const [{ organization }] = await client.emitAndFlattenResponses('get-organization::v2020_12_25', {
|
|
135
126
|
target: {
|
|
@@ -139,7 +130,7 @@ class ConfirmJoinCardViewController extends heartwood_view_controllers_1.Abstrac
|
|
|
139
130
|
this.org = organization;
|
|
140
131
|
}
|
|
141
132
|
catch (err) {
|
|
142
|
-
if (err.options
|
|
133
|
+
if (((_a = err.options) === null || _a === void 0 ? void 0 : _a.code) === 'UNAUTHORIZED_ACCESS') {
|
|
143
134
|
this.org = {
|
|
144
135
|
id: this.organizationId,
|
|
145
136
|
dateCreated: 0,
|
|
@@ -153,6 +144,7 @@ class ConfirmJoinCardViewController extends heartwood_view_controllers_1.Abstrac
|
|
|
153
144
|
}
|
|
154
145
|
}
|
|
155
146
|
async optionallyLoadLocation(client) {
|
|
147
|
+
var _a;
|
|
156
148
|
if (this.locationId) {
|
|
157
149
|
try {
|
|
158
150
|
const [{ location }] = await client.emitAndFlattenResponses('get-location::v2020_12_25', {
|
|
@@ -163,7 +155,7 @@ class ConfirmJoinCardViewController extends heartwood_view_controllers_1.Abstrac
|
|
|
163
155
|
this.location = location;
|
|
164
156
|
}
|
|
165
157
|
catch (err) {
|
|
166
|
-
if (err.options
|
|
158
|
+
if (((_a = err.options) === null || _a === void 0 ? void 0 : _a.code) === 'UNAUTHORIZED_ACCESS') {
|
|
167
159
|
this.location = {
|
|
168
160
|
id: this.locationId,
|
|
169
161
|
dateCreated: 0,
|
|
@@ -189,4 +181,5 @@ class ConfirmJoinCardViewController extends heartwood_view_controllers_1.Abstrac
|
|
|
189
181
|
return this.cardVc.render();
|
|
190
182
|
}
|
|
191
183
|
}
|
|
184
|
+
ConfirmJoinCardViewController.id = 'confirm-join-card';
|
|
192
185
|
exports.default = ConfirmJoinCardViewController;
|
|
@@ -7,11 +7,11 @@ exports.LoginAndConfirmJoinControllerFactory = void 0;
|
|
|
7
7
|
const schema_1 = require("@sprucelabs/schema");
|
|
8
8
|
const ConfirmJoinCard_vc_1 = __importDefault(require("../accepting/ConfirmJoinCard.vc"));
|
|
9
9
|
class LoginAndConfirmJoinControllerFactory {
|
|
10
|
-
static Class;
|
|
11
10
|
static setClass(Class) {
|
|
12
11
|
this.Class = Class;
|
|
13
12
|
}
|
|
14
13
|
static Controller(options) {
|
|
14
|
+
var _a;
|
|
15
15
|
const { views } = (0, schema_1.assertOptions)(options, [
|
|
16
16
|
'authenticator',
|
|
17
17
|
'views',
|
|
@@ -21,20 +21,11 @@ class LoginAndConfirmJoinControllerFactory {
|
|
|
21
21
|
if (!views.hasController('invite.confirm-join-card')) {
|
|
22
22
|
views.setController('invite.confirm-join-card', ConfirmJoinCard_vc_1.default);
|
|
23
23
|
}
|
|
24
|
-
return new (this.Class
|
|
24
|
+
return new ((_a = this.Class) !== null && _a !== void 0 ? _a : LoginAndConfirmJoinControllerImpl)(options);
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
27
|
exports.LoginAndConfirmJoinControllerFactory = LoginAndConfirmJoinControllerFactory;
|
|
28
28
|
class LoginAndConfirmJoinControllerImpl {
|
|
29
|
-
views;
|
|
30
|
-
vc;
|
|
31
|
-
authenticator;
|
|
32
|
-
dialog;
|
|
33
|
-
organizationId;
|
|
34
|
-
connectToApi;
|
|
35
|
-
client;
|
|
36
|
-
locationId;
|
|
37
|
-
confirmJoinContext;
|
|
38
29
|
constructor(options) {
|
|
39
30
|
const { views, authenticator, organizationId, connectToApi, locationId, } = options;
|
|
40
31
|
this.views = views;
|
|
@@ -46,7 +37,7 @@ class LoginAndConfirmJoinControllerImpl {
|
|
|
46
37
|
}
|
|
47
38
|
async promptForLoginAndConfirmJoin(options) {
|
|
48
39
|
this.client = await this.connectToApi();
|
|
49
|
-
this.confirmJoinContext = options
|
|
40
|
+
this.confirmJoinContext = options === null || options === void 0 ? void 0 : options.confirmJoinViewContext;
|
|
50
41
|
let person = this.authenticator.getPerson();
|
|
51
42
|
if (!this.authenticator.isLoggedIn()) {
|
|
52
43
|
person = await this.promptForLogin();
|
|
@@ -75,11 +66,13 @@ class LoginAndConfirmJoinControllerImpl {
|
|
|
75
66
|
let accepted = false;
|
|
76
67
|
const confirmVc = this.views.Controller('invite.confirm-join-card', {
|
|
77
68
|
onAccept: async () => {
|
|
69
|
+
var _a;
|
|
78
70
|
accepted = true;
|
|
79
|
-
await this.dialog
|
|
71
|
+
await ((_a = this.dialog) === null || _a === void 0 ? void 0 : _a.hide());
|
|
80
72
|
},
|
|
81
73
|
onDecline: async () => {
|
|
82
|
-
|
|
74
|
+
var _a;
|
|
75
|
+
await ((_a = this.dialog) === null || _a === void 0 ? void 0 : _a.hide());
|
|
83
76
|
},
|
|
84
77
|
onError: () => { },
|
|
85
78
|
organizationId: this.organizationId,
|
|
@@ -96,17 +89,19 @@ class LoginAndConfirmJoinControllerImpl {
|
|
|
96
89
|
let person;
|
|
97
90
|
const loginVc = this.views.Controller('login', {
|
|
98
91
|
onLogin: async (options) => {
|
|
92
|
+
var _a;
|
|
99
93
|
person = options.person;
|
|
100
|
-
await this.dialog
|
|
94
|
+
await ((_a = this.dialog) === null || _a === void 0 ? void 0 : _a.hide());
|
|
101
95
|
},
|
|
102
96
|
});
|
|
103
97
|
await this.renderInDialogAndWait(loginVc.render());
|
|
104
98
|
return person;
|
|
105
99
|
}
|
|
106
100
|
async renderInDialogAndWait(view) {
|
|
101
|
+
var _a;
|
|
107
102
|
//@ts-ignore
|
|
108
103
|
this.dialog = this.vc.renderInDialog(view);
|
|
109
|
-
await this.dialog
|
|
104
|
+
await ((_a = this.dialog) === null || _a === void 0 ? void 0 : _a.wait());
|
|
110
105
|
}
|
|
111
106
|
}
|
|
112
107
|
exports.default = LoginAndConfirmJoinControllerImpl;
|