forked from trailheadapps/easy-spaces-lwc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcustomerList.js
48 lines (40 loc) · 1.39 KB
/
customerList.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import { LightningElement, api, track, wire } from 'lwc';
import { refreshApex } from '@salesforce/apex';
import getCustomerList from '@salesforce/apex/reservationManagerController.getCustomerList';
import { CurrentPageReference } from 'lightning/navigation';
import { registerListener, unregisterAllListeners, fireEvent } from 'c/pubsub';
export default class CustomerList extends LightningElement {
@api sobject;
@track customers;
@track errorMsg;
@track showDetails;
@track msgForUser;
wiredRecords;
@wire(CurrentPageReference) pageRef;
connectedCallback() {
registerListener('flowfinish', this.handleFlowFinish, this);
}
disconnectedCallback() {
unregisterAllListeners(this);
}
@wire(getCustomerList, { sObjectType: '$sobject' })
wiredCustomerData(value) {
this.wiredRecords = value;
if (value.error) {
this.errorMsg = value.error;
this.msgForUser = 'There was an issue loading customers.';
this.showDetails = false;
} else if (value.data) {
this.customers = value.data;
}
}
handleFlowFinish(event) {
if (event.detail === this.sobject) {
return refreshApex(this.wiredRecords);
}
return undefined;
}
publishSelect(event) {
fireEvent(this.pageRef, 'selectcustomer', { detail: event.detail });
}
}