diff --git a/src/components/forms/sponsor-general-form/sponsorship.js b/src/components/forms/sponsor-general-form/sponsorship.js index 701555a80..eaa1e7ccc 100644 --- a/src/components/forms/sponsor-general-form/sponsorship.js +++ b/src/components/forms/sponsor-general-form/sponsorship.js @@ -33,7 +33,7 @@ const Sponsorship = ({ }) => { const [showAddTierPopup, setShowAddTierPopup] = useState(false); const [showManageTierAddonsPopup, setShowManageTierAddons] = useState(false); - const [selectedSponsorship, setSelectedSponsorship] = useState(null); + const [selectedSponsorshipId, setSelectedSponsorshipId] = useState(null); const { sponsorships, @@ -44,6 +44,9 @@ const Sponsorship = ({ orderDir } = sponsor.sponsorships_collection; + const selectedSponsorship = + sponsorships.find((s) => s.id === selectedSponsorshipId) || null; + const handleCloseAddTierPopup = () => { setShowAddTierPopup(false); }; @@ -67,7 +70,7 @@ const Sponsorship = ({ }; const handleOpenManageAddonsPopup = (sponsorship) => { - setSelectedSponsorship(sponsorship); + setSelectedSponsorshipId(sponsorship.id); onSponsorshipSelect(sponsorship); setShowManageTierAddons(true); }; @@ -75,7 +78,7 @@ const Sponsorship = ({ const handleCloseManageAddonsPopup = () => { setShowManageTierAddons(false); onSponsorshipSelect(null); - setSelectedSponsorship(null); + setSelectedSponsorshipId(null); }; const handleAddSponsorshipAddon = (addons, sponsorshipId) => {