Skip to content

Commit

Permalink
refactor: remove dispatch any
Browse files Browse the repository at this point in the history
  • Loading branch information
pl-buiquang authored May 4, 2023
1 parent 6b18120 commit f6ece0c
Show file tree
Hide file tree
Showing 48 changed files with 195 additions and 192 deletions.
10 changes: 5 additions & 5 deletions src/components/CreationCohort/ControlPanel/ControlPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -117,15 +117,15 @@ const ControlPanel: React.FC<{
if (logicalOperatorNeedToBeErase && logicalOperatorNeedToBeErase.length > 0) {
for (const logicalOperator of logicalOperatorNeedToBeErase) {
const { id } = logicalOperator
dispatch<any>(deleteCriteriaGroup(id))
dispatch(deleteCriteriaGroup(id))
}
}
dispatch<any>(buildCohortCreation({}))
dispatch(buildCohortCreation({}))
}

const _relaunchCount = (keepCount: boolean) => {
if (keepCount) setOldCount(count ?? null)
dispatch<any>(
dispatch(
countCohortCreation({
json,
snapshotId: currentSnapshot,
Expand All @@ -151,7 +151,7 @@ const ControlPanel: React.FC<{
useEffect(() => {
const interval = setInterval(() => {
if (count && count.status && (count.status === 'pending' || count.status === 'started')) {
dispatch<any>(countCohortCreation({ uuid: count.uuid }))
dispatch(countCohortCreation({ uuid: count.uuid }))
} else {
clearInterval(interval)
}
Expand Down Expand Up @@ -198,7 +198,7 @@ const ControlPanel: React.FC<{

<Button
onClick={() => {
dispatch<any>(resetCohortCreation())
dispatch(resetCohortCreation())
}}
className={classes.actionButton}
startIcon={<UpdateSharpIcon color="action" className={classes.iconBorder} />}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ const CohortCreationBreadcrumbs: React.FC = () => {

useEffect(() => {
if (!projects || (projects && projects.length === 0)) {
dispatch<any>(fetchProjectsList())
dispatch(fetchProjectsList())
} else if (!requests || (requests && requests.length === 0)) {
dispatch<any>(fetchRequestsList())
dispatch(fetchRequestsList())
} else {
const foundItem = requests.find(({ uuid }) => uuid === requestId)
if (foundItem) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,23 +172,23 @@ const LogicalOperator: React.FC = () => {
const [selectedCriteria, setSelectedCriteria] = useState<SelectedCriteriaType | null>(null)

const _buildCohortCreation = () => {
dispatch<any>(buildCohortCreation({}))
dispatch(buildCohortCreation({}))
}

const _onConfirmAddOrEditCriteria = async (item: SelectedCriteriaType) => {
// Add criteria
const nextCriteriaId = request.nextCriteriaId
if (item.id !== undefined) {
// Edition
await dispatch<any>(editSelectedCriteria(item))
await dispatch(editSelectedCriteria(item))
} else {
// Creation
item.id = nextCriteriaId
await dispatch<any>(addNewSelectedCriteria(item))
await dispatch(addNewSelectedCriteria(item))
// Link criteria with group operator
const currentParent = request.criteriaGroup ? request.criteriaGroup.find(({ id }) => id === parentId) : null
if (!currentParent) return
await dispatch<any>(
await dispatch(
editCriteriaGroup({
...currentParent,
criteriaIds: [...currentParent.criteriaIds, nextCriteriaId]
Expand All @@ -211,9 +211,9 @@ const LogicalOperator: React.FC = () => {
isSubGroup: parentId === 0 ? false : true,
isInclusive: true
}
await dispatch<any>(addNewCriteriaGroup(newOperator))
await dispatch(addNewCriteriaGroup(newOperator))
// Edit parent and add nextGroupId inside criteriaIds
await dispatch<any>(
await dispatch(
editCriteriaGroup({
...currentParent,
criteriaIds: [...currentParent.criteriaIds, nextGroupId]
Expand All @@ -223,26 +223,26 @@ const LogicalOperator: React.FC = () => {
}

const _addNewCriteria = (parentId: number) => {
dispatch<any>(suspendCount())
dispatch(suspendCount())
setOpenDrawer('criteria')
setParentId(parentId)
setSelectedCriteria(null)
}

const _editCriteria = (criteria: SelectedCriteriaType, parentId: number) => {
dispatch<any>(suspendCount())
dispatch(suspendCount())
setOpenDrawer('criteria')
setParentId(parentId)
setSelectedCriteria(criteria)
}

const _deleteCriteria = async (criteriaId: number) => {
await dispatch<any>(deleteSelectedCriteria(criteriaId))
await dispatch(deleteSelectedCriteria(criteriaId))
_buildCohortCreation()
}

const _duplicateCriteria = async (criteriaId: number) => {
await dispatch<any>(duplicateSelectedCriteria(criteriaId))
await dispatch(duplicateSelectedCriteria(criteriaId))
_buildCohortCreation()
}

Expand All @@ -264,7 +264,7 @@ const LogicalOperator: React.FC = () => {
onChangeSelectedCriteria={_onConfirmAddOrEditCriteria}
open={openDrawer === 'criteria'}
onClose={() => {
dispatch<any>(unsuspendCount())
dispatch(unsuspendCount())
setOpenDrawer(null)
}}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ const BiologyForm: React.FC<BiologyFormProps> = (props) => {
return setError(true)
}
onChangeSelectedCriteria(currentState)
dispatch<any>(fetchBiology())
dispatch(fetchBiology())
}

const defaultValuesCode = currentState.code
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ const BiologyListItem: React.FC<BiologyListItemProps> = (props) => {
const isIndeterminated = checkIfIndeterminated(biologyItem, selectedItems)
const _onExpand = async (biologyCode: string) => {
if (isLoadingsyncHierarchyTable > 0 || isLoadingPmsi > 0) return
dispatch<any>(incrementLoadingSyncHierarchyTable())
dispatch(incrementLoadingSyncHierarchyTable())
setOpen(!open)
const newHierarchy = await expandItem(
biologyCode,
Expand All @@ -65,15 +65,15 @@ const BiologyListItem: React.FC<BiologyListItemProps> = (props) => {
dispatch
)
await handleClick(selectedItems, newHierarchy)
dispatch<any>(decrementLoadingSyncHierarchyTable())
dispatch(decrementLoadingSyncHierarchyTable())
}

const handleClickOnHierarchy = async (biologyItem: PmsiListType) => {
if (isLoadingsyncHierarchyTable > 0 || isLoadingPmsi > 0) return
dispatch<any>(incrementLoadingSyncHierarchyTable())
dispatch(incrementLoadingSyncHierarchyTable())
const newSelectedItems = getSelectedPmsi(biologyItem, selectedItems || [], biologyHierarchy)
await handleClick(newSelectedItems)
dispatch<any>(decrementLoadingSyncHierarchyTable())
dispatch(decrementLoadingSyncHierarchyTable())
}

if (!subItems || (subItems && Array.isArray(subItems) && subItems.length === 0)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const CcamForm: React.FC<CcamFormProps> = (props) => {
return setError(true)
}
onChangeSelectedCriteria(currentState)
dispatch<any>(fetchProcedure())
dispatch(fetchProcedure())
}

const getCCAMOptions = async (searchValue: string) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ const ProcedureListItem: React.FC<ProcedureListItemProps> = (props) => {
const isIndeterminated = checkIfIndeterminated(procedureItem, selectedItems)
const _onExpand = async (procedureCode: string) => {
if (isLoadingsyncHierarchyTable > 0 || isLoadingPmsi > 0) return
dispatch<any>(incrementLoadingSyncHierarchyTable())
dispatch(incrementLoadingSyncHierarchyTable())
setOpen(!open)
const newHierarchy = await expandItem(
procedureCode,
Expand All @@ -68,15 +68,15 @@ const ProcedureListItem: React.FC<ProcedureListItemProps> = (props) => {
dispatch
)
await handleClick(selectedItems, newHierarchy)
dispatch<any>(decrementLoadingSyncHierarchyTable())
dispatch(decrementLoadingSyncHierarchyTable())
}

const handleClickOnHierarchy = async (procedureItem: PmsiListType) => {
if (isLoadingsyncHierarchyTable > 0 || isLoadingPmsi > 0) return
dispatch<any>(incrementLoadingSyncHierarchyTable())
dispatch(incrementLoadingSyncHierarchyTable())
const newSelectedItems = getSelectedPmsi(procedureItem, selectedItems || [], procedureHierarchy)
await handleClick(newSelectedItems)
dispatch<any>(decrementLoadingSyncHierarchyTable())
dispatch(decrementLoadingSyncHierarchyTable())
}

if (!subItems || (subItems && Array.isArray(subItems) && subItems.length === 0)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ const Cim10Form: React.FC<Cim10FormProps> = (props) => {
return setError(true)
}
onChangeSelectedCriteria(currentState)
dispatch<any>(fetchCondition())
dispatch(fetchCondition())
}
const getDiagOptions = async (searchValue: string) => await criteria.fetch.fetchCim10Diagnostic(searchValue, false)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ const CimListItem: React.FC<CimListItemProps> = (props) => {
const isIndeterminated = checkIfIndeterminated(cim10Item, selectedItems)
const _onExpand = async (cim10Code: string) => {
if (isLoadingsyncHierarchyTable > 0 || isLoadingPmsi > 0) return
dispatch<any>(incrementLoadingSyncHierarchyTable())
dispatch(incrementLoadingSyncHierarchyTable())
setOpen(!open)
const newHierarchy = await expandItem(
cim10Code,
Expand All @@ -64,15 +64,15 @@ const CimListItem: React.FC<CimListItemProps> = (props) => {
dispatch
)
await handleClick(selectedItems, newHierarchy)
dispatch<any>(decrementLoadingSyncHierarchyTable())
dispatch(decrementLoadingSyncHierarchyTable())
}

const handleClickOnHierarchy = async (cim10Item: PmsiListType) => {
if (isLoadingsyncHierarchyTable > 0 || isLoadingPmsi > 0) return
dispatch<any>(incrementLoadingSyncHierarchyTable())
dispatch(incrementLoadingSyncHierarchyTable())
const newSelectedItems = getSelectedPmsi(cim10Item, selectedItems || [], cim10Hierarchy)
await handleClick(newSelectedItems)
dispatch<any>(decrementLoadingSyncHierarchyTable())
dispatch(decrementLoadingSyncHierarchyTable())
}

if (!subItems || (subItems && Array.isArray(subItems) && subItems.length === 0)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const GhmForm: React.FC<GHMFormProps> = (props) => {
return setError(true)
}
onChangeSelectedCriteria(currentState)
dispatch<any>(fetchClaim())
dispatch(fetchClaim())
}
const defaultValuesCode = currentState.code
? currentState.code.map((code: any) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,19 +54,19 @@ const GhmListItem: React.FC<GhmListItemProps> = (props) => {
const isIndeterminated = checkIfIndeterminated(ghmItem, selectedItems)
const _onExpand = async (ghmCode: string) => {
if (isLoadingsyncHierarchyTable > 0 || isLoadingPmsi > 0) return
dispatch<any>(incrementLoadingSyncHierarchyTable())
dispatch(incrementLoadingSyncHierarchyTable())
setOpen(!open)
const newHierarchy = await expandItem(ghmCode, selectedItems || [], ghmHierarchy, defaultDemographic.type, dispatch)
await handleClick(selectedItems, newHierarchy)
dispatch<any>(decrementLoadingSyncHierarchyTable())
dispatch(decrementLoadingSyncHierarchyTable())
}

const handleClickOnHierarchy = async (ghmItem: PmsiListType) => {
if (isLoadingsyncHierarchyTable > 0 || isLoadingPmsi > 0) return
dispatch<any>(incrementLoadingSyncHierarchyTable())
dispatch(incrementLoadingSyncHierarchyTable())
const newSelectedItems = getSelectedPmsi(ghmItem, selectedItems || [], ghmHierarchy)
await handleClick(newSelectedItems)
dispatch<any>(decrementLoadingSyncHierarchyTable())
dispatch(decrementLoadingSyncHierarchyTable())
}

if (!subItems || (subItems && Array.isArray(subItems) && subItems.length === 0)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ const MedicationForm: React.FC<MedicationFormProps> = (props) => {
return setError(true)
}
onChangeSelectedCriteria(currentState)
dispatch<any>(fetchMedication())
dispatch(fetchMedication())
}

if (criteria?.data?.prescriptionTypes === 'loading' || criteria?.data?.administrations === 'loading') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ const MedicationListItem: React.FC<MedicationListItemProps> = (props) => {

const _onExpand = async (medicationCode: string) => {
if (isLoadingsyncHierarchyTable > 0 || isLoadingMedication > 0) return
dispatch<any>(incrementLoadingSyncHierarchyTable())
dispatch(incrementLoadingSyncHierarchyTable())
setOpen(!open)
const newHierarchy = await expandItem(
medicationCode,
Expand All @@ -71,15 +71,15 @@ const MedicationListItem: React.FC<MedicationListItemProps> = (props) => {
dispatch
)
await handleClick(selectedItems, newHierarchy)
dispatch<any>(decrementLoadingSyncHierarchyTable())
dispatch(decrementLoadingSyncHierarchyTable())
}

const handleClickOnHierarchy = (medicationItem: MedicationListType) => {
if (isLoadingsyncHierarchyTable > 0 || isLoadingMedication > 0) return
dispatch<any>(incrementLoadingSyncHierarchyTable())
dispatch(incrementLoadingSyncHierarchyTable())
const newSelectedItems = getSelectedPmsi(medicationItem, selectedItems || [], medicationHierarchy)
handleClick(newSelectedItems)
dispatch<any>(decrementLoadingSyncHierarchyTable())
dispatch(decrementLoadingSyncHierarchyTable())
}

if (!subItems || (subItems && Array.isArray(subItems) && subItems.length === 0)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const RequestForm: React.FC<RequestFormProps> = ({ parentId, goBack }) => {
return setError(true)
}

dispatch<any>(addRequestToCohortCreation({ parentId, selectedRequestId }))
dispatch(addRequestToCohortCreation({ parentId, selectedRequestId }))
}

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,11 @@ const LogicalOperatorItem: React.FC<LogicalOperatorItemProps> = ({ itemId }) =>
}

const _buildCohortCreation = () => {
dispatch<any>(buildCohortCreation({}))
dispatch(buildCohortCreation({}))
}

const _deleteLogicalOperator = async () => {
await dispatch<any>(deleteCriteriaGroup(itemId))
await dispatch(deleteCriteriaGroup(itemId))
_buildCohortCreation()
}

Expand All @@ -107,7 +107,7 @@ const LogicalOperatorItem: React.FC<LogicalOperatorItemProps> = ({ itemId }) =>

switch (value) {
case 'atLeast':
dispatch<any>(
dispatch(
editCriteriaGroup({
..._currentLogicalOperator,
type: 'NamongM',
Expand All @@ -121,7 +121,7 @@ const LogicalOperatorItem: React.FC<LogicalOperatorItemProps> = ({ itemId }) =>
)
break
case 'atMost':
dispatch<any>(
dispatch(
editCriteriaGroup({
..._currentLogicalOperator,
type: 'NamongM',
Expand All @@ -135,7 +135,7 @@ const LogicalOperatorItem: React.FC<LogicalOperatorItemProps> = ({ itemId }) =>
)
break
case 'exactly':
dispatch<any>(
dispatch(
editCriteriaGroup({
..._currentLogicalOperator,
type: 'NamongM',
Expand All @@ -151,7 +151,7 @@ const LogicalOperatorItem: React.FC<LogicalOperatorItemProps> = ({ itemId }) =>
case 'andGroup':
case 'orGroup':
default:
dispatch<any>(
dispatch(
editCriteriaGroup({
..._currentLogicalOperator,
type: value
Expand All @@ -160,7 +160,7 @@ const LogicalOperatorItem: React.FC<LogicalOperatorItemProps> = ({ itemId }) =>
break
}
} else if (key === 'options.number') {
dispatch<any>(
dispatch(
editCriteriaGroup({
..._currentLogicalOperator,
type: 'NamongM',
Expand All @@ -173,7 +173,7 @@ const LogicalOperatorItem: React.FC<LogicalOperatorItemProps> = ({ itemId }) =>
})
)
} else {
dispatch<any>(
dispatch(
editCriteriaGroup({
..._currentLogicalOperator,
[key]: value
Expand Down Expand Up @@ -297,7 +297,7 @@ const LogicalOperatorItem: React.FC<LogicalOperatorItemProps> = ({ itemId }) =>
</Button>
<Button
onClick={() => {
dispatch<any>(updateTemporalConstraints([]))
dispatch(updateTemporalConstraints([]))
_handleChangeLogicalOperatorProps('groupType', 'orGroup')
}}
>
Expand Down
Loading

0 comments on commit f6ece0c

Please sign in to comment.