@sprucelabs/spruce-invite-utils 3.4.0 → 3.5.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.
- package/build/__tests__/support/LoginAndConfirmTestFixture.d.ts +2 -1
- package/build/__tests__/support/LoginAndConfirmTestFixture.js +3 -0
- package/build/accepting/ConfirmJoinCard.vc.d.ts +34 -0
- package/build/accepting/ConfirmJoinCard.vc.js +145 -0
- package/build/accepting/renderAcceptCardSections.d.ts +13 -0
- package/build/accepting/renderAcceptCardSections.js +91 -0
- package/build/esm/__tests__/support/LoginAndConfirmTestFixture.d.ts +2 -1
- package/build/esm/__tests__/support/LoginAndConfirmTestFixture.js +3 -0
- package/build/esm/accepting/ConfirmJoinCard.vc.d.ts +34 -0
- package/build/esm/accepting/ConfirmJoinCard.vc.js +138 -0
- package/build/esm/accepting/renderAcceptCardSections.d.ts +13 -0
- package/build/esm/accepting/renderAcceptCardSections.js +95 -0
- package/build/esm/loggingInAndConfirmingJoin/LoginAndConfirmJoinController.d.ts +6 -4
- package/build/loggingInAndConfirmingJoin/LoginAndConfirmJoinController.d.ts +6 -4
- package/package.json +10 -2
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { PromptForLoginAndConfirmOptions } from '../../loggingInAndConfirmingJoin/LoginAndConfirmJoinController';
|
|
1
|
+
import { LoginAndConfirmJoinOptions, PromptForLoginAndConfirmOptions } from '../../loggingInAndConfirmingJoin/LoginAndConfirmJoinController';
|
|
2
2
|
export default class LoginAndConfirmTestFixture {
|
|
3
3
|
private static hitCount;
|
|
4
4
|
private static wasBeforeEachCalled;
|
|
5
5
|
static lastPromptOptions?: PromptForLoginAndConfirmOptions;
|
|
6
|
+
static lastFactoryOptions?: LoginAndConfirmJoinOptions;
|
|
6
7
|
static beforeEach(): void;
|
|
7
8
|
static getHitCount(): number;
|
|
8
9
|
private static assertBeforeEachWasCalled;
|
|
@@ -33,6 +33,9 @@ exports.default = LoginAndConfirmTestFixture;
|
|
|
33
33
|
LoginAndConfirmTestFixture.hitCount = 0;
|
|
34
34
|
LoginAndConfirmTestFixture.wasBeforeEachCalled = false;
|
|
35
35
|
class CountingLoginAndConfirmController {
|
|
36
|
+
constructor(options) {
|
|
37
|
+
LoginAndConfirmTestFixture.lastFactoryOptions = options;
|
|
38
|
+
}
|
|
36
39
|
async promptForLoginAndConfirmJoin(options) {
|
|
37
40
|
//@ts-ignore
|
|
38
41
|
LoginAndConfirmTestFixture.hitCount++;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { AbstractViewController, Authenticator, Card, SpruceSchemas, ViewControllerOptions } from '@sprucelabs/heartwood-view-controllers';
|
|
2
|
+
import { InviteViewContext } from '../loggingInAndConfirmingJoin/LoginAndConfirmJoinController';
|
|
3
|
+
export default class ConfirmJoinCardViewController extends AbstractViewController<Card> {
|
|
4
|
+
static id: string;
|
|
5
|
+
private cardVc;
|
|
6
|
+
private isLoaded;
|
|
7
|
+
private organizationId;
|
|
8
|
+
protected org?: SpruceSchemas.Spruce.v2020_07_22.Organization;
|
|
9
|
+
protected location?: SpruceSchemas.Spruce.v2020_07_22.Location;
|
|
10
|
+
private locationId?;
|
|
11
|
+
private onErrorHandler?;
|
|
12
|
+
private onAcceptHandler;
|
|
13
|
+
private onDeclineHandler;
|
|
14
|
+
protected viewContext: InviteViewContext;
|
|
15
|
+
private authenticator;
|
|
16
|
+
constructor(options: ViewControllerOptions & ConfirmJoinCardOptions);
|
|
17
|
+
private CardVc;
|
|
18
|
+
accept(): Promise<void>;
|
|
19
|
+
decline(): Promise<void>;
|
|
20
|
+
getIsLoaded(): boolean;
|
|
21
|
+
load(): Promise<void>;
|
|
22
|
+
private loadOrg;
|
|
23
|
+
private optionallyLoadLocation;
|
|
24
|
+
render(): SpruceSchemas.HeartwoodViewControllers.v2021_02_11.Card;
|
|
25
|
+
}
|
|
26
|
+
export interface ConfirmJoinCardOptions {
|
|
27
|
+
organizationId: string;
|
|
28
|
+
locationId?: string;
|
|
29
|
+
onError?: (err: Error) => void | Promise<void>;
|
|
30
|
+
onAccept: () => void | Promise<void>;
|
|
31
|
+
onDecline: () => void | Promise<void>;
|
|
32
|
+
viewContext: InviteViewContext;
|
|
33
|
+
authenticator: Authenticator;
|
|
34
|
+
}
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
const heartwood_view_controllers_1 = require("@sprucelabs/heartwood-view-controllers");
|
|
27
|
+
const schema_1 = require("@sprucelabs/schema");
|
|
28
|
+
const renderAcceptCardSections_1 = __importStar(require("./renderAcceptCardSections"));
|
|
29
|
+
class ConfirmJoinCardViewController extends heartwood_view_controllers_1.AbstractViewController {
|
|
30
|
+
constructor(options) {
|
|
31
|
+
super(options);
|
|
32
|
+
this.isLoaded = false;
|
|
33
|
+
(0, schema_1.assertOptions)(options, [
|
|
34
|
+
'organizationId',
|
|
35
|
+
'onAccept',
|
|
36
|
+
'onDecline',
|
|
37
|
+
'viewContext',
|
|
38
|
+
'authenticator',
|
|
39
|
+
]);
|
|
40
|
+
this.organizationId = options.organizationId;
|
|
41
|
+
this.locationId = options.locationId;
|
|
42
|
+
this.onErrorHandler = options.onError;
|
|
43
|
+
this.onAcceptHandler = options.onAccept;
|
|
44
|
+
this.onDeclineHandler = options.onDecline;
|
|
45
|
+
this.viewContext = options.viewContext;
|
|
46
|
+
this.authenticator = options.authenticator;
|
|
47
|
+
this.cardVc = this.CardVc();
|
|
48
|
+
}
|
|
49
|
+
CardVc() {
|
|
50
|
+
return this.Controller('card', {
|
|
51
|
+
header: {
|
|
52
|
+
title: 'Ready to join?',
|
|
53
|
+
subtitle: 'This is so exciting!',
|
|
54
|
+
},
|
|
55
|
+
body: {
|
|
56
|
+
isBusy: true,
|
|
57
|
+
},
|
|
58
|
+
footer: {
|
|
59
|
+
buttons: [
|
|
60
|
+
{
|
|
61
|
+
id: 'accept',
|
|
62
|
+
label: 'Accept!',
|
|
63
|
+
type: 'primary',
|
|
64
|
+
onClick: () => this.accept(),
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
id: 'reject',
|
|
68
|
+
label: 'Reject!',
|
|
69
|
+
type: 'destructive',
|
|
70
|
+
onClick: () => this.decline(),
|
|
71
|
+
},
|
|
72
|
+
],
|
|
73
|
+
},
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
async accept() {
|
|
77
|
+
await this.onAcceptHandler();
|
|
78
|
+
}
|
|
79
|
+
async decline() {
|
|
80
|
+
await this.onDeclineHandler();
|
|
81
|
+
}
|
|
82
|
+
getIsLoaded() {
|
|
83
|
+
return this.isLoaded;
|
|
84
|
+
}
|
|
85
|
+
async load() {
|
|
86
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
87
|
+
try {
|
|
88
|
+
const client = await this.connectToApi();
|
|
89
|
+
await Promise.all([
|
|
90
|
+
this.optionallyLoadLocation(client),
|
|
91
|
+
this.loadOrg(client),
|
|
92
|
+
]);
|
|
93
|
+
this.isLoaded = true;
|
|
94
|
+
const person = this.authenticator.getPerson();
|
|
95
|
+
const listVc = this.Controller('list', (0, renderAcceptCardSections_1.renderPermsList)({
|
|
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 : '',
|
|
99
|
+
onClickToggle: () => this.askForAVote({
|
|
100
|
+
featureKey: 'selectable-perms',
|
|
101
|
+
skillNamespace: 'invite',
|
|
102
|
+
howCoolWouldItBeIf: 'you could hide specific bits of information about yourself, even stay anonymous?',
|
|
103
|
+
}),
|
|
104
|
+
}));
|
|
105
|
+
this.cardVc.setSections([
|
|
106
|
+
...(0, renderAcceptCardSections_1.default)({
|
|
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,
|
|
110
|
+
}),
|
|
111
|
+
{
|
|
112
|
+
list: listVc.render(),
|
|
113
|
+
},
|
|
114
|
+
]);
|
|
115
|
+
this.cardVc.setIsBusy(false);
|
|
116
|
+
}
|
|
117
|
+
catch (err) {
|
|
118
|
+
await this.alert({ message: err.message });
|
|
119
|
+
await ((_h = this.onErrorHandler) === null || _h === void 0 ? void 0 : _h.call(this, err));
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
async loadOrg(client) {
|
|
123
|
+
const [{ organization }] = await client.emitAndFlattenResponses('get-organization::v2020_12_25', {
|
|
124
|
+
target: {
|
|
125
|
+
organizationId: this.organizationId,
|
|
126
|
+
},
|
|
127
|
+
});
|
|
128
|
+
this.org = organization;
|
|
129
|
+
}
|
|
130
|
+
async optionallyLoadLocation(client) {
|
|
131
|
+
if (this.locationId) {
|
|
132
|
+
const [{ location }] = await client.emitAndFlattenResponses('get-location::v2020_12_25', {
|
|
133
|
+
target: {
|
|
134
|
+
locationId: this.locationId,
|
|
135
|
+
},
|
|
136
|
+
});
|
|
137
|
+
this.location = location;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
render() {
|
|
141
|
+
return this.cardVc.render();
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
exports.default = ConfirmJoinCardViewController;
|
|
145
|
+
ConfirmJoinCardViewController.id = 'confirm-join-card';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { CardSection, SpruceSchemas } from '@sprucelabs/heartwood-view-controllers';
|
|
2
|
+
import { AddressFieldValue } from '@sprucelabs/schema';
|
|
3
|
+
export default function renderAcceptCardSections(options: {
|
|
4
|
+
orgName: string;
|
|
5
|
+
locationAddress?: AddressFieldValue;
|
|
6
|
+
roleName: string;
|
|
7
|
+
}): CardSection[];
|
|
8
|
+
export declare function renderPermsList(options: {
|
|
9
|
+
firstName: string;
|
|
10
|
+
onClickToggle: () => Promise<any>;
|
|
11
|
+
lastName: string;
|
|
12
|
+
phone: string;
|
|
13
|
+
}): SpruceSchemas.HeartwoodViewControllers.v2021_02_11.List;
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.renderPermsList = void 0;
|
|
4
|
+
const spruce_skill_utils_1 = require("@sprucelabs/spruce-skill-utils");
|
|
5
|
+
function renderAcceptCardSections(options) {
|
|
6
|
+
const { orgName, roleName, locationAddress } = options;
|
|
7
|
+
const sections = [
|
|
8
|
+
{
|
|
9
|
+
text: {
|
|
10
|
+
html: `Invitation to join<h3>${orgName}</h3>`,
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
locationAddress && {
|
|
14
|
+
text: {
|
|
15
|
+
html: `At the location on<h4>${spruce_skill_utils_1.locationRenderer.renderAddress(locationAddress)}</h4>`,
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
text: {
|
|
20
|
+
html: `As a<h3>${roleName}</h3>`,
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
shouldContentBeCentered: true,
|
|
25
|
+
title: 'Permissions',
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
text: {
|
|
29
|
+
content: `Below is the information the team at ${orgName} will be able to see.`,
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
].filter((s) => !!s);
|
|
33
|
+
return sections;
|
|
34
|
+
}
|
|
35
|
+
exports.default = renderAcceptCardSections;
|
|
36
|
+
function renderPermsList(options) {
|
|
37
|
+
const { firstName, onClickToggle, lastName, phone } = options;
|
|
38
|
+
return {
|
|
39
|
+
columnWidths: ['content', 'fill'],
|
|
40
|
+
rows: [
|
|
41
|
+
renderPermRow({
|
|
42
|
+
id: 'firstName',
|
|
43
|
+
text: 'Your first name',
|
|
44
|
+
subText: firstName,
|
|
45
|
+
onClickToggle,
|
|
46
|
+
}),
|
|
47
|
+
renderPermRow({
|
|
48
|
+
id: 'lastName',
|
|
49
|
+
text: 'Your last name',
|
|
50
|
+
subText: lastName,
|
|
51
|
+
onClickToggle,
|
|
52
|
+
}),
|
|
53
|
+
renderPermRow({
|
|
54
|
+
id: 'phone',
|
|
55
|
+
text: 'Your phone',
|
|
56
|
+
subText: phone,
|
|
57
|
+
onClickToggle,
|
|
58
|
+
}),
|
|
59
|
+
],
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
exports.renderPermsList = renderPermsList;
|
|
63
|
+
function renderPermRow(options) {
|
|
64
|
+
const { id, text, subText, onClickToggle } = options;
|
|
65
|
+
return {
|
|
66
|
+
id,
|
|
67
|
+
cells: [
|
|
68
|
+
{
|
|
69
|
+
lineIcon: 'unlock',
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
text: {
|
|
73
|
+
content: text,
|
|
74
|
+
},
|
|
75
|
+
subText: {
|
|
76
|
+
content: subText,
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
toggleInput: {
|
|
81
|
+
name: 'allow',
|
|
82
|
+
value: true,
|
|
83
|
+
onChange: async () => {
|
|
84
|
+
await onClickToggle();
|
|
85
|
+
return false;
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
],
|
|
90
|
+
};
|
|
91
|
+
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { PromptForLoginAndConfirmOptions } from '../../loggingInAndConfirmingJoin/LoginAndConfirmJoinController';
|
|
1
|
+
import { LoginAndConfirmJoinOptions, PromptForLoginAndConfirmOptions } from '../../loggingInAndConfirmingJoin/LoginAndConfirmJoinController';
|
|
2
2
|
export default class LoginAndConfirmTestFixture {
|
|
3
3
|
private static hitCount;
|
|
4
4
|
private static wasBeforeEachCalled;
|
|
5
5
|
static lastPromptOptions?: PromptForLoginAndConfirmOptions;
|
|
6
|
+
static lastFactoryOptions?: LoginAndConfirmJoinOptions;
|
|
6
7
|
static beforeEach(): void;
|
|
7
8
|
static getHitCount(): number;
|
|
8
9
|
private static assertBeforeEachWasCalled;
|
|
@@ -36,6 +36,9 @@ export default class LoginAndConfirmTestFixture {
|
|
|
36
36
|
LoginAndConfirmTestFixture.hitCount = 0;
|
|
37
37
|
LoginAndConfirmTestFixture.wasBeforeEachCalled = false;
|
|
38
38
|
class CountingLoginAndConfirmController {
|
|
39
|
+
constructor(options) {
|
|
40
|
+
LoginAndConfirmTestFixture.lastFactoryOptions = options;
|
|
41
|
+
}
|
|
39
42
|
promptForLoginAndConfirmJoin(options) {
|
|
40
43
|
return __awaiter(this, void 0, void 0, function* () {
|
|
41
44
|
//@ts-ignore
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { AbstractViewController, Authenticator, Card, SpruceSchemas, ViewControllerOptions } from '@sprucelabs/heartwood-view-controllers';
|
|
2
|
+
import { InviteViewContext } from '../loggingInAndConfirmingJoin/LoginAndConfirmJoinController';
|
|
3
|
+
export default class ConfirmJoinCardViewController extends AbstractViewController<Card> {
|
|
4
|
+
static id: string;
|
|
5
|
+
private cardVc;
|
|
6
|
+
private isLoaded;
|
|
7
|
+
private organizationId;
|
|
8
|
+
protected org?: SpruceSchemas.Spruce.v2020_07_22.Organization;
|
|
9
|
+
protected location?: SpruceSchemas.Spruce.v2020_07_22.Location;
|
|
10
|
+
private locationId?;
|
|
11
|
+
private onErrorHandler?;
|
|
12
|
+
private onAcceptHandler;
|
|
13
|
+
private onDeclineHandler;
|
|
14
|
+
protected viewContext: InviteViewContext;
|
|
15
|
+
private authenticator;
|
|
16
|
+
constructor(options: ViewControllerOptions & ConfirmJoinCardOptions);
|
|
17
|
+
private CardVc;
|
|
18
|
+
accept(): Promise<void>;
|
|
19
|
+
decline(): Promise<void>;
|
|
20
|
+
getIsLoaded(): boolean;
|
|
21
|
+
load(): Promise<void>;
|
|
22
|
+
private loadOrg;
|
|
23
|
+
private optionallyLoadLocation;
|
|
24
|
+
render(): SpruceSchemas.HeartwoodViewControllers.v2021_02_11.Card;
|
|
25
|
+
}
|
|
26
|
+
export interface ConfirmJoinCardOptions {
|
|
27
|
+
organizationId: string;
|
|
28
|
+
locationId?: string;
|
|
29
|
+
onError?: (err: Error) => void | Promise<void>;
|
|
30
|
+
onAccept: () => void | Promise<void>;
|
|
31
|
+
onDecline: () => void | Promise<void>;
|
|
32
|
+
viewContext: InviteViewContext;
|
|
33
|
+
authenticator: Authenticator;
|
|
34
|
+
}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { AbstractViewController, } from '@sprucelabs/heartwood-view-controllers';
|
|
11
|
+
import { assertOptions } from '@sprucelabs/schema';
|
|
12
|
+
import renderAcceptCardSections, { renderPermsList, } from './renderAcceptCardSections.js';
|
|
13
|
+
export default class ConfirmJoinCardViewController extends AbstractViewController {
|
|
14
|
+
constructor(options) {
|
|
15
|
+
super(options);
|
|
16
|
+
this.isLoaded = false;
|
|
17
|
+
assertOptions(options, [
|
|
18
|
+
'organizationId',
|
|
19
|
+
'onAccept',
|
|
20
|
+
'onDecline',
|
|
21
|
+
'viewContext',
|
|
22
|
+
'authenticator',
|
|
23
|
+
]);
|
|
24
|
+
this.organizationId = options.organizationId;
|
|
25
|
+
this.locationId = options.locationId;
|
|
26
|
+
this.onErrorHandler = options.onError;
|
|
27
|
+
this.onAcceptHandler = options.onAccept;
|
|
28
|
+
this.onDeclineHandler = options.onDecline;
|
|
29
|
+
this.viewContext = options.viewContext;
|
|
30
|
+
this.authenticator = options.authenticator;
|
|
31
|
+
this.cardVc = this.CardVc();
|
|
32
|
+
}
|
|
33
|
+
CardVc() {
|
|
34
|
+
return this.Controller('card', {
|
|
35
|
+
header: {
|
|
36
|
+
title: 'Ready to join?',
|
|
37
|
+
subtitle: 'This is so exciting!',
|
|
38
|
+
},
|
|
39
|
+
body: {
|
|
40
|
+
isBusy: true,
|
|
41
|
+
},
|
|
42
|
+
footer: {
|
|
43
|
+
buttons: [
|
|
44
|
+
{
|
|
45
|
+
id: 'accept',
|
|
46
|
+
label: 'Accept!',
|
|
47
|
+
type: 'primary',
|
|
48
|
+
onClick: () => this.accept(),
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
id: 'reject',
|
|
52
|
+
label: 'Reject!',
|
|
53
|
+
type: 'destructive',
|
|
54
|
+
onClick: () => this.decline(),
|
|
55
|
+
},
|
|
56
|
+
],
|
|
57
|
+
},
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
accept() {
|
|
61
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
62
|
+
yield this.onAcceptHandler();
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
decline() {
|
|
66
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
67
|
+
yield this.onDeclineHandler();
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
getIsLoaded() {
|
|
71
|
+
return this.isLoaded;
|
|
72
|
+
}
|
|
73
|
+
load() {
|
|
74
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
75
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
76
|
+
try {
|
|
77
|
+
const client = yield this.connectToApi();
|
|
78
|
+
yield Promise.all([
|
|
79
|
+
this.optionallyLoadLocation(client),
|
|
80
|
+
this.loadOrg(client),
|
|
81
|
+
]);
|
|
82
|
+
this.isLoaded = true;
|
|
83
|
+
const person = this.authenticator.getPerson();
|
|
84
|
+
const listVc = this.Controller('list', renderPermsList({
|
|
85
|
+
firstName: (_a = person === null || person === void 0 ? void 0 : person.firstName) !== null && _a !== void 0 ? _a : '',
|
|
86
|
+
lastName: (_b = person === null || person === void 0 ? void 0 : person.lastName) !== null && _b !== void 0 ? _b : '',
|
|
87
|
+
phone: (_c = person === null || person === void 0 ? void 0 : person.phone) !== null && _c !== void 0 ? _c : '',
|
|
88
|
+
onClickToggle: () => this.askForAVote({
|
|
89
|
+
featureKey: 'selectable-perms',
|
|
90
|
+
skillNamespace: 'invite',
|
|
91
|
+
howCoolWouldItBeIf: 'you could hide specific bits of information about yourself, even stay anonymous?',
|
|
92
|
+
}),
|
|
93
|
+
}));
|
|
94
|
+
this.cardVc.setSections([
|
|
95
|
+
...renderAcceptCardSections({
|
|
96
|
+
orgName: (_e = (_d = this.org) === null || _d === void 0 ? void 0 : _d.name) !== null && _e !== void 0 ? _e : 'a company',
|
|
97
|
+
roleName: (_f = this.viewContext.roleName) !== null && _f !== void 0 ? _f : 'Guest',
|
|
98
|
+
locationAddress: (_g = this.location) === null || _g === void 0 ? void 0 : _g.address,
|
|
99
|
+
}),
|
|
100
|
+
{
|
|
101
|
+
list: listVc.render(),
|
|
102
|
+
},
|
|
103
|
+
]);
|
|
104
|
+
this.cardVc.setIsBusy(false);
|
|
105
|
+
}
|
|
106
|
+
catch (err) {
|
|
107
|
+
yield this.alert({ message: err.message });
|
|
108
|
+
yield ((_h = this.onErrorHandler) === null || _h === void 0 ? void 0 : _h.call(this, err));
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
loadOrg(client) {
|
|
113
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
114
|
+
const [{ organization }] = yield client.emitAndFlattenResponses('get-organization::v2020_12_25', {
|
|
115
|
+
target: {
|
|
116
|
+
organizationId: this.organizationId,
|
|
117
|
+
},
|
|
118
|
+
});
|
|
119
|
+
this.org = organization;
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
optionallyLoadLocation(client) {
|
|
123
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
124
|
+
if (this.locationId) {
|
|
125
|
+
const [{ location }] = yield client.emitAndFlattenResponses('get-location::v2020_12_25', {
|
|
126
|
+
target: {
|
|
127
|
+
locationId: this.locationId,
|
|
128
|
+
},
|
|
129
|
+
});
|
|
130
|
+
this.location = location;
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
render() {
|
|
135
|
+
return this.cardVc.render();
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
ConfirmJoinCardViewController.id = 'confirm-join-card';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { CardSection, SpruceSchemas } from '@sprucelabs/heartwood-view-controllers';
|
|
2
|
+
import { AddressFieldValue } from '@sprucelabs/schema';
|
|
3
|
+
export default function renderAcceptCardSections(options: {
|
|
4
|
+
orgName: string;
|
|
5
|
+
locationAddress?: AddressFieldValue;
|
|
6
|
+
roleName: string;
|
|
7
|
+
}): CardSection[];
|
|
8
|
+
export declare function renderPermsList(options: {
|
|
9
|
+
firstName: string;
|
|
10
|
+
onClickToggle: () => Promise<any>;
|
|
11
|
+
lastName: string;
|
|
12
|
+
phone: string;
|
|
13
|
+
}): SpruceSchemas.HeartwoodViewControllers.v2021_02_11.List;
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { locationRenderer } from '@sprucelabs/spruce-skill-utils';
|
|
11
|
+
export default function renderAcceptCardSections(options) {
|
|
12
|
+
const { orgName, roleName, locationAddress } = options;
|
|
13
|
+
const sections = [
|
|
14
|
+
{
|
|
15
|
+
text: {
|
|
16
|
+
html: `Invitation to join<h3>${orgName}</h3>`,
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
locationAddress && {
|
|
20
|
+
text: {
|
|
21
|
+
html: `At the location on<h4>${locationRenderer.renderAddress(locationAddress)}</h4>`,
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
text: {
|
|
26
|
+
html: `As a<h3>${roleName}</h3>`,
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
shouldContentBeCentered: true,
|
|
31
|
+
title: 'Permissions',
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
text: {
|
|
35
|
+
content: `Below is the information the team at ${orgName} will be able to see.`,
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
].filter((s) => !!s);
|
|
39
|
+
return sections;
|
|
40
|
+
}
|
|
41
|
+
export function renderPermsList(options) {
|
|
42
|
+
const { firstName, onClickToggle, lastName, phone } = options;
|
|
43
|
+
return {
|
|
44
|
+
columnWidths: ['content', 'fill'],
|
|
45
|
+
rows: [
|
|
46
|
+
renderPermRow({
|
|
47
|
+
id: 'firstName',
|
|
48
|
+
text: 'Your first name',
|
|
49
|
+
subText: firstName,
|
|
50
|
+
onClickToggle,
|
|
51
|
+
}),
|
|
52
|
+
renderPermRow({
|
|
53
|
+
id: 'lastName',
|
|
54
|
+
text: 'Your last name',
|
|
55
|
+
subText: lastName,
|
|
56
|
+
onClickToggle,
|
|
57
|
+
}),
|
|
58
|
+
renderPermRow({
|
|
59
|
+
id: 'phone',
|
|
60
|
+
text: 'Your phone',
|
|
61
|
+
subText: phone,
|
|
62
|
+
onClickToggle,
|
|
63
|
+
}),
|
|
64
|
+
],
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
function renderPermRow(options) {
|
|
68
|
+
const { id, text, subText, onClickToggle } = options;
|
|
69
|
+
return {
|
|
70
|
+
id,
|
|
71
|
+
cells: [
|
|
72
|
+
{
|
|
73
|
+
lineIcon: 'unlock',
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
text: {
|
|
77
|
+
content: text,
|
|
78
|
+
},
|
|
79
|
+
subText: {
|
|
80
|
+
content: subText,
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
toggleInput: {
|
|
85
|
+
name: 'allow',
|
|
86
|
+
value: true,
|
|
87
|
+
onChange: () => __awaiter(this, void 0, void 0, function* () {
|
|
88
|
+
yield onClickToggle();
|
|
89
|
+
return false;
|
|
90
|
+
}),
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
],
|
|
94
|
+
};
|
|
95
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Authenticator, CardViewControllerImpl,
|
|
1
|
+
import { Authenticator, CardViewControllerImpl, ViewControllerFactory } from '@sprucelabs/heartwood-view-controllers';
|
|
2
2
|
import { MercuryClient } from '@sprucelabs/mercury-client';
|
|
3
3
|
export default class LoginAndConfirmJoinControllerImpl implements LoginAndConfirmJoinController {
|
|
4
4
|
private views;
|
|
@@ -12,7 +12,7 @@ export default class LoginAndConfirmJoinControllerImpl implements LoginAndConfir
|
|
|
12
12
|
private locationId?;
|
|
13
13
|
private confirmJoinContext?;
|
|
14
14
|
protected constructor(options: LoginAndConfirmJoinOptions);
|
|
15
|
-
static setClass(Class?:
|
|
15
|
+
static setClass(Class?: LoginAndConfirmJoinConstructor): void;
|
|
16
16
|
static Controller(options: LoginAndConfirmJoinOptions): LoginAndConfirmJoinController;
|
|
17
17
|
promptForLoginAndConfirmJoin(options?: PromptForLoginAndConfirmOptions): Promise<boolean>;
|
|
18
18
|
private listRoles;
|
|
@@ -27,9 +27,11 @@ export interface LoginAndConfirmJoinOptions {
|
|
|
27
27
|
locationId?: string;
|
|
28
28
|
connectToApi: ConnectToApi;
|
|
29
29
|
}
|
|
30
|
-
export declare type LoginAndConfirmJoinConstructor = new () => LoginAndConfirmJoinController;
|
|
30
|
+
export declare type LoginAndConfirmJoinConstructor = new (options: LoginAndConfirmJoinOptions) => LoginAndConfirmJoinController;
|
|
31
31
|
declare type ConnectToApi = () => Promise<MercuryClient>;
|
|
32
|
-
export
|
|
32
|
+
export interface InviteViewContext {
|
|
33
|
+
roleName?: string | undefined | null;
|
|
34
|
+
}
|
|
33
35
|
export interface PromptForLoginAndConfirmOptions {
|
|
34
36
|
confirmJoinViewContext?: InviteViewContext;
|
|
35
37
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Authenticator, CardViewControllerImpl,
|
|
1
|
+
import { Authenticator, CardViewControllerImpl, ViewControllerFactory } from '@sprucelabs/heartwood-view-controllers';
|
|
2
2
|
import { MercuryClient } from '@sprucelabs/mercury-client';
|
|
3
3
|
export default class LoginAndConfirmJoinControllerImpl implements LoginAndConfirmJoinController {
|
|
4
4
|
private views;
|
|
@@ -12,7 +12,7 @@ export default class LoginAndConfirmJoinControllerImpl implements LoginAndConfir
|
|
|
12
12
|
private locationId?;
|
|
13
13
|
private confirmJoinContext?;
|
|
14
14
|
protected constructor(options: LoginAndConfirmJoinOptions);
|
|
15
|
-
static setClass(Class?:
|
|
15
|
+
static setClass(Class?: LoginAndConfirmJoinConstructor): void;
|
|
16
16
|
static Controller(options: LoginAndConfirmJoinOptions): LoginAndConfirmJoinController;
|
|
17
17
|
promptForLoginAndConfirmJoin(options?: PromptForLoginAndConfirmOptions): Promise<boolean>;
|
|
18
18
|
private listRoles;
|
|
@@ -27,9 +27,11 @@ export interface LoginAndConfirmJoinOptions {
|
|
|
27
27
|
locationId?: string;
|
|
28
28
|
connectToApi: ConnectToApi;
|
|
29
29
|
}
|
|
30
|
-
export declare type LoginAndConfirmJoinConstructor = new () => LoginAndConfirmJoinController;
|
|
30
|
+
export declare type LoginAndConfirmJoinConstructor = new (options: LoginAndConfirmJoinOptions) => LoginAndConfirmJoinController;
|
|
31
31
|
declare type ConnectToApi = () => Promise<MercuryClient>;
|
|
32
|
-
export
|
|
32
|
+
export interface InviteViewContext {
|
|
33
|
+
roleName?: string | undefined | null;
|
|
34
|
+
}
|
|
33
35
|
export interface PromptForLoginAndConfirmOptions {
|
|
34
36
|
confirmJoinViewContext?: InviteViewContext;
|
|
35
37
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sprucelabs/spruce-invite-utils",
|
|
3
3
|
"description": "Invite Utilities",
|
|
4
|
-
"version": "3.
|
|
4
|
+
"version": "3.5.1",
|
|
5
5
|
"skill": {
|
|
6
6
|
"namespace": "invite"
|
|
7
7
|
},
|
|
@@ -29,7 +29,15 @@
|
|
|
29
29
|
"build/__tests__/support/LoginAndConfirmTestFixture.js",
|
|
30
30
|
"build/__tests__/support/LoginAndConfirmTestFixture.d.ts",
|
|
31
31
|
"build/esm/__tests__/support/LoginAndConfirmTestFixture.js",
|
|
32
|
-
"build/esm/__tests__/support/LoginAndConfirmTestFixture.d.ts"
|
|
32
|
+
"build/esm/__tests__/support/LoginAndConfirmTestFixture.d.ts",
|
|
33
|
+
"build/accepting/ConfirmJoinCard.vc.js",
|
|
34
|
+
"build/accepting/ConfirmJoinCard.vc.d.ts",
|
|
35
|
+
"build/esm/accepting/ConfirmJoinCard.vc.js",
|
|
36
|
+
"build/esm/accepting/ConfirmJoinCard.vc.d.ts",
|
|
37
|
+
"build/accepting/renderAcceptCardSections.js",
|
|
38
|
+
"build/accepting/renderAcceptCardSections.d.ts",
|
|
39
|
+
"build/esm/accepting/renderAcceptCardSections.js",
|
|
40
|
+
"build/esm/accepting/renderAcceptCardSections.d.ts"
|
|
33
41
|
],
|
|
34
42
|
"keywords": [],
|
|
35
43
|
"scripts": {
|