Skip to content

Comments

Disable module date selection outside program duration#3424

Merged
kasya merged 5 commits intoOWASP:mainfrom
mrkeshav-05:fix/module-date-selection
Jan 23, 2026
Merged

Disable module date selection outside program duration#3424
kasya merged 5 commits intoOWASP:mainfrom
mrkeshav-05:fix/module-date-selection

Conversation

@mrkeshav-05
Copy link
Contributor

Proposed change

This PR fixes the issue and disable module date selection outside program start and end dates.

Resolves #3382

image

Checklist

  • Required: I followed the contributing workflow
  • Required: I verified that my code works as intended and resolves the issue as described
  • Required: I ran make check-test locally: all warnings addressed, tests passed
  • I used AI for code, documentation, tests, or communication related to this PR

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 19, 2026

Summary by CodeRabbit

  • New Features
    • Module start and end dates are now restricted to fall within your program's date range during creation and editing, ensuring data consistency across your mentorship program.

✏️ Tip: You can customize this high-level summary in your review settings.

Walkthrough

Adds program start/end dates to GraphQL queries and threads formatted minDate/maxDate props through ModuleForm → FormDateInput so module start/end pickers are constrained to the program's duration.

Changes

Cohort / File(s) Summary
GraphQL queries
frontend/src/server/queries/moduleQueries.ts, frontend/src/server/queries/programsQueries.ts
Query payloads extended to request startedAt and endedAt for programs.
Module pages
frontend/src/app/my/mentorship/programs/[programKey]/modules/create/page.tsx, frontend/src/app/my/mentorship/programs/[programKey]/modules/[moduleKey]/edit/page.tsx
Import/usage of formatDateForInput; pass minDate/maxDate (formatted program start/end or undefined) into ModuleForm.
ModuleForm component
frontend/src/components/ModuleForm.tsx
Added optional minDate?: string and maxDate?: string props; forward them to start/end FormDateInput and ensure end-date min respects selected start or minDate.
FormDateInput component
frontend/src/components/forms/shared/FormDateInput.tsx
Added optional max?: string prop and pass max through to the underlying <Input max={max} />.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • arkid15r
  • kasya
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Disable module date selection outside program duration' directly and clearly describes the main change in the PR.
Description check ✅ Passed The description explains the proposed change, references the resolved issue, and demonstrates understanding of the problem through screenshots and verification checklist.
Linked Issues check ✅ Passed The PR fully addresses issue #3382 by implementing date constraints via minDate and maxDate props that restrict module date selection to within program duration [#3382].
Out of Scope Changes check ✅ Passed All changes are directly related to restricting module date selection within program bounds; no unrelated modifications detected.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
frontend/src/components/ModuleForm.tsx (1)

223-236: Clamp end-date min to the program start.

If an existing module has startedAt before the program start, min={formData.startedAt || minDate} allows selecting end dates earlier than the program start. Consider clamping to the later of minDate and startedAt so the end-date picker can’t go outside the program window. Line 234 is the key spot.

🛠️ Suggested adjustment
+  const endDateMin =
+    minDate && formData.startedAt
+      ? (formData.startedAt > minDate ? formData.startedAt : minDate)
+      : formData.startedAt || minDate || undefined
...
-                  min={formData.startedAt || minDate || undefined}
+                  min={endDateMin}

coderabbitai[bot]
coderabbitai bot previously approved these changes Jan 19, 2026
@mrkeshav-05 mrkeshav-05 marked this pull request as draft January 19, 2026 19:20
@mrkeshav-05 mrkeshav-05 force-pushed the fix/module-date-selection branch from c511d24 to b5f400c Compare January 19, 2026 19:58
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
frontend/src/components/ModuleForm.tsx (1)

209-236: Min/max aren’t enforced for typed input with noValidate.

Because the form disables native validation, users can still type/paste out‑of‑range dates even though the picker UI is constrained. Consider adding explicit range checks in the custom validators (e.g., validateStartDateLocal/validateEndDateLocal) when minDate/maxDate are present.

@mrkeshav-05 mrkeshav-05 marked this pull request as ready for review January 19, 2026 20:03
@sonarqubecloud
Copy link

Copy link
Collaborator

@kasya kasya left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great @mrkeshav-05 👍🏼
Thanks!

@kasya kasya added this pull request to the merge queue Jan 23, 2026
Merged via the queue into OWASP:main with commit 15de802 Jan 23, 2026
29 of 30 checks passed
@mrkeshav-05 mrkeshav-05 deleted the fix/module-date-selection branch January 24, 2026 07:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Disable module date selection outside program duration

2 participants