diff --git a/src/components/modals/DonateWrongNetwork.tsx b/src/components/modals/DonateWrongNetwork.tsx index a2c218c9e5..73ea3d6bdb 100644 --- a/src/components/modals/DonateWrongNetwork.tsx +++ b/src/components/modals/DonateWrongNetwork.tsx @@ -61,7 +61,7 @@ export const DonateWrongNetwork: FC = props => { const router = useRouter(); const { switchChain } = useSwitchChain(); const isSafeEnv = useIsSafeEnvironment(); - const { setDonateModalByPriority } = useDonateData(); + const { setDonateModalByPriority, currentDonateModal } = useDonateData(); const closeNetworkModal = useCallback(() => { setDonateModalByPriority(DonateModalPriorityValues.None); closeModal(); @@ -95,7 +95,7 @@ export const DonateWrongNetwork: FC = props => { ) { closeNetworkModal(); } - }, [networkId, acceptedChains]); + }, [networkId, acceptedChains, currentDonateModal]); return ( { qrDonationStatus, draftDonationData, hasActiveQFRound, + currentDonateModal, shouldRenderModal, setSuccessDonation, setQRDonationStatus, @@ -122,7 +123,7 @@ const DonateIndex: FC = () => { useEffect(() => { validateSanctions(); - }, [project, address]); + }, [project, address, currentDonateModal]); useEffect(() => { if ( @@ -132,11 +133,13 @@ const DonateIndex: FC = () => { setDonateModalByPriority( DonateModalPriorityValues.DonationByProjectOwner, ); + } else { + setDonateModalByPriority(DonateModalPriorityValues.None); } setIsModalPriorityChecked( DonateModalPriorityValues.DonationByProjectOwner, ); - }, [userData?.id, project.adminUser]); + }, [userData?.id, project.adminUser, currentDonateModal]); useEffect(() => { const fetchDonation = async () => { diff --git a/src/context/donate.context.tsx b/src/context/donate.context.tsx index 43358bd0be..bf9e3d1067 100644 --- a/src/context/donate.context.tsx +++ b/src/context/donate.context.tsx @@ -38,6 +38,7 @@ interface IDonateContext { project: IProject; successDonation?: ISuccessDonation; tokenStreams: ITokenStreams; + currentDonateModal: DonateModalPriorityValues; setSuccessDonation: (successDonation?: ISuccessDonation) => void; selectedOneTimeToken?: IProjectAcceptedToken; selectedRecurringToken?: ISelectTokenWithBalance; @@ -82,6 +83,7 @@ const DonateContext = createContext({ setSuccessDonation: () => {}, setSelectedOneTimeToken: () => {}, setSelectedRecurringToken: () => {}, + currentDonateModal: DonateModalPriorityValues.None, project: {} as IProject, tokenStreams: {}, fetchProject: async () => {}, @@ -244,6 +246,7 @@ export const DonateProvider: FC = ({ children, project }) => { setSelectedRecurringToken, setIsModalPriorityChecked, tokenStreams, + currentDonateModal, fetchProject, draftDonationData: draftDonation as IDraftDonation, setDraftDonationData: setDraftDonation,