From 7d3c3844fecded114f79facc071f9b43fc7fc97e Mon Sep 17 00:00:00 2001 From: eirikhaugstulen Date: Mon, 19 Feb 2024 21:45:32 +0700 Subject: [PATCH] chore: change state labels --- .../Actions/Transfer/hooks/useUpdateOwnership.js | 10 +++++----- .../TransferModal/InfoBoxes/InfoBoxes.component.js | 6 +++--- .../OrgUnitField/useSearchScopeWithFallback.js | 8 ++++---- .../TransferModal/hooks/useTransferValidation.js | 12 ++++++------ 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/core_modules/capture-core/components/WidgetEnrollment/Actions/Transfer/hooks/useUpdateOwnership.js b/src/core_modules/capture-core/components/WidgetEnrollment/Actions/Transfer/hooks/useUpdateOwnership.js index 65a5e217c9..e453865cd8 100644 --- a/src/core_modules/capture-core/components/WidgetEnrollment/Actions/Transfer/hooks/useUpdateOwnership.js +++ b/src/core_modules/capture-core/components/WidgetEnrollment/Actions/Transfer/hooks/useUpdateOwnership.js @@ -12,8 +12,8 @@ export type UpdateEnrollmentOwnership = {| orgUnitId: string, programAccessLevel: ?$Values, orgUnitScopes: { - ORIGIN: ?$Values, - DESTINATION: ?$Values, + origin: ?$Values, + destination: ?$Values, }, |} => Promise; @@ -65,7 +65,7 @@ export const useUpdateOwnership = ({ { onSuccess: (_, { programAccessLevel, orgUnitScopes }) => { // If the user is transferring ownership to a capture scope, we stay on the same page - if (orgUnitScopes.DESTINATION === OrgUnitScopes.CAPTURE) { + if (orgUnitScopes.destination === OrgUnitScopes.CAPTURE) { refetchTEI(); return; } @@ -77,10 +77,10 @@ export const useUpdateOwnership = ({ // Assuming that all cases are outside the capture scope and program is protected or closed if (programAccessLevel === ProgramAccessLevels.PROTECTED) { - if (orgUnitScopes.ORIGIN === OrgUnitScopes.CAPTURE) { + if (orgUnitScopes.origin === OrgUnitScopes.CAPTURE) { onTransferOutsideCaptureScope && onTransferOutsideCaptureScope(); return; - } else if (orgUnitScopes.ORIGIN === OrgUnitScopes.SEARCH) { + } else if (orgUnitScopes.origin === OrgUnitScopes.SEARCH) { refetchTEI(); return; } diff --git a/src/core_modules/capture-core/components/WidgetEnrollment/TransferModal/InfoBoxes/InfoBoxes.component.js b/src/core_modules/capture-core/components/WidgetEnrollment/TransferModal/InfoBoxes/InfoBoxes.component.js index ccea978be0..2532b151e9 100644 --- a/src/core_modules/capture-core/components/WidgetEnrollment/TransferModal/InfoBoxes/InfoBoxes.component.js +++ b/src/core_modules/capture-core/components/WidgetEnrollment/TransferModal/InfoBoxes/InfoBoxes.component.js @@ -13,8 +13,8 @@ type Props = { validOrgUnitId: ?string, programAccessLevel: string, orgUnitScopes: { - ORIGIN: $Keys, - DESTINATION: $Keys, + origin: $Keys, + destination: $Keys, }, classes: Object, }; @@ -52,7 +52,7 @@ const InfoBoxesPlain = ({ const { displayName: newOrgUnitName } = useOrgUnitName(validOrgUnitId); const showWarning = [ProgramAccessLevels.PROTECTED, ProgramAccessLevels.PROTECTED].includes(programAccessLevel) - && orgUnitScopes.DESTINATION === OrgUnitScopes.SEARCH; + && orgUnitScopes.destination === OrgUnitScopes.SEARCH; return (
diff --git a/src/core_modules/capture-core/components/WidgetEnrollment/TransferModal/OrgUnitField/useSearchScopeWithFallback.js b/src/core_modules/capture-core/components/WidgetEnrollment/TransferModal/OrgUnitField/useSearchScopeWithFallback.js index b31525adc5..eca5d5f929 100644 --- a/src/core_modules/capture-core/components/WidgetEnrollment/TransferModal/OrgUnitField/useSearchScopeWithFallback.js +++ b/src/core_modules/capture-core/components/WidgetEnrollment/TransferModal/OrgUnitField/useSearchScopeWithFallback.js @@ -17,8 +17,8 @@ export const useSearchScopeWithFallback = ({ searchText }: Props) => { }, { enabled: !searchText, - // Clearing cache after 60 minutes to avoid memory leaks - cacheTime: 60 * 60 * 1000, + // Clearing cache after 120 minutes to avoid memory leaks + cacheTime: 120 * 60 * 1000, select: (data) => { const { teiSearchOrganisationUnits, organisationUnits } = data; return teiSearchOrganisationUnits.length @@ -43,8 +43,8 @@ export const useSearchScopeWithFallback = ({ searchText }: Props) => { }, { enabled: Boolean(searchText), - // Clearing cache after 60 minutes to avoid memory leaks - cacheTime: 60 * 60 * 1000, + // Clearing cache after 120 minutes to avoid memory leaks + cacheTime: 120 * 60 * 1000, select: (data) => { const { organisationUnits } = data; return organisationUnits; diff --git a/src/core_modules/capture-core/components/WidgetEnrollment/TransferModal/hooks/useTransferValidation.js b/src/core_modules/capture-core/components/WidgetEnrollment/TransferModal/hooks/useTransferValidation.js index 9412039c0b..a9533437ed 100644 --- a/src/core_modules/capture-core/components/WidgetEnrollment/TransferModal/hooks/useTransferValidation.js +++ b/src/core_modules/capture-core/components/WidgetEnrollment/TransferModal/hooks/useTransferValidation.js @@ -38,19 +38,19 @@ export const useTransferValidation = ({ ownerOrgUnitId, programId }: Props) => { const dataEngine = useDataEngine(); const [selectedOrgUnit, setSelectedOrgUnit] = useState(); const [orgUnitScopes, setOrgUnitScopes] = useState({ - ORIGIN: null, - DESTINATION: null, + origin: null, + destination: null, }); const { accessLevel } = useProgramAccessLevel({ programId }); - const ready = useMemo(() => !!accessLevel && !!orgUnitScopes.ORIGIN, - [accessLevel, orgUnitScopes.ORIGIN]); + const ready = useMemo(() => !!accessLevel && !!orgUnitScopes.origin, + [accessLevel, orgUnitScopes.origin]); useEffect(() => { const updateOriginScope = (newScope: $Values) => setOrgUnitScopes( prevOrgUnitScopes => ({ ...prevOrgUnitScopes, - ORIGIN: newScope, + origin: newScope, }), ); @@ -63,7 +63,7 @@ export const useTransferValidation = ({ ownerOrgUnitId, programId }: Props) => { const updateDestinationScope = (newScope: $Values) => setOrgUnitScopes( prevOrgUnitScopes => ({ ...prevOrgUnitScopes, - DESTINATION: newScope, + destination: newScope, }), );