@@ -13,13 +13,13 @@ import { isEqual } from '@microsoft/sp-lodash-subset';
13
13
14
14
export class LocationPicker extends React . Component < ILocationPickerProps , ILocationPickerState > {
15
15
private _token : string | string [ ] = null ;
16
- private focusRef : any = null ;
16
+ private focusRef : any = null ; // eslint-disable-line @typescript-eslint/no-implicit-any
17
17
/**
18
18
* Constructor method
19
19
*/
20
20
constructor ( props : ILocationPickerProps ) {
21
21
super ( props ) ;
22
- this . getToken ( ) ;
22
+ this . getToken ( ) . then ( ( ) => { /* no-op; */ } ) . catch ( ( ) => { /* no-op; */ } ) ;
23
23
this . focusRef = React . createRef ( ) ;
24
24
if ( props . defaultValue ) {
25
25
this . state = {
@@ -42,7 +42,7 @@ export class LocationPicker extends React.Component<ILocationPickerProps, ILocat
42
42
43
43
}
44
44
45
- public UNSAFE_componentWillReceiveProps ( nextProps : ILocationPickerProps ) {
45
+ public UNSAFE_componentWillReceiveProps ( nextProps : ILocationPickerProps ) : void {
46
46
if ( ! isEqual ( nextProps . defaultValue , this . props . defaultValue ) ) {
47
47
if ( nextProps . defaultValue ) {
48
48
this . setState ( { selectedItem : nextProps . defaultValue , currentMode : Mode . view } ) ;
@@ -64,7 +64,7 @@ export class LocationPicker extends React.Component<ILocationPickerProps, ILocat
64
64
) ;
65
65
}
66
66
67
- private onRenderOption = ( item : ILocationBoxOption ) => {
67
+ private onRenderOption = ( item : ILocationBoxOption ) : JSX . Element => {
68
68
const {
69
69
text,
70
70
locationItem
@@ -107,7 +107,7 @@ export class LocationPicker extends React.Component<ILocationPickerProps, ILocat
107
107
openOnKeyboardFocus = { true }
108
108
scrollSelectedToTop = { true }
109
109
isButtonAriaHidden = { true }
110
- onInput = { ( e ) => this . getLocatios ( e . target [ "value" ] ) }
110
+ onInput = { ( e ) => this . getLocatios ( e . target [ "value" ] ) } // eslint-disable-line dot-notation
111
111
onChange = { this . onChange }
112
112
errorMessage = { errorMessage }
113
113
/> ;
@@ -212,30 +212,30 @@ export class LocationPicker extends React.Component<ILocationPickerProps, ILocat
212
212
return `${ address . Street ? address . Street + ", " : '' } ${ address . City ? address . City + ", " : "" } ${ address . State ? address . State + ", " : '' } ${ address . CountryOrRegion || "" } ` ;
213
213
}
214
214
215
- private onIconButtonClick = ( ) => {
215
+ private onIconButtonClick = ( ) : void => {
216
216
this . setState ( { currentMode : Mode . empty , selectedItem : null } ) ;
217
217
if ( this . props . onChange ) {
218
218
this . props . onChange ( null ) ;
219
219
}
220
220
}
221
221
222
- private onClick = ( ) => {
222
+ private onClick = ( ) : void => {
223
223
this . setState ( { currentMode : Mode . editView } ,
224
224
( ) => {
225
225
if ( this . focusRef . current !== null )
226
226
this . focusRef . current . focus ( ) ;
227
227
} ) ;
228
228
}
229
229
230
- private onBlur = ( ev ) => {
230
+ private onBlur = ( ev ) : void => {
231
231
try {
232
- if ( ev !== null && ev . relatedTarget [ "title" ] !== "Location" && ev . relatedTarget [ "title" ] !== "Clear" ) {
232
+ if ( ev !== null && ev . relatedTarget [ "title" ] !== "Location" && ev . relatedTarget [ "title" ] !== "Clear" ) { // eslint-disable-line dot-notation
233
233
this . setState ( { currentMode : Mode . view } ) ;
234
234
}
235
- } catch { }
235
+ } catch { /* no-op; */ }
236
236
}
237
237
238
- private onChange = ( ev , option : ILocationBoxOption ) => {
238
+ private onChange = ( ev , option : ILocationBoxOption ) : void => {
239
239
this . setState ( { selectedItem : option . locationItem , currentMode : Mode . editView } ,
240
240
( ) => {
241
241
if ( this . focusRef . current !== null )
@@ -247,14 +247,14 @@ export class LocationPicker extends React.Component<ILocationPickerProps, ILocat
247
247
}
248
248
}
249
249
250
- private customRenderInitials ( props ) {
250
+ private customRenderInitials ( props ) : JSX . Element {
251
251
if ( props . imageAlt === "Custom" )
252
252
return < FontIcon aria-label = "Poi" iconName = "Poi" style = { { fontSize : "14pt" } } /> ;
253
253
else
254
254
return < FontIcon aria-label = "EMI" iconName = "EMI" style = { { fontSize : "14pt" } } /> ;
255
255
}
256
256
257
- private async getToken ( ) {
257
+ private async getToken ( ) : Promise < void > {
258
258
const requestHeaders : Headers = new Headers ( ) ;
259
259
requestHeaders . append ( "Content-type" , "application/json" ) ;
260
260
requestHeaders . append ( "Cache-Control" , "no-cache" ) ;
@@ -263,14 +263,14 @@ export class LocationPicker extends React.Component<ILocationPickerProps, ILocat
263
263
headers : requestHeaders
264
264
} ;
265
265
266
- let response : SPHttpClientResponse = await this . props . context . spHttpClient . post ( `${ this . props . context . pageContext . web . absoluteUrl } /_api/SP.OAuth.Token/Acquire` , SPHttpClient . configurations . v1 , spOpts ) ;
267
- let PrimaryQueryResult : any = await response . json ( ) ;
266
+ const response : SPHttpClientResponse = await this . props . context . spHttpClient . post ( `${ this . props . context . pageContext . web . absoluteUrl } /_api/SP.OAuth.Token/Acquire` , SPHttpClient . configurations . v1 , spOpts ) ;
267
+ const PrimaryQueryResult : any = await response . json ( ) ;
268
268
this . _token = PrimaryQueryResult . access_token ;
269
269
}
270
270
271
- private async getLocatios ( searchText ) {
271
+ private async getLocatios ( searchText ) : Promise < void > {
272
272
try {
273
- let optionsForCustomRender : ILocationBoxOption [ ] = [ ] ;
273
+ const optionsForCustomRender : ILocationBoxOption [ ] = [ ] ;
274
274
const requestHeaders : Headers = new Headers ( ) ;
275
275
requestHeaders . append ( "Content-type" , "application/json" ) ;
276
276
requestHeaders . append ( "Cache-Control" , "no-cache" ) ;
@@ -279,12 +279,12 @@ export class LocationPicker extends React.Component<ILocationPickerProps, ILocat
279
279
body : `{"QueryConstraint":{"Query":"${ searchText } "},"LocationProvider":32,"BingMarket":"en-IN"}` ,
280
280
headers : requestHeaders
281
281
} ;
282
- let response1 : HttpClientResponse = await this . props . context . httpClient . post ( "https://outlook.office365.com/SchedulingB2/api/v1.0/me/findmeetinglocations" , HttpClient . configurations . v1 , spOpts ) ;
283
- let json = await response1 . json ( ) ;
282
+ const response1 : HttpClientResponse = await this . props . context . httpClient . post ( "https://outlook.office365.com/SchedulingB2/api/v1.0/me/findmeetinglocations" , HttpClient . configurations . v1 , spOpts ) ;
283
+ const json = await response1 . json ( ) ;
284
284
285
285
286
286
json . MeetingLocations . forEach ( ( v , i ) => {
287
- let loc : ILocationPickerItem = v [ "MeetingLocation" ] ;
287
+ const loc : ILocationPickerItem = v [ "MeetingLocation" ] ;
288
288
optionsForCustomRender . push ( { text : v . MeetingLocation [ "DisplayName" ] , key : i , locationItem : loc } ) ;
289
289
} ) ;
290
290
0 commit comments