1
1
import { Component , inject } from '@angular/core' ;
2
2
import { CommonModule } from '@angular/common' ;
3
- import { FirebaseUI } from '../../provider' ;
4
- import { map } from 'rxjs/operators ' ;
3
+ import { FirebaseUI , FirebaseUIPolicies } from '../../provider' ;
4
+ import { map } from 'rxjs' ;
5
5
6
6
@Component ( {
7
7
selector : 'fui-terms-and-privacy' ,
8
8
standalone : true ,
9
9
imports : [ CommonModule ] ,
10
10
template : `
11
- <!-- < div class="text-text-muted text-xs text-start my-6" *ngIf="shouldShow | async ">
11
+ <div class="text-text-muted text-xs text-start my-6" *ngIf="shouldShow">
12
12
<ng-container *ngFor="let part of parts | async; let i = index">
13
- <a
14
- *ngIf="part.type === 'tos' && (tosUrl | async)"
15
- [href]="tosUrl | async"
16
- target="_blank"
17
- rel="noopener noreferrer"
18
- class="text-text-muted hover:underline text-xs"
13
+ <a
14
+ *ngIf="part.type === 'tos' && tosUrl"
15
+ (click)="handleUrl(tosUrl)"
16
+ class="text-text-muted hover:underline font-semibold cursor-pointer"
19
17
>
20
18
{{ termsText | async }}
21
19
</a>
22
- <a
23
- *ngIf="part.type === 'privacy' && (privacyPolicyUrl | async)"
24
- [href]="privacyPolicyUrl | async"
25
- target="_blank"
26
- rel="noopener noreferrer"
27
- class="text-text-muted hover:underline text-xs"
20
+ <a
21
+ *ngIf="part.type === 'privacy' && privacyPolicyUrl"
22
+ (click)="handleUrl(privacyPolicyUrl)"
23
+ class="text-text-muted hover:underline font-semibold cursor-pointer"
28
24
>
29
25
{{ privacyText | async }}
30
26
</a>
31
- <ng-container *ngIf="part.type === 'text'">{{ part.content }}</ng-container>
27
+ <ng-container *ngIf="part.type === 'text'">
28
+ <span>{{ part.content }}</span>
29
+ </ng-container>
32
30
</ng-container>
33
- </div> -->
31
+ </div>
34
32
` ,
35
33
} )
36
34
export class TermsAndPrivacyComponent {
37
35
private ui = inject ( FirebaseUI ) ;
36
+ private policies = inject ( FirebaseUIPolicies ) ;
38
37
39
- // tosUrl = this.ui.config().pipe(
40
- // map(config => config?.tosUrl)
41
- // );
38
+ tosUrl = this . policies . termsOfServiceUrl ;
39
+ privacyPolicyUrl = this . policies . privacyPolicyUrl ;
42
40
43
- // privacyPolicyUrl = this.ui.config().pipe(
44
- // map(config => config?.privacyPolicyUrl)
45
- // );
46
-
47
- // shouldShow = this.ui.config().pipe(
48
- // map(config => !!(config?.tosUrl || config?.privacyPolicyUrl))
49
- // );
41
+ shouldShow = ! ! ( this . tosUrl || this . privacyPolicyUrl ) ;
50
42
51
43
termsText = this . ui . translation ( 'labels' , 'termsOfService' ) ;
52
44
privacyText = this . ui . translation ( 'labels' , 'privacyPolicy' ) ;
@@ -55,14 +47,16 @@ export class TermsAndPrivacyComponent {
55
47
map ( ( text ) => {
56
48
const parts = text . split ( / ( { t o s } | { p r i v a c y } ) / ) ;
57
49
return parts . map ( ( part ) => {
58
- if ( part === '{tos}' ) {
59
- return { type : 'tos' } ;
60
- }
61
- if ( part === '{privacy}' ) {
62
- return { type : 'privacy' } ;
63
- }
50
+ if ( part === '{tos}' ) return { type : 'tos' } ;
51
+ if ( part === '{privacy}' ) return { type : 'privacy' } ;
64
52
return { type : 'text' , content : part } ;
65
53
} ) ;
66
54
} ) ,
67
55
) ;
56
+
57
+ handleUrl ( url : string ) {
58
+ if ( url ) {
59
+ window . open ( url , '_blank' , 'noopener,noreferrer' ) ;
60
+ }
61
+ }
68
62
}
0 commit comments