Skip to content

Commit bbbbe81

Browse files
committed
feat(angular): tos migrated to terms & service provider
1 parent e7926b7 commit bbbbe81

File tree

2 files changed

+35
-34
lines changed

2 files changed

+35
-34
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,44 @@
11
import { Component, inject } from '@angular/core';
22
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';
55

66
@Component({
77
selector: 'fui-terms-and-privacy',
88
standalone: true,
99
imports: [CommonModule],
1010
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">
1212
<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"
1917
>
2018
{{ termsText | async }}
2119
</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"
2824
>
2925
{{ privacyText | async }}
3026
</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>
3230
</ng-container>
33-
</div> -->
31+
</div>
3432
`,
3533
})
3634
export class TermsAndPrivacyComponent {
3735
private ui = inject(FirebaseUI);
36+
private policies = inject(FirebaseUIPolicies);
3837

39-
// tosUrl = this.ui.config().pipe(
40-
// map(config => config?.tosUrl)
41-
// );
38+
tosUrl = this.policies.termsOfServiceUrl;
39+
privacyPolicyUrl = this.policies.privacyPolicyUrl;
4240

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);
5042

5143
termsText = this.ui.translation('labels', 'termsOfService');
5244
privacyText = this.ui.translation('labels', 'privacyPolicy');
@@ -55,14 +47,16 @@ export class TermsAndPrivacyComponent {
5547
map((text) => {
5648
const parts = text.split(/({tos}|{privacy})/);
5749
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' };
6452
return { type: 'text', content: part };
6553
});
6654
}),
6755
);
56+
57+
handleUrl(url: string) {
58+
if (url) {
59+
window.open(url, '_blank', 'noopener,noreferrer');
60+
}
61+
}
6862
}

packages/angular/src/app/app.config.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@ import {
99

1010
import { provideFirebaseApp, initializeApp } from '@angular/fire/app';
1111
import { provideAuth, getAuth, connectAuthEmulator } from '@angular/fire/auth';
12-
import { provideFirebaseUI } from '@firebase-ui/angular';
12+
import {
13+
provideFirebaseUI,
14+
provideFirebaseUIPolicies,
15+
} from '@firebase-ui/angular';
1316
import { initializeUI } from '@firebase-ui/core';
1417

1518
const firebaseConfig = {
@@ -36,5 +39,9 @@ export const appConfig: ApplicationConfig = {
3639
return auth;
3740
}),
3841
provideFirebaseUI((apps) => initializeUI({ app: apps[0] })),
42+
provideFirebaseUIPolicies(() => ({
43+
termsOfServiceUrl: 'https://www.google.com',
44+
privacyPolicyUrl: 'https://www.google.com',
45+
})),
3946
],
4047
};

0 commit comments

Comments
 (0)