File tree 5 files changed +64
-3
lines changed
libs/carrier-portal/ui/src/lib
5 files changed +64
-3
lines changed Original file line number Diff line number Diff line change @@ -44,8 +44,19 @@ <h3>Enrollment Group</h3>
44
44
</ td >
45
45
< td > {{ t('relationships.' + enrollee.relationship) | titlecase }}</ td >
46
46
< 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 >
49
60
</ td >
50
61
< td > {{ enrollee.carrier_member_id }}</ td >
51
62
< td > {{ enrollee.carrier_policy_id }}</ td >
Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ import { TranslocoModule } from '@ngneat/transloco';
11
11
12
12
import { Policy } from '@enroll/carrier-portal/types' ;
13
13
14
- import { SortByDatePipe } from '../pipes' ;
14
+ import { SortByDatePipe , PolicyEndDatePipe } from '../pipes' ;
15
15
16
16
@Component ( {
17
17
selector : 'enroll-member-policy' ,
@@ -23,6 +23,7 @@ import { SortByDatePipe } from '../pipes';
23
23
DatePipe ,
24
24
CurrencyPipe ,
25
25
SortByDatePipe ,
26
+ PolicyEndDatePipe ,
26
27
TranslocoModule ,
27
28
TitleCasePipe ,
28
29
] ,
Original file line number Diff line number Diff line change @@ -6,3 +6,4 @@ export * from './phone-number.pipe';
6
6
export * from './sort-by-date.pipe' ;
7
7
export * from './sort-by-status.pipe' ;
8
8
export * from './sort-by-policy-start.pipe' ;
9
+ export * from './policy-end-date.pipe' ;
Original file line number Diff line number Diff line change
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 number Diff line number Diff line change
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
+ }
You can’t perform that action at this time.
0 commit comments