import { IWebPartContext } from '@microsoft/sp-webpart-base' ; import { Environment , EnvironmentType } from '@microsoft/sp-core-library' ; import { ICrmDataProvider } from '../dataProviders/ICrmDataProvider' ; import MockCrmDataProvider from '../dataProviders/MockCrmDataProvider' ; import SharePointCrmDataProvider from '../dataProviders/SharePointCrmDataProvider' ; export default class CrmManager { private _context : IWebPartContext ; private _data : ICrmDataProvider ; public get data ( ) : ICrmDataProvider { return this . _data ; } public get userLoginName ( ) : string { return this . _context . pageContext . user . loginName ; } constructor ( context ) { this . _context = context ; if ( Environment . type == EnvironmentType . Local ) { this . _data = new MockCrmDataProvider ( ) ; } else { const spcrmdata = new SharePointCrmDataProvider ( context ) ; spcrmdata . meUserLoginName = this . _context . pageContext . user . loginName ; this . _data = spcrmdata ; } this . _data . selectedOrganizationList = this . _data . defaultOrganizationList ; this . _data . selectedPersonList = this . _data . defaultPersonList ; this . _data . selectedTagList = this . _data . defaultTagList ; } }