generated from EyeSeeTea/dhis2-app-skeleton
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: do not show existing diseases and hazard in create event dropdown
- Loading branch information
Showing
9 changed files
with
139 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { PropsWithChildren, useCallback, useState } from "react"; | ||
import { | ||
DiseaseNames, | ||
HazardNames, | ||
} from "../../domain/entities/disease-outbreak-event/PerformanceOverviewMetrics"; | ||
import { ExistingEventTrackerTypesContext } from "./existing-event-tracker-types-context"; | ||
|
||
export const ExistingEventTrackerTypesProvider: React.FC<PropsWithChildren> = ({ children }) => { | ||
const [existingEventTrackerTypes, setExistingEventTrackerTypes] = useState< | ||
(DiseaseNames | HazardNames)[] | ||
>([]); | ||
|
||
const changeExistingEventTrackerTypes = useCallback( | ||
(updatedExistingEventTrackerTypes: (DiseaseNames | HazardNames)[]) => { | ||
setExistingEventTrackerTypes(updatedExistingEventTrackerTypes); | ||
}, | ||
[] | ||
); | ||
|
||
return ( | ||
<ExistingEventTrackerTypesContext.Provider | ||
value={{ | ||
existingEventTrackerTypes, | ||
changeExistingEventTrackerTypes, | ||
}} | ||
> | ||
{children} | ||
</ExistingEventTrackerTypesContext.Provider> | ||
); | ||
}; |
26 changes: 26 additions & 0 deletions
26
src/webapp/contexts/existing-event-tracker-types-context.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { createContext, useContext } from "react"; | ||
import { | ||
DiseaseNames, | ||
HazardNames, | ||
} from "../../domain/entities/disease-outbreak-event/PerformanceOverviewMetrics"; | ||
|
||
export interface ExistingEventTrackerTypesProps { | ||
existingEventTrackerTypes: (DiseaseNames | HazardNames)[]; | ||
changeExistingEventTrackerTypes: ( | ||
existingEventTrackerTypes: (DiseaseNames | HazardNames)[] | ||
) => void; | ||
} | ||
|
||
export const ExistingEventTrackerTypesContext = createContext<ExistingEventTrackerTypesProps>({ | ||
existingEventTrackerTypes: [], | ||
changeExistingEventTrackerTypes: () => {}, | ||
}); | ||
|
||
export function useExistingEventTrackerTypes() { | ||
const context = useContext(ExistingEventTrackerTypesContext); | ||
if (context) { | ||
return context; | ||
} else { | ||
throw new Error("Existing Event Tracker Types context uninitialized"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters