Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor member-coverage component to handle policy status and display correctly #125

Open
wants to merge 2 commits into
base: trunk
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ <h2>Personal Info</h2>
<!-- This translation is coming from the generic translations -->
<dd>{{ t(member.gender) | titlecase }}</dd>
<dt>DOB</dt>
<dd>{{ member.dob | date : 'MM/dd/YYYY' }}</dd>
<dd>{{ member.dob | date: 'MM/dd/YYYY' }}</dd>
<dt>SSN</dt>
<dd>{{ member.ssn | formatSsn }}</dd>
</dl>
Expand All @@ -45,7 +45,47 @@ <h2>Policies</h2>
else dentalPolicyIcon
"
></ng-container>
<span>{{ policy.status }}</span>

<span>
<ng-container
*ngIf="
policy.status === 'Submitted' &&
policy.plan.coverage_year < currentYear;
else originalStatus
"
>
Expired
</ng-container>

<ng-template #originalStatus>
<span>
<ng-container
*ngIf="
policy.status === 'Submitted' &&
policy.plan.coverage_year >= currentYear
"
>
Active
</ng-container>
<ng-container
*ngIf="
policy.status === 'Resubmitted' &&
policy.plan.coverage_year >= currentYear
"
>
Reinstated
</ng-container>
<ng-container
*ngIf="
policy.status !== 'Submitted' &&
policy.status !== 'Resubmitted'
"
>
{{ policy.status }}
</ng-container>
</span>
</ng-template>
</span>
<span>{{ policy.hbx_assigned_id }}</span>
<span>{{ policy.plan.coverage_year }}</span>
<span>{{ policy.plan.name }}</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ import { PersonContactInfoComponent } from './person-contact-info.component';
scope: 'memberCoverage',
loader: scopeLoader(
(lang: string, root: string) =>
import(`./${root}/${lang}.json`) as Promise<Translation>
import(`./${root}/${lang}.json`) as Promise<Translation>,
),
},
},
Expand All @@ -49,12 +49,13 @@ import { PersonContactInfoComponent } from './person-contact-info.component';
export class MemberCoverageComponent {
personService = inject(PersonService);
route = inject(ActivatedRoute);
currentYear = new Date().getFullYear().toString();
Copy link

Choose a reason for hiding this comment

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

Initialization of currentYear using new Date().getFullYear().toString() is correct and aligns with the PR objectives to use the current year in conditional rendering logic. However, consider the implications of converting the year to a string if numerical comparisons are needed elsewhere.

-  currentYear = new Date().getFullYear().toString();
+  currentYear = new Date().getFullYear(); // If numerical comparison is needed, keep it as a number.

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
currentYear = new Date().getFullYear().toString();
currentYear = new Date().getFullYear(); // If numerical comparison is needed, keep it as a number.


id!: string | null;
person$: Observable<DataResult<Person>> = this.route.paramMap.pipe(
map((parameters: ParamMap) => parameters.get('id') ?? '___IGNORE___'),
filter((idString: string) => idString !== '___IGNORE___'),
switchMap((id: string) => this.personService.getPerson(id))
switchMap((id: string) => this.personService.getPerson(id)),
);

public policyExpanded(pol: Policy): boolean {
Expand All @@ -63,7 +64,7 @@ export class MemberCoverageComponent {

private subscriber(pol: Policy): Enrollee | undefined {
return pol.enrollees.find(
(en: Enrollee) => en.hbx_member_id === pol.subscriber_hbx_member_id
(en: Enrollee) => en.hbx_member_id === pol.subscriber_hbx_member_id,
);
}

Expand Down
Loading