Right now, when the "new study" button is clicked on the My Studies Page, the user is redirected to /studies/new
The study is not created in the DB until they click save for the first time
We have separate logic to track whether the study is new, and the Save button works slightly differently in each case
Task
[x] Create an endpoint POST /studies to create a new study and return the id
I think this endpoint exists already actually but it may need some tweaking
[x] Make sure it adds the study to the current user's studies list
[x] When the new study button is clicked, hit the endpoint to create the study in the db immediately (useMutation)
[x] On success, redirect to studies/<returned id> instead of studies/new
[x] Since the PUT /studies/:id endpoint will now only be called on studies that exist, it can be greatly simplified
[x] Remove all logic specific to "new study mode", most of which is likely in the studyBuilder Pinia store stores/studyBuilder
[x] May be other places as well - e.g. since we can assume that the study being edited exists, we don't need to conditionally render the StudyServerCode component in StudyPanel.vue
Problem
Task
studies
listuseMutation
)studies/<returned id>
instead ofstudies/new
PUT /studies/:id
endpoint will now only be called on studies that exist, it can be greatly simplifiedstores/studyBuilder
StudyServerCode
component inStudyPanel.vue