import config from './config'; import { ImpactedUsersServiceMock } from '../../user-insights/mocks/services/impacted-users.service.mock'; import { ImpactedUsersService } from '../../user-insights/components/middle-status/components/impacted-users/impacted-users.service'; import { TotalTicketsServiceMock } from '../../user-insights/mocks/services/total-tickets.service.mock'; import { TotalTicketsService } from '../../user-insights/components/middle-status/components/total-tickets/total-tickets.service'; import { TimeToResolutionServiceMock } from '../../user-insights/mocks/services/time-to-resolution.service.mock'; import { TimeToResolutionService } from '../../user-insights/components/middle-status/components/time-to-resolution/time-to-resolution.service'; import { PersonasServiceMock } from '../../user-insights/mocks/services/personas.service.mock'; import { PersonasService } from '../../user-insights/components/bottom-details/components/personas/personas.service'; import { LocationsServiceMock } from '../../user-insights/mocks/services/locations.service.mock'; import { LocationsService } from '../../user-insights/components/bottom-details/components/locations/locations.service'; import { IssueTypesServiceMock } from '../../user-insights/mocks/services/issue-types.service.mock'; import { IssueTypesService } from '../../user-insights/components/bottom-details/components/issue-types/issue-types.service'; import { TopChallengesServiceMock } from '../../user-insights/mocks/services/top-challenges.service.mock'; import { TopChallengesService } from '../../user-insights/components/bottom-details/components/top-challenges/top-challenges.service'; import { TopOpportunitesServiceMock } from '../../user-insights/mocks/services/top-opportunites.service.mock'; import { TopOpportunitiesService } from '../../user-insights/components/bottom-details/components/top-opportunities/top-opportunities.service'; import { ApplicationsServiceMock } from '../../device-insights/mocks/services/applications.service.mock'; import { ApplicationsService } from '../../device-insights/components/middle-status/components/applications/applications.service'; import { DevicesServiceMock } from '../../device-insights/mocks/services/devices.service.mock'; import { DevicesService } from '../../device-insights/components/middle-status/components/devices/devices.service'; import { TimeToResolutionDeviceServiceMock } from '../../device-insights/mocks/services/time-to-resolution-device.service.mock'; import { TimeToResolutionDeviceService } from '../../device-insights/components/middle-status/components/time-to-resolution/time-to-resolution.service'; import { IssueTypesDeviceServiceMock } from '../../device-insights/mocks/services/issue-types.service.mock'; import { IssueTypesDeviceService } from '../../device-insights/components/bottom-details/components/issue-types/issue-types.service'; import { TopApplicationsServiceMock } from '../../device-insights/mocks/services/top-applications.service.mock'; import { TopApplicationsService } from '../../device-insights/components/bottom-details/components/top-applications/top-applications.service'; import { TopDevicesServiceMock } from '../../device-insights/mocks/services/top-devices.service.mock'; import { TopDevicesService } from '../../device-insights/components/bottom-details/components/top-devices/top-devices.service'; import { TopFilterServiceMock } from '../../user-insights/mocks/services/top-filter.service.mock'; import { TopFilterService } from '../../user-insights/components/top-filter/top-filter.service'; import { IssueCategoriesServiceMock } from '../../user-insights/mocks/services/issue-categories.service.mock'; import { IssueCategoriesService } from '../../user-insights/components/bottom-details/components/issue-categories/issue-categories.service'; import { IssueCategoriesService as DeviceIssueCategoriesService } from '../../device-insights/components/bottom-details/components/issue-categories/issue-categories.service'; import { TopFilterServiceMock as DeviceTopFilterServiceMock } from '../../device-insights/mocks/services/top-filter.service.mock'; import { TopFilterService as DeviceTopFilterService } from '../../device-insights/components/top-filter/top-filter.service'; import { TopFilterServiceMock as PersonaTopFilterServiceMock } from '../../persona-detail/mocks/services/top-filter.service.mock'; import { TopFilterService as PersonaTopFilterService } from '../../persona-detail/components/top-filter/top-filter.service'; import { PersonaSummaryServiceMock } from '../../persona-detail/mocks/services/persona-summary.service.mock'; import { PersonalSummaryService } from '../../persona-detail/components/persona-summary/personal-summary.service'; const SERVICE_REGISTRY: any = {}; export enum SERVICE_TYPES { USER_INSIGHT_IMPACTED_USERS, USER_INSIGHT_TOTAL_TICKETS, TIME_TO_RESOLUTION, PERSONA, LOCATIONS, ISSUE_TYPES, TOP_CHALLENGES, TOP_OPPORTUNITIES, APPLICATIONS, DEVICES, TIME_TO_RESOLUTION_DEVICE, ISSUE_TYPES_DEVICE, TOP_APPLICATIONS, TOP_DEVICES, USER_INSIGHTS_FILTER_OPTION, USER_INSIGHT_ISSUE_CATEGORIES, DEVICE_INSIGHT_FILTER_OPTION, DEVICE_INSIGHT_ISSUE_CATEGORIES, PERSONA_DETAIL_FILTER_OPTION, PERSONA_DETAIL_SUMMARY, } const getServiceInstance = (type: SERVICE_TYPES): any => { if (!(type in SERVICE_REGISTRY)) { SERVICE_REGISTRY[type] = {}; } const fkType = '' + config.usingMock; if (!(fkType in SERVICE_REGISTRY[type])) { switch (type) { case SERVICE_TYPES.USER_INSIGHT_IMPACTED_USERS: SERVICE_REGISTRY[type][fkType] = config.usingMock ? new ImpactedUsersServiceMock() : new ImpactedUsersService(); break; case SERVICE_TYPES.USER_INSIGHT_TOTAL_TICKETS: SERVICE_REGISTRY[type][fkType] = config.usingMock ? new TotalTicketsServiceMock() : new TotalTicketsService(); break; case SERVICE_TYPES.TIME_TO_RESOLUTION: SERVICE_REGISTRY[type][fkType] = config.usingMock ? new TimeToResolutionServiceMock() : new TimeToResolutionService(); break; case SERVICE_TYPES.PERSONA: SERVICE_REGISTRY[type][fkType] = config.usingMock ? new PersonasServiceMock() : new PersonasService(); break; case SERVICE_TYPES.LOCATIONS: SERVICE_REGISTRY[type][fkType] = config.usingMock ? new LocationsServiceMock() : new LocationsService(); break; case SERVICE_TYPES.ISSUE_TYPES: SERVICE_REGISTRY[type][fkType] = config.usingMock ? new IssueTypesServiceMock() : new IssueTypesService(); break; case SERVICE_TYPES.TOP_CHALLENGES: SERVICE_REGISTRY[type][fkType] = config.usingMock ? new TopChallengesServiceMock() : new TopChallengesService(); break; case SERVICE_TYPES.TOP_OPPORTUNITIES: SERVICE_REGISTRY[type][fkType] = config.usingMock ? new TopOpportunitesServiceMock() : new TopOpportunitiesService(); break; case SERVICE_TYPES.APPLICATIONS: SERVICE_REGISTRY[type][fkType] = config.usingMock ? new ApplicationsServiceMock() : new ApplicationsService(); break; case SERVICE_TYPES.DEVICES: SERVICE_REGISTRY[type][fkType] = config.usingMock ? new DevicesServiceMock() : new DevicesService(); break; case SERVICE_TYPES.TIME_TO_RESOLUTION_DEVICE: SERVICE_REGISTRY[type][fkType] = config.usingMock ? new TimeToResolutionDeviceServiceMock() : new TimeToResolutionDeviceService(); break; case SERVICE_TYPES.ISSUE_TYPES_DEVICE: SERVICE_REGISTRY[type][fkType] = config.usingMock ? new IssueTypesDeviceServiceMock() : new IssueTypesDeviceService(); break; case SERVICE_TYPES.TOP_APPLICATIONS: SERVICE_REGISTRY[type][fkType] = config.usingMock ? new TopApplicationsServiceMock() : new TopApplicationsService(); break; case SERVICE_TYPES.TOP_DEVICES: SERVICE_REGISTRY[type][fkType] = config.usingMock ? new TopDevicesServiceMock() : new TopDevicesService(); break; case SERVICE_TYPES.USER_INSIGHTS_FILTER_OPTION: SERVICE_REGISTRY[type][fkType] = config.usingMock ? new TopFilterServiceMock() : new TopFilterService(); break; case SERVICE_TYPES.USER_INSIGHT_ISSUE_CATEGORIES: SERVICE_REGISTRY[type][fkType] = config.usingMock ? new IssueCategoriesServiceMock() : new IssueCategoriesService(); break; // Start Device Insight case SERVICE_TYPES.DEVICE_INSIGHT_FILTER_OPTION: SERVICE_REGISTRY[type][fkType] = config.usingMock ? new DeviceTopFilterServiceMock() : new DeviceTopFilterService(); break; case SERVICE_TYPES.DEVICE_INSIGHT_ISSUE_CATEGORIES: SERVICE_REGISTRY[type][fkType] = config.usingMock ? new IssueCategoriesServiceMock() : new DeviceIssueCategoriesService(); break; // Start Persona Detail APIs case SERVICE_TYPES.PERSONA_DETAIL_FILTER_OPTION: SERVICE_REGISTRY[type][fkType] = config.usingMock ? new PersonaTopFilterServiceMock() : new PersonaTopFilterService(); break; case SERVICE_TYPES.PERSONA_DETAIL_SUMMARY: SERVICE_REGISTRY[type][fkType] = config.usingMock ? new PersonaSummaryServiceMock() : new PersonalSummaryService(); break; } } return SERVICE_REGISTRY[type][fkType]; }; export default getServiceInstance;