We have to differentiate between the main and non-main supervisors.
NOTICE: we decided that the primary supervisor can't be external
[x] Add a checkbox next to the supervisors that the user can check to indicate the main supervisor
[x] Create field for the supervision table called isPrimarySupervisor
[x] Add backend and frontend validations -- the frontend should not allow to submit without primary supervisor and the backend needs to also check for this
Consider adding a test case and implementation for the following behaviour (which should not be possible though):
When a new supervisor is added if there is no existing supervisors the added supervisor will be the primary supervisor by default. --> However, this should not happen in the first place
It is now possible to trick the application in to deleting the primary supervisor when you remove the user from the supervisor field which is set to primary --> add two new supervisors but do not input any names for them --> make the lastly added supervisor the primary supervisor --> delete the second supervisor field --> this will delete the second supervisor, yes, but since the React map index values are used as keys, sort of, this will fuck shit up and the delete dialog will stay for the middle field key=supervisions-1 and you will now be able to delete the primary supervisor :D --> fix the key issue: providing meaningful unique keys is hard now for person inputs where a person is not yet selected so the user is null, since we cannot use the user.id as key. Consider adding some kind of creation time UUIDs for the person inputs, before the field has user selected so that the UUID can be used as the key and fix this issue --> Yes I know runtime keys are bad as shit, but better than this bug atleast
We have to differentiate between the main and non-main supervisors.
NOTICE: we decided that the primary supervisor can't be external
isPrimarySupervisor