11import { Component , EventEmitter , inject } from '@angular/core' ;
22import { MatSnackBar } from '@angular/material/snack-bar' ;
33import { ActivatedRoute , Router , RouterLink } from '@angular/router' ;
4- import { IonButtons , IonContent , IonHeader , IonIcon , IonSkeletonText , IonTitle , IonToolbar , ModalController , PopoverController } from '@ionic/angular/standalone' ;
4+ import {
5+ IonButtons ,
6+ IonContent ,
7+ IonHeader ,
8+ IonIcon ,
9+ IonSkeletonText ,
10+ IonTitle ,
11+ IonToolbar ,
12+ ModalController ,
13+ PopoverController ,
14+ } from '@ionic/angular/standalone' ;
515import { Observable , Subscription , concat , forkJoin , from , noop , finalize } from 'rxjs' ;
6- import { map , shareReplay , switchMap } from 'rxjs/operators' ;
16+ import { map , shareReplay , switchMap , take } from 'rxjs/operators' ;
717import { ExtendedOrgUser } from 'src/app/core/models/extended-org-user.model' ;
818import { InfoCardData } from 'src/app/core/models/info-card-data.model' ;
919import { Org } from 'src/app/core/models/org.model' ;
@@ -57,6 +67,7 @@ import { MatRipple } from '@angular/material/core';
5767import { NgClass , AsyncPipe } from '@angular/common' ;
5868import { InfoCardComponent } from './info-card/info-card.component' ;
5969import { PreferenceSettingComponent } from './preference-setting/preference-setting.component' ;
70+ import { TranslocoService } from '@jsverse/transloco' ;
6071
6172@Component ( {
6273 selector : 'app-my-profile' ,
@@ -79,7 +90,7 @@ import { PreferenceSettingComponent } from './preference-setting/preference-sett
7990 NgClass ,
8091 PreferenceSettingComponent ,
8192 ProfileOptInCardComponent ,
82- RouterLink
93+ RouterLink ,
8394 ] ,
8495} )
8596export class MyProfilePage {
@@ -137,6 +148,8 @@ export class MyProfilePage {
137148
138149 private featureConfigService = inject ( FeatureConfigService ) ;
139150
151+ private translocoService = inject ( TranslocoService ) ;
152+
140153 employeeSettings : EmployeeSettings ;
141154
142155 orgSettings : OrgSettings ;
@@ -160,7 +173,7 @@ export class MyProfilePage {
160173
161174 preferenceSettings : PreferenceSetting [ ] = [ ] ;
162175
163- infoCardsData : CopyCardDetails [ ] ;
176+ infoCardsData : InfoCardData [ ] ;
164177
165178 commuteDetails : CommuteDetails ;
166179
@@ -375,8 +388,14 @@ export class MyProfilePage {
375388 this . org$ = this . orgService . getCurrentOrg ( ) ;
376389 const orgSettings$ = this . orgSettingsService . get ( ) ;
377390
391+ // Set info cards initially (without eou for email receipts card)
378392 this . setInfoCardsData ( ) ;
379393
394+ // Subscribe to eou$ to update info cards when eou is available (for Magic mail card)
395+ this . eou$ . pipe ( take ( 1 ) ) . subscribe ( ( eou ) => {
396+ this . setInfoCardsData ( eou ) ;
397+ } ) ;
398+
380399 forkJoin ( {
381400 employeeSettings : employeeSettings$ ,
382401 orgSettings : orgSettings$ ,
@@ -456,18 +475,31 @@ export class MyProfilePage {
456475 this . preferenceSettings = allPreferenceSettings . filter ( ( setting ) => setting . isAllowed ) ;
457476 }
458477
459- setInfoCardsData ( ) : void {
478+ setInfoCardsData ( eou ?: ExtendedOrgUser ) : void {
460479 const fyleEmail = '[email protected] ' ; 461480
462- const allInfoCardsData : InfoCardData [ ] = [
463- {
464- title : 'Email receipts' ,
465- content : `Forward your receipts to Sage Expense Management at ${ fyleEmail } .` ,
466- contentToCopy : fyleEmail ,
467- toastMessageContent : 'Email copied successfully' ,
481+ const allInfoCardsData : InfoCardData [ ] = [ ] ;
482+
483+ if ( eou ?. ou ?. special_email ) {
484+ allInfoCardsData . push ( {
485+ title : this . translocoService . translate < string > ( 'myProfile.magicMail.title' ) ,
486+ content : this . translocoService . translate < string > ( 'myProfile.magicMail.content' ) ,
487+ contentToCopy : eou . ou . special_email ,
488+ toastMessageContent : this . translocoService . translate < string > ( 'myProfile.emailCopiedSuccessfully' ) ,
468489 isShown : true ,
469- } ,
470- ] ;
490+ showMagicEmail : true ,
491+ showBetaTag : true ,
492+ } ) ;
493+ }
494+
495+ allInfoCardsData . push ( {
496+ title : this . translocoService . translate < string > ( 'myProfile.emailReceipts.title' ) ,
497+ content : this . translocoService . translate < string > ( 'myProfile.emailReceipts.content' ) ,
498+ contentToCopy : fyleEmail ,
499+ toastMessageContent : this . translocoService . translate < string > ( 'myProfile.emailCopiedSuccessfully' ) ,
500+ isShown : true ,
501+ showMagicEmail : true ,
502+ } ) ;
471503
472504 this . infoCardsData = allInfoCardsData . filter ( ( infoCardData ) => infoCardData . isShown ) ;
473505 }
0 commit comments