@sprucelabs/spruce-invite-utils 3.3.2 → 3.4.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.
@@ -1,6 +1,8 @@
1
+ import { PromptForLoginAndConfirmOptions } from '../../loggingInAndConfirmingJoin/LoginAndConfirmJoinController';
1
2
  export default class LoginAndConfirmTestFixture {
2
3
  private static hitCount;
3
4
  private static wasBeforeEachCalled;
5
+ static lastPromptOptions?: PromptForLoginAndConfirmOptions;
4
6
  static beforeEach(): void;
5
7
  static getHitCount(): number;
6
8
  private static assertBeforeEachWasCalled;
@@ -33,9 +33,10 @@ exports.default = LoginAndConfirmTestFixture;
33
33
  LoginAndConfirmTestFixture.hitCount = 0;
34
34
  LoginAndConfirmTestFixture.wasBeforeEachCalled = false;
35
35
  class CountingLoginAndConfirmController {
36
- async promptForLoginAndConfirmJoin() {
36
+ async promptForLoginAndConfirmJoin(options) {
37
37
  //@ts-ignore
38
38
  LoginAndConfirmTestFixture.hitCount++;
39
+ LoginAndConfirmTestFixture.lastPromptOptions = options;
39
40
  return true;
40
41
  }
41
42
  }
@@ -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,6 +1,8 @@
1
+ import { PromptForLoginAndConfirmOptions } from '../../loggingInAndConfirmingJoin/LoginAndConfirmJoinController';
1
2
  export default class LoginAndConfirmTestFixture {
2
3
  private static hitCount;
3
4
  private static wasBeforeEachCalled;
5
+ static lastPromptOptions?: PromptForLoginAndConfirmOptions;
4
6
  static beforeEach(): void;
5
7
  static getHitCount(): number;
6
8
  private static assertBeforeEachWasCalled;
@@ -36,10 +36,11 @@ export default class LoginAndConfirmTestFixture {
36
36
  LoginAndConfirmTestFixture.hitCount = 0;
37
37
  LoginAndConfirmTestFixture.wasBeforeEachCalled = false;
38
38
  class CountingLoginAndConfirmController {
39
- promptForLoginAndConfirmJoin() {
39
+ promptForLoginAndConfirmJoin(options) {
40
40
  return __awaiter(this, void 0, void 0, function* () {
41
41
  //@ts-ignore
42
42
  LoginAndConfirmTestFixture.hitCount++;
43
+ LoginAndConfirmTestFixture.lastPromptOptions = options;
43
44
  return true;
44
45
  });
45
46
  }
@@ -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,8 +1,5 @@
1
- import { Authenticator, CardViewControllerImpl, ViewControllerFactory } from '@sprucelabs/heartwood-view-controllers';
1
+ import { Authenticator, CardViewControllerImpl, SpruceSchemas, ViewControllerFactory } from '@sprucelabs/heartwood-view-controllers';
2
2
  import { MercuryClient } from '@sprucelabs/mercury-client';
3
- export interface LoginAndConfirmJoinController {
4
- promptForLoginAndConfirmJoin(): Promise<boolean>;
5
- }
6
3
  export default class LoginAndConfirmJoinControllerImpl implements LoginAndConfirmJoinController {
7
4
  private views;
8
5
  protected vc: CardViewControllerImpl;
@@ -13,10 +10,11 @@ export default class LoginAndConfirmJoinControllerImpl implements LoginAndConfir
13
10
  private connectToApi;
14
11
  private client;
15
12
  private locationId?;
13
+ private confirmJoinContext?;
16
14
  protected constructor(options: LoginAndConfirmJoinOptions);
17
15
  static setClass(Class?: new () => LoginAndConfirmJoinController): void;
18
16
  static Controller(options: LoginAndConfirmJoinOptions): LoginAndConfirmJoinController;
19
- promptForLoginAndConfirmJoin(): Promise<boolean>;
17
+ promptForLoginAndConfirmJoin(options?: PromptForLoginAndConfirmOptions): Promise<boolean>;
20
18
  private listRoles;
21
19
  private confirmTheJoin;
22
20
  private promptForLogin;
@@ -24,11 +22,18 @@ export default class LoginAndConfirmJoinControllerImpl implements LoginAndConfir
24
22
  }
25
23
  export interface LoginAndConfirmJoinOptions {
26
24
  authenticator: Authenticator;
27
- views: Pick<ViewControllerFactory, 'Controller' | 'setController'>;
25
+ views: Pick<ViewControllerFactory, 'Controller' | 'setController' | 'hasController'>;
28
26
  organizationId: string;
29
27
  locationId?: string;
30
28
  connectToApi: ConnectToApi;
31
29
  }
32
30
  export declare type LoginAndConfirmJoinConstructor = new () => LoginAndConfirmJoinController;
33
31
  declare type ConnectToApi = () => Promise<MercuryClient>;
32
+ export declare type InviteViewContext = SpruceSchemas.Invite.v2021_12_16.InviteViewContext;
33
+ export interface PromptForLoginAndConfirmOptions {
34
+ confirmJoinViewContext?: InviteViewContext;
35
+ }
36
+ export interface LoginAndConfirmJoinController {
37
+ promptForLoginAndConfirmJoin(options?: PromptForLoginAndConfirmOptions): Promise<boolean>;
38
+ }
34
39
  export {};
@@ -24,18 +24,21 @@ export default class LoginAndConfirmJoinControllerImpl {
24
24
  }
25
25
  static Controller(options) {
26
26
  var _a;
27
- assertOptions(options, [
27
+ const { views } = assertOptions(options, [
28
28
  'authenticator',
29
29
  'views',
30
30
  'organizationId',
31
31
  'connectToApi',
32
32
  ]);
33
- options.views.setController('invite.confirm-join-card', ConfirmJoinCardViewController);
33
+ if (!views.hasController('invite.confirm-join-card')) {
34
+ views.setController('invite.confirm-join-card', ConfirmJoinCardViewController);
35
+ }
34
36
  return new ((_a = this.Class) !== null && _a !== void 0 ? _a : this)(options);
35
37
  }
36
- promptForLoginAndConfirmJoin() {
38
+ promptForLoginAndConfirmJoin(options) {
37
39
  return __awaiter(this, void 0, void 0, function* () {
38
40
  this.client = yield this.connectToApi();
41
+ this.confirmJoinContext = options === null || options === void 0 ? void 0 : options.confirmJoinViewContext;
39
42
  if (this.authenticator.isLoggedIn()) {
40
43
  return true;
41
44
  }
@@ -79,7 +82,7 @@ export default class LoginAndConfirmJoinControllerImpl {
79
82
  onError: () => { },
80
83
  organizationId: this.organizationId,
81
84
  authenticator: this.authenticator,
82
- viewContext: {},
85
+ viewContext: Object.assign({}, this.confirmJoinContext),
83
86
  });
84
87
  yield confirmVc.load();
85
88
  yield this.renderInDialogAndWait(confirmVc.render());
@@ -1,8 +1,5 @@
1
- import { Authenticator, CardViewControllerImpl, ViewControllerFactory } from '@sprucelabs/heartwood-view-controllers';
1
+ import { Authenticator, CardViewControllerImpl, SpruceSchemas, ViewControllerFactory } from '@sprucelabs/heartwood-view-controllers';
2
2
  import { MercuryClient } from '@sprucelabs/mercury-client';
3
- export interface LoginAndConfirmJoinController {
4
- promptForLoginAndConfirmJoin(): Promise<boolean>;
5
- }
6
3
  export default class LoginAndConfirmJoinControllerImpl implements LoginAndConfirmJoinController {
7
4
  private views;
8
5
  protected vc: CardViewControllerImpl;
@@ -13,10 +10,11 @@ export default class LoginAndConfirmJoinControllerImpl implements LoginAndConfir
13
10
  private connectToApi;
14
11
  private client;
15
12
  private locationId?;
13
+ private confirmJoinContext?;
16
14
  protected constructor(options: LoginAndConfirmJoinOptions);
17
15
  static setClass(Class?: new () => LoginAndConfirmJoinController): void;
18
16
  static Controller(options: LoginAndConfirmJoinOptions): LoginAndConfirmJoinController;
19
- promptForLoginAndConfirmJoin(): Promise<boolean>;
17
+ promptForLoginAndConfirmJoin(options?: PromptForLoginAndConfirmOptions): Promise<boolean>;
20
18
  private listRoles;
21
19
  private confirmTheJoin;
22
20
  private promptForLogin;
@@ -24,11 +22,18 @@ export default class LoginAndConfirmJoinControllerImpl implements LoginAndConfir
24
22
  }
25
23
  export interface LoginAndConfirmJoinOptions {
26
24
  authenticator: Authenticator;
27
- views: Pick<ViewControllerFactory, 'Controller' | 'setController'>;
25
+ views: Pick<ViewControllerFactory, 'Controller' | 'setController' | 'hasController'>;
28
26
  organizationId: string;
29
27
  locationId?: string;
30
28
  connectToApi: ConnectToApi;
31
29
  }
32
30
  export declare type LoginAndConfirmJoinConstructor = new () => LoginAndConfirmJoinController;
33
31
  declare type ConnectToApi = () => Promise<MercuryClient>;
32
+ export declare type InviteViewContext = SpruceSchemas.Invite.v2021_12_16.InviteViewContext;
33
+ export interface PromptForLoginAndConfirmOptions {
34
+ confirmJoinViewContext?: InviteViewContext;
35
+ }
36
+ export interface LoginAndConfirmJoinController {
37
+ promptForLoginAndConfirmJoin(options?: PromptForLoginAndConfirmOptions): Promise<boolean>;
38
+ }
34
39
  export {};
@@ -20,17 +20,20 @@ class LoginAndConfirmJoinControllerImpl {
20
20
  }
21
21
  static Controller(options) {
22
22
  var _a;
23
- (0, schema_1.assertOptions)(options, [
23
+ const { views } = (0, schema_1.assertOptions)(options, [
24
24
  'authenticator',
25
25
  'views',
26
26
  'organizationId',
27
27
  'connectToApi',
28
28
  ]);
29
- options.views.setController('invite.confirm-join-card', ConfirmJoinCard_vc_1.default);
29
+ if (!views.hasController('invite.confirm-join-card')) {
30
+ views.setController('invite.confirm-join-card', ConfirmJoinCard_vc_1.default);
31
+ }
30
32
  return new ((_a = this.Class) !== null && _a !== void 0 ? _a : this)(options);
31
33
  }
32
- async promptForLoginAndConfirmJoin() {
34
+ async promptForLoginAndConfirmJoin(options) {
33
35
  this.client = await this.connectToApi();
36
+ this.confirmJoinContext = options === null || options === void 0 ? void 0 : options.confirmJoinViewContext;
34
37
  if (this.authenticator.isLoggedIn()) {
35
38
  return true;
36
39
  }
@@ -70,7 +73,7 @@ class LoginAndConfirmJoinControllerImpl {
70
73
  onError: () => { },
71
74
  organizationId: this.organizationId,
72
75
  authenticator: this.authenticator,
73
- viewContext: {},
76
+ viewContext: Object.assign({}, this.confirmJoinContext),
74
77
  });
75
78
  await confirmVc.load();
76
79
  await this.renderInDialogAndWait(confirmVc.render());
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.3.2",
4
+ "version": "3.4.3",
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": {