Skip to content

Conversation

@Saby-Bishops
Copy link
Member

@Saby-Bishops Saby-Bishops commented Jan 21, 2026

Motivation

  • Improve type safety for the reports date filter form by migrating from untyped Angular forms to typed FormGroup/FormControl/FormBuilder usages.
  • Ensure the end-date validation is applied at the group level (so it is not treated as a control) and make date value handling explicit under strict typing.
image

Description

  • Replaced UntypedFormGroup/UntypedFormBuilder imports with typed FormBuilder, FormControl, and FormGroup imports and usages.
  • Added a DateFilterForm type alias describing startDate and endDate as FormControl<Date | '' | null> and updated dateFilterForm to FormGroup<DateFilterForm>.
  • Reworked initDateFilterForm() to build the group with typed controls using this.fb.control<...>(...) and moved CustomValidators.endDateValidator() into the group options ({ validators: ... }).
  • Adjusted valueChanges handling to explicitly treat value.startDate/value.endDate as Date instances (instanceof Date) and otherwise use null, and ensured existing setValue/patchValue interactions reference the typed controls.

Testing

  • No automated tests were run for this change (per instruction, ./gradlew test was not executed).

Codex Task

Copy link
Member

@uj-sxn uj-sxn left a comment

Choose a reason for hiding this comment

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

The migration to typed forms in this component is a great improvement for long-term maintainability. It makes the expected data structure for the date filters much more explicit and helps prevent runtime errors.

@Mutugiii Mutugiii changed the title src/app/manager-dashboard/reports/reports-detail.component.ts (fixes #9504) manager: smoother reports filter type form (fixes #9504) Jan 26, 2026
@Mutugiii Mutugiii requested a review from Copilot January 26, 2026 21:13
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR enhances type safety in the reports filter form by migrating from untyped Angular forms to strongly typed form controls. The change ensures compile-time type checking for the date filter form and correctly applies end-date validation at the form group level rather than as a control validator.

Changes:

  • Replaced UntypedFormGroup/UntypedFormBuilder with typed FormGroup/NonNullableFormBuilder and related imports
  • Introduced DateFilterForm interface to define the structure of form controls
  • Refactored initDateFilterForm() to use typed form controls with explicit validators and moved group-level validation to the correct position

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants