1
- import { createDispatchMap } from '@ngxs/store' ;
1
+ import { createDispatchMap , select } from '@ngxs/store' ;
2
+
3
+ import { TranslateService } from '@ngx-translate/core' ;
4
+
5
+ import { DialogService } from 'primeng/dynamicdialog' ;
2
6
3
7
import { filter } from 'rxjs/operators' ;
4
8
5
- import { ChangeDetectionStrategy , Component , DestroyRef , inject , OnInit } from '@angular/core' ;
9
+ import { ChangeDetectionStrategy , Component , DestroyRef , effect , inject , OnInit } from '@angular/core' ;
6
10
import { takeUntilDestroyed } from '@angular/core/rxjs-interop' ;
7
11
import { NavigationEnd , Router , RouterOutlet } from '@angular/router' ;
8
12
9
13
import { GetCurrentUser } from '@core/store/user' ;
14
+ import { GetEmails , UserEmailsSelectors } from '@core/store/user-emails' ;
15
+ import { ConfirmEmailComponent } from '@shared/components' ;
10
16
11
17
import { FullScreenLoaderComponent , ToastComponent } from './shared/components' ;
12
18
import { MetaTagsService } from './shared/services/meta-tags.service' ;
@@ -17,23 +23,31 @@ import { MetaTagsService } from './shared/services/meta-tags.service';
17
23
templateUrl : './app.component.html' ,
18
24
styleUrl : './app.component.scss' ,
19
25
changeDetection : ChangeDetectionStrategy . OnPush ,
26
+ providers : [ DialogService ] ,
20
27
} )
21
28
export class AppComponent implements OnInit {
22
- private destroyRef = inject ( DestroyRef ) ;
29
+ private readonly destroyRef = inject ( DestroyRef ) ;
30
+ private readonly dialogService = inject ( DialogService ) ;
31
+ private readonly router = inject ( Router ) ;
32
+ private readonly translateService = inject ( TranslateService ) ;
33
+ private readonly metaTagsService = inject ( MetaTagsService ) ;
34
+
35
+ private readonly actions = createDispatchMap ( { getCurrentUser : GetCurrentUser , getEmails : GetEmails } ) ;
23
36
24
- actions = createDispatchMap ( {
25
- getCurrentUser : GetCurrentUser ,
26
- } ) ;
37
+ unverifiedEmails = select ( UserEmailsSelectors . getUnverifiedEmails ) ;
27
38
28
- constructor (
29
- private router : Router ,
30
- private metaTagsService : MetaTagsService
31
- ) {
39
+ constructor ( ) {
32
40
this . setupMetaTagsCleanup ( ) ;
41
+ effect ( ( ) => {
42
+ if ( this . unverifiedEmails ( ) . length ) {
43
+ this . showEmailDialog ( ) ;
44
+ }
45
+ } ) ;
33
46
}
34
47
35
48
ngOnInit ( ) : void {
36
49
this . actions . getCurrentUser ( ) ;
50
+ this . actions . getEmails ( ) ;
37
51
}
38
52
39
53
private setupMetaTagsCleanup ( ) : void {
@@ -44,4 +58,15 @@ export class AppComponent implements OnInit {
44
58
)
45
59
. subscribe ( ( event : NavigationEnd ) => this . metaTagsService . clearMetaTagsIfNeeded ( event . url ) ) ;
46
60
}
61
+
62
+ private showEmailDialog ( ) {
63
+ this . dialogService . open ( ConfirmEmailComponent , {
64
+ width : '448px' ,
65
+ focusOnShow : false ,
66
+ header : this . translateService . instant ( 'home.confirmEmail.title' ) ,
67
+ modal : true ,
68
+ closable : false ,
69
+ data : this . unverifiedEmails ( ) ,
70
+ } ) ;
71
+ }
47
72
}
0 commit comments