diff --git a/package.json b/package.json index a6b9967..de98f29 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "siteforge", "private": true, - "version": "2.8.2", + "version": "2.8.3", "type": "module", "scripts": { "dev": "vite", diff --git a/server/routes/study-data.js b/server/routes/study-data.js index 9d27bcf..fbb4db6 100644 --- a/server/routes/study-data.js +++ b/server/routes/study-data.js @@ -59,6 +59,11 @@ export function register(app) { const enrolled = Array.isArray(user.enrolledStudySlugs) ? user.enrolledStudySlugs : [] if (!enrolled.includes(studySlug)) { + const catalogEntry = getStudyCatalog().find(study => study.slug === studySlug) + if (catalogEntry?.status === 'planned') { + res.status(400).json({ message: 'This study is not open for enrollment yet.' }) + return + } user.enrolledStudySlugs = [...enrolled, studySlug].slice(0, MAX_STUDY_ENROLLMENTS_PER_USER) user.updatedAt = new Date().toISOString() queueStudyUsersWrite() diff --git a/src/studyPages.tsx b/src/studyPages.tsx index 6515545..61ef3d5 100644 --- a/src/studyPages.tsx +++ b/src/studyPages.tsx @@ -806,6 +806,8 @@ export function StudyLandingPage({ content }: Props) { >{enrollBusySlug === studyInfo.slug ? 'Working…' : 'Yes, leave'} setConfirmLeaveSlug(null)}>Cancel + ) : !studyInfo.enrolled && studyInfo.status === 'planned' ? ( + Coming soon ) : ( {studyInfo.title} {studyInfo.completedLessons} of {studyInfo.totalLessons} lessons completed · {studyInfo.noteCount} notes - handleEnrollmentToggle(studyInfo.slug, studyInfo.enrolled)} - > - {enrollBusySlug === studyInfo.slug ? 'Working…' : studyInfo.enrolled ? 'Leave' : 'Enroll'} - + {!studyInfo.enrolled && studyInfo.status === 'planned' ? ( + Coming soon + ) : ( + handleEnrollmentToggle(studyInfo.slug, studyInfo.enrolled)} + > + {enrollBusySlug === studyInfo.slug ? 'Working…' : studyInfo.enrolled ? 'Leave' : 'Enroll'} + + )} ))}
{studyInfo.completedLessons} of {studyInfo.totalLessons} lessons completed · {studyInfo.noteCount} notes