Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix id after choosing a campaign (Admin panel) #1891

Merged
merged 1 commit into from
Aug 20, 2024
Merged

Fix id after choosing a campaign (Admin panel) #1891

merged 1 commit into from
Aug 20, 2024

Conversation

ani-kalpachka
Copy link
Member

Fixed id after choosing a campain in recurring donations in Admin panel:

Before After
image image

The id is set in handleCampaignSelected function when the user chooses a campaign. The issue was caused by setting an initail value on sourceVault when the id is already present, so I reset it to '' in the object.

Copy link
Contributor

@slavcho slavcho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand how this fixes the issue?
Is the "data.sourceVault.Id" incorrect?

What if we open the form, but do not change the campaign? Don't we end up without a sourceVault set to "" if we click save without changing the campaign?

@ani-kalpachka
Copy link
Member Author

ani-kalpachka commented Jul 24, 2024

As I understand it, sourceVault: data?.sourceVault.id sets the inital value if the id is present.
The same id is set for the second time when a campaign is chosen from the dropdown in this block of code:

handleCampaignSelected={(campaign) => {
   campaigns?.forEach((c) => {
       if (c.id === campaign && c.vaults) {
           setFieldValue('sourceVault', c.vaults[0].id)
        }
   })
}}

I thought we dont need the first initail setting of the value and it should be handled in the handleCampaignSelected() function.
This approach fixes the issue and seems not to cause unwanted side effects. It may be better approuches though. If you have some concerns and other better suggestions how to fix the issue, please advice.

@slavcho

@slavcho slavcho merged commit 5471218 into master Aug 20, 2024
12 checks passed
@slavcho slavcho deleted the show-id branch August 20, 2024 15:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Not showing correctly ID on sub account after choosing campaign
2 participants