@@ -2,8 +2,9 @@ import { Component, Inject, OnInit } from '@angular/core';
2
2
import { Router } from '@angular/router' ;
3
3
import { MenuItem } from 'primeng/api' ;
4
4
import { brandingContent , brandingFeatureConfig } from 'src/app/branding/branding-config' ;
5
- import { AppName } from 'src/app/core/models/enum/enum.model' ;
5
+ import { AppName , ToastSeverity } from 'src/app/core/models/enum/enum.model' ;
6
6
import { AccountingExportService } from 'src/app/core/services/common/accounting-export.service' ;
7
+ import { IntegrationsToastService } from 'src/app/core/services/common/integrations-toast.service' ;
7
8
import { XeroHelperService } from 'src/app/core/services/xero/xero-core/xero-helper.service' ;
8
9
9
10
@Component ( {
@@ -17,6 +18,8 @@ export class XeroMainComponent implements OnInit {
17
18
18
19
readonly brandingContent = brandingContent . common ;
19
20
21
+ readonly disconnectButton = brandingFeatureConfig . featureFlags . dashboard . disconnectButton ;
22
+
20
23
modules : MenuItem [ ] = [
21
24
{ label : 'Dashboard' , routerLink : '/integrations/xero/main/dashboard' } ,
22
25
{ label : this . brandingContent . exportLogTabName , routerLink : '/integrations/xero/main/export_log' } ,
@@ -28,12 +31,26 @@ export class XeroMainComponent implements OnInit {
28
31
29
32
readonly brandingFeatureConfig = brandingFeatureConfig ;
30
33
34
+ isConnectionInProgress : boolean = false ;
35
+
31
36
constructor (
32
37
private accountingExportService : AccountingExportService ,
33
38
private xeroHelperService : XeroHelperService ,
34
- private router : Router
39
+ private router : Router ,
40
+ private toastService : IntegrationsToastService
35
41
) { }
36
42
43
+ disconnect ( ) : void {
44
+ if ( ! this . isConnectionInProgress ) {
45
+ this . xeroHelperService . disconnect ( ) . subscribe ( ( ) => {
46
+ this . isConnectionInProgress = false ;
47
+ this . toastService . displayToastMessage ( ToastSeverity . SUCCESS , 'Disconnected Xero Company successfully' ) ;
48
+ this . router . navigate ( [ '/integrations/xero/onboarding/landing' ] ) ;
49
+ } ) ;
50
+ }
51
+ this . isConnectionInProgress = true ;
52
+ }
53
+
37
54
refreshDimensions ( ) {
38
55
this . xeroHelperService . refreshXeroDimensions ( ) . subscribe ( ) ;
39
56
this . xeroHelperService . refreshFyleDimensions ( ) . subscribe ( ) ;
0 commit comments