Skip to content

Commit 1dc8186

Browse files
authored
Merge branch 'trunk' into update/fix-console-commonjs-warnings
2 parents 4f2d6a6 + 12e558c commit 1dc8186

File tree

5 files changed

+64
-3
lines changed

5 files changed

+64
-3
lines changed

libs/carrier-portal/ui/src/lib/member-policy/member-policy.component.html

+13-2
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,19 @@ <h3>Enrollment Group</h3>
4444
</td>
4545
<td>{{ t('relationships.' + enrollee.relationship) | titlecase }}</td>
4646
<td>
47-
{{ enrollee.coverage_start | date : 'M/d/yy' }}
48-
- {{ (enrollee.coverage_end | date : 'M/d/yy') ?? '' }}
47+
{{ enrollee.coverage_start | date : 'M/d/yy' }} -
48+
<ng-container
49+
*ngIf="enrollee.coverage_end; then endGiven; else noEndGiven"
50+
>
51+
</ng-container>
52+
53+
<ng-template #endGiven>
54+
{{ enrollee.coverage_end | date : 'M/d/yy' }}
55+
</ng-template>
56+
57+
<ng-template #noEndGiven>
58+
{{ enrollee.coverage_start | policyEndDate }}
59+
</ng-template>
4960
</td>
5061
<td>{{ enrollee.carrier_member_id }}</td>
5162
<td>{{ enrollee.carrier_policy_id }}</td>

libs/carrier-portal/ui/src/lib/member-policy/member-policy.component.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { TranslocoModule } from '@ngneat/transloco';
1111

1212
import { Policy } from '@enroll/carrier-portal/types';
1313

14-
import { SortByDatePipe } from '../pipes';
14+
import { SortByDatePipe, PolicyEndDatePipe } from '../pipes';
1515

1616
@Component({
1717
selector: 'enroll-member-policy',
@@ -23,6 +23,7 @@ import { SortByDatePipe } from '../pipes';
2323
DatePipe,
2424
CurrencyPipe,
2525
SortByDatePipe,
26+
PolicyEndDatePipe,
2627
TranslocoModule,
2728
TitleCasePipe,
2829
],

libs/carrier-portal/ui/src/lib/pipes/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ export * from './phone-number.pipe';
66
export * from './sort-by-date.pipe';
77
export * from './sort-by-status.pipe';
88
export * from './sort-by-policy-start.pipe';
9+
export * from './policy-end-date.pipe';
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import { PolicyEndDatePipe } from './policy-end-date.pipe';
2+
3+
describe('PolicyEndDatePipe', () => {
4+
let pipe: PolicyEndDatePipe;
5+
const currentYear = new Date();
6+
const thisYear = currentYear.toString();
7+
const futureYear = (currentYear.getFullYear() + 1).toString();
8+
const previousYear = (currentYear.getFullYear() - 1).toString();
9+
10+
beforeEach(() => {
11+
pipe = new PolicyEndDatePipe();
12+
});
13+
14+
it('returns an empty string if the current year is equal to the given year', () => {
15+
const policyStartDate = thisYear;
16+
expect(pipe.transform(policyStartDate)).toBe('');
17+
});
18+
19+
it('returns an empty string if the current year is greater than the given year', () => {
20+
const policyStartDate = futureYear;
21+
expect(pipe.transform(policyStartDate)).toBe('');
22+
});
23+
24+
it('returns the last day of the year for the given date if the given year is less than the current year', () => {
25+
// const policyStartDate = '2021-03-01';
26+
const policyStartDate = previousYear;
27+
expect(pipe.transform(policyStartDate)).toBe(
28+
`12/31/${previousYear.substring(2, 4)}`
29+
);
30+
});
31+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/* eslint-disable @typescript-eslint/naming-convention */
2+
import { Pipe, PipeTransform } from '@angular/core';
3+
4+
type DateString = string;
5+
6+
@Pipe({
7+
name: 'policyEndDate',
8+
standalone: true,
9+
})
10+
export class PolicyEndDatePipe implements PipeTransform {
11+
currentYear = new Date().getFullYear().toString().substring(2, 4);
12+
transform(value: DateString) {
13+
const policyStartYear = value.substring(2, 4);
14+
15+
return policyStartYear < this.currentYear ? `12/31/${policyStartYear}` : '';
16+
}
17+
}

0 commit comments

Comments
 (0)