#46510 Unlimited forms created by spamming add items button in user setting

Ive been asked to solve the above issue. Batch updates aside, my understanding of it is we want to limit the user to only being able to add one unsaved item/portfolio/form at a time (while allowing the user to add as many saved forms as he desires)

Here are the instructions I recieved on discord though I didnt understand them (as it makes it seem like im supposed to only allow one portfolio item in total) :

here is how I solved it, please let me know what changes to make if any. for me its working as expected:

https://github.com/KravMaguy/freeCodeCamp/tree/disable-portfolio-add-btn

P.S. I am assuming that it is saved based off actions on the client without checking any response from the server to know if it is in fact truly “saved”. Is it necessary to write tests?

Edit: the code doesnt work when you reload the page because isSaved property is not saved to the database, I think if its added than it will work

Edit: I think there is also small bug onSubmit button isPristine lodash isEqual because of that prop I added, (it should be disabled after first click)

it does not save the portfolio item properly

I want isSaved to be true:

also where is this component PortfolioSettings It is exported where is it used?

is it withTranslation? it looks like currying. how is it working?

EDIT:
in the state it is true, yet in the payload it is not (onSubmit is not using the latest state after the update)

I think its solved, though I wish it had been more of a team effort

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.