Reduce duplicated form logic between ModuleForm and ProgramForm
- Dominant language
- Python
- Stars
- 451
- Forks
- 702
- Avg merge
- 22h 59m
- Merged PRs (30d)
- 91
Description
**What I noticed**
While reviewing the frontend code, I noticed that `ModuleForm.tsx` and `ProgramForm.tsx` share a lot of very similar logic.
This includes:
- Nearly identical `handleInputChange()` implementations
- Similar local validation wrappers (name and end-date validation)
- Repeated form submission and validation flow
- Very similar JSX structure for multiple form fields
Both files are fairly large, and this duplication makes them harder to reason about and maintain.
**Why this matters**
Because the same logic exists in more than one place:
- Bug fixes or improvements need to be done multiple times
- It’s easy for the two forms to slowly drift out of sync
- Reviewing or extending these forms takes more effort than necessary
Reducing this duplication would make future changes safer and easier.
**Suggested next step**
As an initial improvement, we could:
- Extract the shared input-handling and validation logic into a common helper or hook
- Reuse it in both forms without changing any UI or existing behavior
This can be done incrementally and kept limited in scope.
**Are you going to work on fixing this?**
- [x] Yes
- [ ] No
Contributor guide
Assessment
This issue has not been assessed yet.