@sprucelabs/spruce-people-utils 1.0.16 → 1.0.19
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__/behavioral/searching/SpyPersonSelectInput.d.ts +1 -0
- package/build/__tests__/behavioral/searching/SpyPersonSelectInput.js +3 -0
- package/build/esm/__tests__/behavioral/searching/SpyPersonSelectInput.d.ts +1 -0
- package/build/esm/__tests__/behavioral/searching/SpyPersonSelectInput.js +3 -0
- package/build/esm/viewControllers/PersonSelectInput.vc.d.ts +8 -2
- package/build/esm/viewControllers/PersonSelectInput.vc.js +46 -17
- package/build/esm/viewControllers/searchPeopleToSuggestions.d.ts +8 -1
- package/build/esm/viewControllers/searchPeopleToSuggestions.js +8 -5
- package/build/viewControllers/PersonSelectInput.vc.d.ts +8 -2
- package/build/viewControllers/PersonSelectInput.vc.js +40 -17
- package/build/viewControllers/searchPeopleToSuggestions.d.ts +8 -1
- package/build/viewControllers/searchPeopleToSuggestions.js +10 -6
- package/package.json +1 -1
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import PersonSelectInputViewController from '../../../viewControllers/PersonSelectInput.vc';
|
|
2
2
|
import SpyPersonInviteViewController from '../inviting/SpyPersonInviteViewController';
|
|
3
3
|
export default class SpyPersonSelectInput extends PersonSelectInputViewController {
|
|
4
|
+
getLastLoadedPersonId(): string | undefined;
|
|
4
5
|
getOrganizationId(): string | undefined;
|
|
5
6
|
getLocationId(): string | undefined;
|
|
6
7
|
getAutocompleteVc(): import("@sprucelabs/heartwood-view-controllers").AutocompleteInputViewController;
|
|
@@ -5,6 +5,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const PersonSelectInput_vc_1 = __importDefault(require("../../../viewControllers/PersonSelectInput.vc"));
|
|
7
7
|
class SpyPersonSelectInput extends PersonSelectInput_vc_1.default {
|
|
8
|
+
getLastLoadedPersonId() {
|
|
9
|
+
return this.lastLoadedPersonId;
|
|
10
|
+
}
|
|
8
11
|
getOrganizationId() {
|
|
9
12
|
return this.organizationId;
|
|
10
13
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import PersonSelectInputViewController from '../../../viewControllers/PersonSelectInput.vc';
|
|
2
2
|
import SpyPersonInviteViewController from '../inviting/SpyPersonInviteViewController';
|
|
3
3
|
export default class SpyPersonSelectInput extends PersonSelectInputViewController {
|
|
4
|
+
getLastLoadedPersonId(): string | undefined;
|
|
4
5
|
getOrganizationId(): string | undefined;
|
|
5
6
|
getLocationId(): string | undefined;
|
|
6
7
|
getAutocompleteVc(): import("@sprucelabs/heartwood-view-controllers").AutocompleteInputViewController;
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import PersonSelectInputViewController from '../../../viewControllers/PersonSelectInput.vc.js';
|
|
2
2
|
export default class SpyPersonSelectInput extends PersonSelectInputViewController {
|
|
3
|
+
getLastLoadedPersonId() {
|
|
4
|
+
return this.lastLoadedPersonId;
|
|
5
|
+
}
|
|
3
6
|
getOrganizationId() {
|
|
4
7
|
return this.organizationId;
|
|
5
8
|
}
|
|
@@ -1,12 +1,15 @@
|
|
|
1
|
-
import { AbstractViewController, AutocompleteInputViewController, FormInputViewController, SpruceSchemas, ViewControllerOptions } from '@sprucelabs/heartwood-view-controllers';
|
|
1
|
+
import { AbstractViewController, AutocompleteInputViewController, FormInputOptions, FormInputViewController, SpruceSchemas, ViewControllerOptions } from '@sprucelabs/heartwood-view-controllers';
|
|
2
2
|
export default class PersonSelectInputViewController extends AbstractViewController<AutocompleteInput> implements FormInputViewController<AutocompleteInput> {
|
|
3
3
|
static id: string;
|
|
4
4
|
protected autoCompleteVc: AutocompleteInputViewController;
|
|
5
5
|
protected organizationId?: string;
|
|
6
6
|
protected locationId?: string;
|
|
7
7
|
protected shouldIgnoreNextChange: boolean;
|
|
8
|
+
protected lastLoadedPersonId?: string;
|
|
9
|
+
private loadingPromise?;
|
|
8
10
|
constructor(options: ViewControllerOptions & PersonSelectInputOptions);
|
|
9
11
|
private handleFocusInput;
|
|
12
|
+
private renderAnonSuggestion;
|
|
10
13
|
private handleOnChangeRenderedValue;
|
|
11
14
|
private populateSuggestions;
|
|
12
15
|
private handleClickInviteAnonymous;
|
|
@@ -16,14 +19,17 @@ export default class PersonSelectInputViewController extends AbstractViewControl
|
|
|
16
19
|
private handleClickSuggestion;
|
|
17
20
|
setOrganizationId(orgId: string): void;
|
|
18
21
|
setLocationId(locationId: string): void;
|
|
22
|
+
waitForLoading(): Promise<void | undefined>;
|
|
19
23
|
getValue(): any;
|
|
20
24
|
setValue(value: string, renderedValue?: string | null | undefined): Promise<void>;
|
|
21
25
|
setRenderedValue(renderedValue: string): Promise<void>;
|
|
22
26
|
getRenderedValue(): any;
|
|
27
|
+
private loadCurrentPerson;
|
|
28
|
+
private _loadCurrentPerson;
|
|
23
29
|
render(): SpruceSchemas.HeartwoodViewControllers.v2021_02_11.AutocompleteInput;
|
|
24
30
|
}
|
|
25
31
|
declare type AutocompleteInput = SpruceSchemas.HeartwoodViewControllers.v2021_02_11.AutocompleteInput;
|
|
26
|
-
export interface PersonSelectInputOptions {
|
|
32
|
+
export interface PersonSelectInputOptions extends Pick<FormInputOptions, 'value'> {
|
|
27
33
|
organizationId?: string;
|
|
28
34
|
locationId?: string;
|
|
29
35
|
}
|
|
@@ -16,25 +16,22 @@ export default class PersonSelectInputViewController extends AbstractViewControl
|
|
|
16
16
|
this.shouldIgnoreNextChange = false;
|
|
17
17
|
this.organizationId = options.organizationId;
|
|
18
18
|
this.locationId = options.locationId;
|
|
19
|
-
this.autoCompleteVc = this.Controller('autocompleteInput', {
|
|
20
|
-
onChangeRenderedValue: this.handleOnChangeRenderedValue.bind(this),
|
|
21
|
-
renderedValue: '',
|
|
22
|
-
onFocus: this.handleFocusInput.bind(this),
|
|
23
|
-
});
|
|
19
|
+
this.autoCompleteVc = this.Controller('autocompleteInput', Object.assign(Object.assign({}, options), { onChangeRenderedValue: this.handleOnChangeRenderedValue.bind(this), renderedValue: '', onFocus: this.handleFocusInput.bind(this) }));
|
|
24
20
|
}
|
|
25
21
|
handleFocusInput() {
|
|
26
22
|
return __awaiter(this, void 0, void 0, function* () {
|
|
27
23
|
if (this.autoCompleteVc.getRenderedValue() === '') {
|
|
28
|
-
this.autoCompleteVc.showSuggestions([
|
|
29
|
-
{
|
|
30
|
-
id: 'anonymous',
|
|
31
|
-
label: 'Add anonymous',
|
|
32
|
-
onClick: this.handleClickInviteAnonymous.bind(this),
|
|
33
|
-
},
|
|
34
|
-
]);
|
|
24
|
+
this.autoCompleteVc.showSuggestions([this.renderAnonSuggestion()]);
|
|
35
25
|
}
|
|
36
26
|
});
|
|
37
27
|
}
|
|
28
|
+
renderAnonSuggestion() {
|
|
29
|
+
return {
|
|
30
|
+
id: 'anonymous',
|
|
31
|
+
label: 'Add anonymous',
|
|
32
|
+
onClick: this.handleClickInviteAnonymous.bind(this),
|
|
33
|
+
};
|
|
34
|
+
}
|
|
38
35
|
handleOnChangeRenderedValue(value) {
|
|
39
36
|
return __awaiter(this, void 0, void 0, function* () {
|
|
40
37
|
if (!this.shouldIgnoreNextChange && value.length > 2) {
|
|
@@ -56,11 +53,7 @@ export default class PersonSelectInputViewController extends AbstractViewControl
|
|
|
56
53
|
label: 'Invite person',
|
|
57
54
|
onClick: this.handleClickInvitePerson.bind(this),
|
|
58
55
|
},
|
|
59
|
-
|
|
60
|
-
id: 'anonymous',
|
|
61
|
-
label: 'Add anonymously',
|
|
62
|
-
onClick: this.handleClickInviteAnonymous.bind(this),
|
|
63
|
-
},
|
|
56
|
+
this.renderAnonSuggestion(),
|
|
64
57
|
]);
|
|
65
58
|
}
|
|
66
59
|
catch (err) {
|
|
@@ -123,6 +116,7 @@ export default class PersonSelectInputViewController extends AbstractViewControl
|
|
|
123
116
|
handleClickSuggestion(person) {
|
|
124
117
|
return __awaiter(this, void 0, void 0, function* () {
|
|
125
118
|
this.shouldIgnoreNextChange = true;
|
|
119
|
+
this.lastLoadedPersonId = person.id;
|
|
126
120
|
yield this.autoCompleteVc.setRenderedValue(renderLabel(person));
|
|
127
121
|
yield this.autoCompleteVc.setValue(person.id);
|
|
128
122
|
this.autoCompleteVc.hideSuggestions();
|
|
@@ -134,6 +128,11 @@ export default class PersonSelectInputViewController extends AbstractViewControl
|
|
|
134
128
|
setLocationId(locationId) {
|
|
135
129
|
this.locationId = locationId;
|
|
136
130
|
}
|
|
131
|
+
waitForLoading() {
|
|
132
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
133
|
+
return this.loadingPromise;
|
|
134
|
+
});
|
|
135
|
+
}
|
|
137
136
|
getValue() {
|
|
138
137
|
return this.autoCompleteVc.getValue();
|
|
139
138
|
}
|
|
@@ -146,7 +145,37 @@ export default class PersonSelectInputViewController extends AbstractViewControl
|
|
|
146
145
|
getRenderedValue() {
|
|
147
146
|
return this.autoCompleteVc.getRenderedValue();
|
|
148
147
|
}
|
|
148
|
+
loadCurrentPerson() {
|
|
149
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
150
|
+
this.loadingPromise = this._loadCurrentPerson();
|
|
151
|
+
return this.loadingPromise;
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
_loadCurrentPerson() {
|
|
155
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
156
|
+
const id = this.getValue();
|
|
157
|
+
if (id && this.lastLoadedPersonId !== id) {
|
|
158
|
+
this.lastLoadedPersonId = id;
|
|
159
|
+
yield this.setRenderedValue('Loading...');
|
|
160
|
+
try {
|
|
161
|
+
const client = yield this.connectToApi();
|
|
162
|
+
const [{ person }] = yield client.emitAndFlattenResponses('people.get::v2022_05_29', {
|
|
163
|
+
target: {
|
|
164
|
+
organizationId: this.organizationId,
|
|
165
|
+
searchPersonId: id,
|
|
166
|
+
},
|
|
167
|
+
});
|
|
168
|
+
yield this.setRenderedValue(renderLabel(person));
|
|
169
|
+
}
|
|
170
|
+
catch (err) {
|
|
171
|
+
console.error(err);
|
|
172
|
+
yield this.setRenderedValue('*** Failed loading person ***');
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
});
|
|
176
|
+
}
|
|
149
177
|
render() {
|
|
178
|
+
void this.loadCurrentPerson();
|
|
150
179
|
return this.autoCompleteVc.render();
|
|
151
180
|
}
|
|
152
181
|
}
|
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
import { AutocompleteSuggestion } from '@sprucelabs/heartwood-view-controllers';
|
|
2
2
|
import { SearchPerson } from '../types/people-module.types';
|
|
3
|
-
|
|
3
|
+
declare type SuggestionClickHandler = (person: SearchPerson) => Promise<void> | void;
|
|
4
|
+
export default function searchPeopleToSuggestions(people: SearchPerson[], cb?: SuggestionClickHandler): AutocompleteSuggestion[];
|
|
5
|
+
export declare function searchPersonToSuggestion(person: SearchPerson, cb?: SuggestionClickHandler): {
|
|
6
|
+
id: string;
|
|
7
|
+
label: string;
|
|
8
|
+
onClick: () => void | Promise<void> | undefined;
|
|
9
|
+
};
|
|
4
10
|
export declare function renderLabel(p: SearchPerson): string;
|
|
11
|
+
export {};
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
export default function searchPeopleToSuggestions(people, cb) {
|
|
2
|
-
return people.map((
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
return people.map((person) => searchPersonToSuggestion(person, cb));
|
|
3
|
+
}
|
|
4
|
+
export function searchPersonToSuggestion(person, cb) {
|
|
5
|
+
return {
|
|
6
|
+
id: person.id,
|
|
7
|
+
label: renderLabel(person),
|
|
8
|
+
onClick: () => cb === null || cb === void 0 ? void 0 : cb(person),
|
|
9
|
+
};
|
|
7
10
|
}
|
|
8
11
|
export function renderLabel(p) {
|
|
9
12
|
return `${p.fullName} (${p.phone})`;
|
|
@@ -1,12 +1,15 @@
|
|
|
1
|
-
import { AbstractViewController, AutocompleteInputViewController, FormInputViewController, SpruceSchemas, ViewControllerOptions } from '@sprucelabs/heartwood-view-controllers';
|
|
1
|
+
import { AbstractViewController, AutocompleteInputViewController, FormInputOptions, FormInputViewController, SpruceSchemas, ViewControllerOptions } from '@sprucelabs/heartwood-view-controllers';
|
|
2
2
|
export default class PersonSelectInputViewController extends AbstractViewController<AutocompleteInput> implements FormInputViewController<AutocompleteInput> {
|
|
3
3
|
static id: string;
|
|
4
4
|
protected autoCompleteVc: AutocompleteInputViewController;
|
|
5
5
|
protected organizationId?: string;
|
|
6
6
|
protected locationId?: string;
|
|
7
7
|
protected shouldIgnoreNextChange: boolean;
|
|
8
|
+
protected lastLoadedPersonId?: string;
|
|
9
|
+
private loadingPromise?;
|
|
8
10
|
constructor(options: ViewControllerOptions & PersonSelectInputOptions);
|
|
9
11
|
private handleFocusInput;
|
|
12
|
+
private renderAnonSuggestion;
|
|
10
13
|
private handleOnChangeRenderedValue;
|
|
11
14
|
private populateSuggestions;
|
|
12
15
|
private handleClickInviteAnonymous;
|
|
@@ -16,14 +19,17 @@ export default class PersonSelectInputViewController extends AbstractViewControl
|
|
|
16
19
|
private handleClickSuggestion;
|
|
17
20
|
setOrganizationId(orgId: string): void;
|
|
18
21
|
setLocationId(locationId: string): void;
|
|
22
|
+
waitForLoading(): Promise<void | undefined>;
|
|
19
23
|
getValue(): any;
|
|
20
24
|
setValue(value: string, renderedValue?: string | null | undefined): Promise<void>;
|
|
21
25
|
setRenderedValue(renderedValue: string): Promise<void>;
|
|
22
26
|
getRenderedValue(): any;
|
|
27
|
+
private loadCurrentPerson;
|
|
28
|
+
private _loadCurrentPerson;
|
|
23
29
|
render(): SpruceSchemas.HeartwoodViewControllers.v2021_02_11.AutocompleteInput;
|
|
24
30
|
}
|
|
25
31
|
declare type AutocompleteInput = SpruceSchemas.HeartwoodViewControllers.v2021_02_11.AutocompleteInput;
|
|
26
|
-
export interface PersonSelectInputOptions {
|
|
32
|
+
export interface PersonSelectInputOptions extends Pick<FormInputOptions, 'value'> {
|
|
27
33
|
organizationId?: string;
|
|
28
34
|
locationId?: string;
|
|
29
35
|
}
|
|
@@ -32,23 +32,20 @@ class PersonSelectInputViewController extends heartwood_view_controllers_1.Abstr
|
|
|
32
32
|
this.shouldIgnoreNextChange = false;
|
|
33
33
|
this.organizationId = options.organizationId;
|
|
34
34
|
this.locationId = options.locationId;
|
|
35
|
-
this.autoCompleteVc = this.Controller('autocompleteInput', {
|
|
36
|
-
onChangeRenderedValue: this.handleOnChangeRenderedValue.bind(this),
|
|
37
|
-
renderedValue: '',
|
|
38
|
-
onFocus: this.handleFocusInput.bind(this),
|
|
39
|
-
});
|
|
35
|
+
this.autoCompleteVc = this.Controller('autocompleteInput', Object.assign(Object.assign({}, options), { onChangeRenderedValue: this.handleOnChangeRenderedValue.bind(this), renderedValue: '', onFocus: this.handleFocusInput.bind(this) }));
|
|
40
36
|
}
|
|
41
37
|
async handleFocusInput() {
|
|
42
38
|
if (this.autoCompleteVc.getRenderedValue() === '') {
|
|
43
|
-
this.autoCompleteVc.showSuggestions([
|
|
44
|
-
{
|
|
45
|
-
id: 'anonymous',
|
|
46
|
-
label: 'Add anonymous',
|
|
47
|
-
onClick: this.handleClickInviteAnonymous.bind(this),
|
|
48
|
-
},
|
|
49
|
-
]);
|
|
39
|
+
this.autoCompleteVc.showSuggestions([this.renderAnonSuggestion()]);
|
|
50
40
|
}
|
|
51
41
|
}
|
|
42
|
+
renderAnonSuggestion() {
|
|
43
|
+
return {
|
|
44
|
+
id: 'anonymous',
|
|
45
|
+
label: 'Add anonymous',
|
|
46
|
+
onClick: this.handleClickInviteAnonymous.bind(this),
|
|
47
|
+
};
|
|
48
|
+
}
|
|
52
49
|
async handleOnChangeRenderedValue(value) {
|
|
53
50
|
if (!this.shouldIgnoreNextChange && value.length > 2) {
|
|
54
51
|
await this.populateSuggestions(value);
|
|
@@ -67,11 +64,7 @@ class PersonSelectInputViewController extends heartwood_view_controllers_1.Abstr
|
|
|
67
64
|
label: 'Invite person',
|
|
68
65
|
onClick: this.handleClickInvitePerson.bind(this),
|
|
69
66
|
},
|
|
70
|
-
|
|
71
|
-
id: 'anonymous',
|
|
72
|
-
label: 'Add anonymously',
|
|
73
|
-
onClick: this.handleClickInviteAnonymous.bind(this),
|
|
74
|
-
},
|
|
67
|
+
this.renderAnonSuggestion(),
|
|
75
68
|
]);
|
|
76
69
|
}
|
|
77
70
|
catch (err) {
|
|
@@ -126,6 +119,7 @@ class PersonSelectInputViewController extends heartwood_view_controllers_1.Abstr
|
|
|
126
119
|
}
|
|
127
120
|
async handleClickSuggestion(person) {
|
|
128
121
|
this.shouldIgnoreNextChange = true;
|
|
122
|
+
this.lastLoadedPersonId = person.id;
|
|
129
123
|
await this.autoCompleteVc.setRenderedValue((0, searchPeopleToSuggestions_1.renderLabel)(person));
|
|
130
124
|
await this.autoCompleteVc.setValue(person.id);
|
|
131
125
|
this.autoCompleteVc.hideSuggestions();
|
|
@@ -136,6 +130,9 @@ class PersonSelectInputViewController extends heartwood_view_controllers_1.Abstr
|
|
|
136
130
|
setLocationId(locationId) {
|
|
137
131
|
this.locationId = locationId;
|
|
138
132
|
}
|
|
133
|
+
async waitForLoading() {
|
|
134
|
+
return this.loadingPromise;
|
|
135
|
+
}
|
|
139
136
|
getValue() {
|
|
140
137
|
return this.autoCompleteVc.getValue();
|
|
141
138
|
}
|
|
@@ -148,7 +145,33 @@ class PersonSelectInputViewController extends heartwood_view_controllers_1.Abstr
|
|
|
148
145
|
getRenderedValue() {
|
|
149
146
|
return this.autoCompleteVc.getRenderedValue();
|
|
150
147
|
}
|
|
148
|
+
async loadCurrentPerson() {
|
|
149
|
+
this.loadingPromise = this._loadCurrentPerson();
|
|
150
|
+
return this.loadingPromise;
|
|
151
|
+
}
|
|
152
|
+
async _loadCurrentPerson() {
|
|
153
|
+
const id = this.getValue();
|
|
154
|
+
if (id && this.lastLoadedPersonId !== id) {
|
|
155
|
+
this.lastLoadedPersonId = id;
|
|
156
|
+
await this.setRenderedValue('Loading...');
|
|
157
|
+
try {
|
|
158
|
+
const client = await this.connectToApi();
|
|
159
|
+
const [{ person }] = await client.emitAndFlattenResponses('people.get::v2022_05_29', {
|
|
160
|
+
target: {
|
|
161
|
+
organizationId: this.organizationId,
|
|
162
|
+
searchPersonId: id,
|
|
163
|
+
},
|
|
164
|
+
});
|
|
165
|
+
await this.setRenderedValue((0, searchPeopleToSuggestions_1.renderLabel)(person));
|
|
166
|
+
}
|
|
167
|
+
catch (err) {
|
|
168
|
+
console.error(err);
|
|
169
|
+
await this.setRenderedValue('*** Failed loading person ***');
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
151
173
|
render() {
|
|
174
|
+
void this.loadCurrentPerson();
|
|
152
175
|
return this.autoCompleteVc.render();
|
|
153
176
|
}
|
|
154
177
|
}
|
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
import { AutocompleteSuggestion } from '@sprucelabs/heartwood-view-controllers';
|
|
2
2
|
import { SearchPerson } from '../types/people-module.types';
|
|
3
|
-
|
|
3
|
+
declare type SuggestionClickHandler = (person: SearchPerson) => Promise<void> | void;
|
|
4
|
+
export default function searchPeopleToSuggestions(people: SearchPerson[], cb?: SuggestionClickHandler): AutocompleteSuggestion[];
|
|
5
|
+
export declare function searchPersonToSuggestion(person: SearchPerson, cb?: SuggestionClickHandler): {
|
|
6
|
+
id: string;
|
|
7
|
+
label: string;
|
|
8
|
+
onClick: () => void | Promise<void> | undefined;
|
|
9
|
+
};
|
|
4
10
|
export declare function renderLabel(p: SearchPerson): string;
|
|
11
|
+
export {};
|
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.renderLabel = void 0;
|
|
3
|
+
exports.renderLabel = exports.searchPersonToSuggestion = void 0;
|
|
4
4
|
function searchPeopleToSuggestions(people, cb) {
|
|
5
|
-
return people.map((
|
|
6
|
-
id: p.id,
|
|
7
|
-
label: renderLabel(p),
|
|
8
|
-
onClick: () => cb === null || cb === void 0 ? void 0 : cb(p),
|
|
9
|
-
}));
|
|
5
|
+
return people.map((person) => searchPersonToSuggestion(person, cb));
|
|
10
6
|
}
|
|
11
7
|
exports.default = searchPeopleToSuggestions;
|
|
8
|
+
function searchPersonToSuggestion(person, cb) {
|
|
9
|
+
return {
|
|
10
|
+
id: person.id,
|
|
11
|
+
label: renderLabel(person),
|
|
12
|
+
onClick: () => cb === null || cb === void 0 ? void 0 : cb(person),
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
exports.searchPersonToSuggestion = searchPersonToSuggestion;
|
|
12
16
|
function renderLabel(p) {
|
|
13
17
|
return `${p.fullName} (${p.phone})`;
|
|
14
18
|
}
|