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