I can see an error message when trying to add a tutor that already exists, and be prevented from adding duplicate tutors
so that the data in the app is reliable, and not confusing.
(1) Start by adding constraints at the database level if possible.
(2) Then, improve error handling for the POST endpoint. The error should not just be a generic 500 but a 409 status with an error message that is specific (Tutor with email ___ already exists).
(3) Ensure that the PUT endpoint doesn't allow changing the email address; a new email address should be a new tutor entry.
(4) Then make the front end display a meaningful error message. Intercept the 409 and display a toast, for example.
(1) Start by adding constraints at the database level if possible. (2) Then, improve error handling for the POST endpoint. The error should not just be a generic 500 but a 409 status with an error message that is specific (
Tutor with email ___ already exists
). (3) Ensure that the PUT endpoint doesn't allow changing the email address; a new email address should be a new tutor entry. (4) Then make the front end display a meaningful error message. Intercept the 409 and display a toast, for example.