Skip to content

Commit

Permalink
chore: change state labels
Browse files Browse the repository at this point in the history
  • Loading branch information
eirikhaugstulen committed Feb 19, 2024
1 parent f88b394 commit 7d3c384
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ export type UpdateEnrollmentOwnership = {|
orgUnitId: string,
programAccessLevel: ?$Values<typeof ProgramAccessLevels>,
orgUnitScopes: {
ORIGIN: ?$Values<typeof OrgUnitScopes>,
DESTINATION: ?$Values<typeof OrgUnitScopes>,
origin: ?$Values<typeof OrgUnitScopes>,
destination: ?$Values<typeof OrgUnitScopes>,
},
|} => Promise<void>;

Expand Down Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ type Props = {
validOrgUnitId: ?string,
programAccessLevel: string,
orgUnitScopes: {
ORIGIN: $Keys<typeof OrgUnitScopes>,
DESTINATION: $Keys<typeof OrgUnitScopes>,
origin: $Keys<typeof OrgUnitScopes>,
destination: $Keys<typeof OrgUnitScopes>,
},
classes: Object,
};
Expand Down Expand Up @@ -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 (
<div className={classes.container}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,19 @@ export const useTransferValidation = ({ ownerOrgUnitId, programId }: Props) => {
const dataEngine = useDataEngine();
const [selectedOrgUnit, setSelectedOrgUnit] = useState<?OrgUnit>();
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<typeof OrgUnitScopes>) => setOrgUnitScopes(
prevOrgUnitScopes => ({
...prevOrgUnitScopes,
ORIGIN: newScope,
origin: newScope,
}),
);

Expand All @@ -63,7 +63,7 @@ export const useTransferValidation = ({ ownerOrgUnitId, programId }: Props) => {
const updateDestinationScope = (newScope: $Values<typeof OrgUnitScopes>) => setOrgUnitScopes(
prevOrgUnitScopes => ({
...prevOrgUnitScopes,
DESTINATION: newScope,
destination: newScope,
}),
);

Expand Down

0 comments on commit 7d3c384

Please sign in to comment.