diff --git a/src/CompositionRoot.ts b/src/CompositionRoot.ts index 54f09cb..f54db51 100644 --- a/src/CompositionRoot.ts +++ b/src/CompositionRoot.ts @@ -71,7 +71,6 @@ import { CompleteEventTrackerUseCase } from "./domain/usecases/CompleteEventTrac import { UserGroupD2Repository } from "./data/repositories/UserGroupD2Repository"; import { UserGroupRepository } from "./domain/repositories/UserGroupRepository"; import { UserGroupTestRepository } from "./data/repositories/test/UserGroupTestRepository"; -import { GetUserGroupByCodeUseCase } from "./domain/usecases/GetUserGroupByCodeUseCase"; export type CompositionRoot = ReturnType; @@ -145,9 +144,6 @@ function getCompositionRoot(repositories: Repositories) { charts: { getCases: new GetChartConfigByTypeUseCase(repositories.chartConfigRepository), }, - userGroup: { - getByCode: new GetUserGroupByCodeUseCase(repositories.userGroupRepository), - }, }; } diff --git a/src/data/repositories/UserGroupD2Repository.ts b/src/data/repositories/UserGroupD2Repository.ts index 4f6caa3..a94b171 100644 --- a/src/data/repositories/UserGroupD2Repository.ts +++ b/src/data/repositories/UserGroupD2Repository.ts @@ -3,11 +3,12 @@ import { UserGroupRepository } from "../../domain/repositories/UserGroupReposito import { apiToFuture, FutureData } from "../api-futures"; import { assertOrError } from "./utils/AssertOrError"; import { UserGroup } from "../../domain/entities/UserGroup"; +import { RTSL_ZEBRA_INCIDENTMANAGER } from "./TeamMemberD2Repository"; export class UserGroupD2Repository implements UserGroupRepository { constructor(private api: D2Api) {} - getUserGroupByCode(code: string): FutureData { + getIncidentManagerUserGroupByCode(): FutureData { return apiToFuture( this.api.metadata.get({ userGroups: { @@ -15,12 +16,14 @@ export class UserGroupD2Repository implements UserGroupRepository { id: true, }, filter: { - code: { eq: code }, + code: { eq: RTSL_ZEBRA_INCIDENTMANAGER }, }, }, }) ) - .flatMap(response => assertOrError(response.userGroups[0], `User group ${code}`)) + .flatMap(response => + assertOrError(response.userGroups[0], `User group ${RTSL_ZEBRA_INCIDENTMANAGER}`) + ) .map(userGroup => userGroup); } } diff --git a/src/data/repositories/test/UserGroupTestRepository.ts b/src/data/repositories/test/UserGroupTestRepository.ts index 22e4fc7..c0f579b 100644 --- a/src/data/repositories/test/UserGroupTestRepository.ts +++ b/src/data/repositories/test/UserGroupTestRepository.ts @@ -4,7 +4,7 @@ import { UserGroupRepository } from "../../../domain/repositories/UserGroupRepos import { FutureData } from "../../api-futures"; export class UserGroupTestRepository implements UserGroupRepository { - getUserGroupByCode(_code: string): FutureData { + getIncidentManagerUserGroupByCode(): FutureData { return Future.success({ id: "1", }); diff --git a/src/domain/repositories/UserGroupRepository.ts b/src/domain/repositories/UserGroupRepository.ts index ac92a47..5693efc 100644 --- a/src/domain/repositories/UserGroupRepository.ts +++ b/src/domain/repositories/UserGroupRepository.ts @@ -2,5 +2,5 @@ import { FutureData } from "../../data/api-futures"; import { UserGroup } from "../entities/UserGroup"; export interface UserGroupRepository { - getUserGroupByCode(code: string): FutureData; + getIncidentManagerUserGroupByCode(): FutureData; } diff --git a/src/domain/usecases/GetConfigurationsUseCase.ts b/src/domain/usecases/GetConfigurationsUseCase.ts index c0e8f1a..11791bb 100644 --- a/src/domain/usecases/GetConfigurationsUseCase.ts +++ b/src/domain/usecases/GetConfigurationsUseCase.ts @@ -2,7 +2,6 @@ import { FutureData } from "../../data/api-futures"; import { Configurations, SelectableOptions } from "../entities/AppConfigurations"; import { Future } from "../entities/generic/Future"; import { TeamMember } from "../entities/incident-management-team/TeamMember"; -import { Code } from "../entities/Ref"; import { ConfigurationsRepository } from "../repositories/ConfigurationsRepository"; import { TeamMemberRepository } from "../repositories/TeamMemberRepository"; import { UserGroupRepository } from "../repositories/UserGroupRepository"; @@ -14,20 +13,14 @@ export class GetConfigurationsUseCase { private userGroupRepository: UserGroupRepository ) {} - public execute({ - incidentManagerUserGroupCode, - }: { - incidentManagerUserGroupCode: Code; - }): FutureData { + public execute(): FutureData { return Future.joinObj({ allTeamMembers: this.teamMemberRepository.getAll(), incidentResponseOfficers: this.teamMemberRepository.getIncidentResponseOfficers(), managers: this.teamMemberRepository.getIncidentManagers(), riskAssessors: this.teamMemberRepository.getRiskAssessors(), selectableOptionsResponse: this.configurationsRepository.getSelectableOptions(), - incidentManagerUserGroup: this.userGroupRepository.getUserGroupByCode( - incidentManagerUserGroupCode - ), + incidentManagerUserGroup: this.userGroupRepository.getIncidentManagerUserGroupByCode(), }).flatMap( ({ allTeamMembers, diff --git a/src/domain/usecases/GetUserGroupByCodeUseCase.ts b/src/domain/usecases/GetUserGroupByCodeUseCase.ts deleted file mode 100644 index 6a3d18c..0000000 --- a/src/domain/usecases/GetUserGroupByCodeUseCase.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { FutureData } from "../../data/api-futures"; -import { Code } from "../entities/Ref"; -import { UserGroup } from "../entities/UserGroup"; -import { UserGroupRepository } from "../repositories/UserGroupRepository"; - -export class GetUserGroupByCodeUseCase { - constructor(private userGroupRepository: UserGroupRepository) {} - - public execute(code: Code): FutureData { - return this.userGroupRepository.getUserGroupByCode(code); - } -} diff --git a/src/webapp/pages/app/App.tsx b/src/webapp/pages/app/App.tsx index b7da6f9..4d39c89 100644 --- a/src/webapp/pages/app/App.tsx +++ b/src/webapp/pages/app/App.tsx @@ -18,7 +18,6 @@ import { D2Api } from "../../../types/d2-api"; import "./App.css"; import { CurrentEventTrackerContextProvider } from "../../contexts/CurrentEventTrackerProvider"; import { ExistingEventTrackerTypesProvider } from "../../contexts/ExistingEventTrackerTypes"; -import { RTSL_ZEBRA_INCIDENTMANAGER } from "../../../data/repositories/TeamMemberD2Repository"; export interface AppProps { compositionRoot: CompositionRoot; @@ -39,7 +38,7 @@ function App(props: AppProps) { const orgUnits = await compositionRoot.orgUnits.getAll.execute().toPromise(); const configurations = await compositionRoot.diseaseOutbreakEvent.getConfigurations - .execute({ incidentManagerUserGroupCode: RTSL_ZEBRA_INCIDENTMANAGER }) + .execute() .toPromise(); const isDev = process.env.NODE_ENV === "development";