benhuangbmj / cmp-lab-schedule

The front-end of a human resource management app designed for higher education built with React and powered by Vite.
0 stars 2 forks source link

Alerting "update failed" when using Admin #50

Open benhuangbmj opened 3 months ago

benhuangbmj commented 3 months ago

What: When using the Profile popup in Admin to update the user info, the app would alert "update failed", then alert "updates successfully".

benhuangbmj commented 3 months ago

Cause: The form in Profile is technically nested in the form in Admin, thus when the Profile form is being submitted, the Admin form submission will be triggered as well. Consequently, two put requests to the Contentful API are made simultaneously which causes a version conflict.

Solution: (ad hoc) Wrap the handleSubmit of the Profile form with a propagation stopper.

benhuangbmj commented 3 months ago

Suggestion: Investigate the codes in React Hook Form to see if there is any intrinsic solution.