connect icon indicating copy to clipboard operation
connect copied to clipboard

Fix/con/898 ensure exclusive acceptance of mentors

Open ericbolikowski opened this issue 2 months ago • 1 comments

What Github issue does this PR relate to? Insert link.

#898

This PR fixes bug #898 which allowed mentees in special cases to have two simultaneously active/accepted Mentorship Matches: CleanShot 2024-05-19 at 11 28 22@2x|200

The case could happen when for example:

  1. Eric sends mentorship requests to two mentors, Anil and Kate
  2. Two Mentorship Matches are created, both with state Applied
  3. Anil and Kate access the CON Applications page at the same time
  4. Anil accepts the mentorship
  5. Nestjs updates the two Mentorship Mathches:
  • The Eric+Anil Mentorship Match becomes Accepted
  • The Eric+Kate Mentorship Match becomes Invalidated/Cancelled
  1. Kate accepts the mentorship
  2. The Eric+Kate Mentorship Match becomes Accepted

The fix was obvious: in the code that handles the "accept mentorship" mutation, only change the Mentorship Match state into Accepted if the current state is Applied.

What should the reviewer know?

The backend issue is solved, and we likely won't get into a state of one mentee + two active mentorships. But an unpleasant UX issue came up:

If the above steps happened again, but with the fix in this PR, Kate would in step 6 be prevented from accepting the mentorship request. Nestjs would return an error handled by the CON frontend in the catch (error) { clause you'll see. I've implemented a crude alert() shown to the user and then the page refreshes.

That scenario is illustrated in this Loom: https://www.loom.com/share/47fb8764f8d14c619092a3c8a6775b6d?sid=1dd21bcc-d13f-4020-a133-7a91d5bbb265

This leads to the loss of the acceptance message that Kate wrote - which is annoying, but the message isn't relevant any longer since Eric has a mentorship with Anil and isn't supposed to have one with Kate.

The question is: are there any easy ways to improve this UX?

ericbolikowski avatar May 19 '24 09:05 ericbolikowski