Skip to content

Commit

Permalink
fix: OFAC Sanction Modal Check
Browse files Browse the repository at this point in the history
  • Loading branch information
HrithikSampson committed Sep 21, 2024
1 parent edaa8a5 commit 34829fe
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions src/context/donate.context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,9 @@ export const DonateProvider: FC<IProviderProps> = ({ children, project }) => {
const isModalStatusChecked = useRef<
Map<DonateModalPriorityValues, boolean>
>(new Map());
const [highestModalPriorityUnchecked, setHighestModalPriorityUnchecked] =
useState<DonateModalPriorityValues | 'All Checked'>(
DonateModalPriorityValues.None,
);
const highestModalPriorityUnchecked = useRef<
DonateModalPriorityValues | 'All Checked'
>(DonateModalPriorityValues.None);

const [successDonation, setSuccessDonation] = useState<ISuccessDonation>();
const [projectData, setProjectData] = useState<IProject>(project);
Expand All @@ -147,8 +146,10 @@ export const DonateProvider: FC<IProviderProps> = ({ children, project }) => {
const setIsModalPriorityChecked = useCallback(
(modalChecked: DonateModalPriorityValues): void => {
if (
highestModalPriorityUnchecked != 'All Checked' &&
modalChecked > highestModalPriorityUnchecked
highestModalPriorityUnchecked.current != 'All Checked' &&
(modalChecked <= highestModalPriorityUnchecked.current ||
highestModalPriorityUnchecked.current ===
DonateModalPriorityValues.None)
) {
isModalStatusChecked.current.set(modalChecked, true);
let highestModalStatusUnchecked =
Expand All @@ -164,12 +165,13 @@ export const DonateProvider: FC<IProviderProps> = ({ children, project }) => {
highestModalStatusUnchecked = modalStatus;
}
isAllChecked =
isAllChecked &&
!!isModalStatusChecked.current.get(modalStatus);
(isAllChecked &&
!!isModalStatusChecked.current.get(modalStatus)) ||
modalStatus === DonateModalPriorityValues.None;
}
setHighestModalPriorityUnchecked(
isAllChecked ? 'All Checked' : highestModalStatusUnchecked,
);
highestModalPriorityUnchecked.current = isAllChecked
? 'All Checked'
: highestModalStatusUnchecked;
}
},
[],
Expand Down Expand Up @@ -235,7 +237,8 @@ export const DonateProvider: FC<IProviderProps> = ({ children, project }) => {
startTimer,
setQRDonationStatus: setStatus,
setPendingDonationExists,
highestModalPriorityUnchecked,
highestModalPriorityUnchecked:
highestModalPriorityUnchecked.current,
setIsModalPriorityChecked,
draftDonationLoading: loading,
}}
Expand Down

0 comments on commit 34829fe

Please sign in to comment.