Skip to content

Commit 82fd9d5

Browse files
authored
feat: Xero Disconnect (#1008)
* feat: Xero Disconnect * update url * fix url
1 parent 4e6d820 commit 82fd9d5

File tree

3 files changed

+24
-3
lines changed

3 files changed

+24
-3
lines changed

src/app/core/services/xero/xero-core/xero-helper.service.ts

+4
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,8 @@ export class XeroHelperService {
3030
refreshFyleDimensions() {
3131
return this.apiService.post(`/workspaces/${this.workspaceService.getWorkspaceId()}/fyle/refresh_dimensions/`, {});
3232
}
33+
34+
disconnect() {
35+
return this.apiService.post(`/workspaces/${this.workspaceService.getWorkspaceId()}/connection/xero/revoke/`, {});
36+
}
3337
}

src/app/integrations/xero/xero-main/xero-main.component.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<div [ngClass]="{'tw-h-100-vh tw-bg-bg-tertiary-lighter tw-overflow-auto': brandingFeatureConfig.isBackgroundColorAllowed}">
2-
<app-main-menu [modules]="modules" [activeItem]="modules[0]" [appName]="appName" [isDropdrownRequired]="false" (refreshDimensionClick)="refreshDimensions()" [isSyncVisible]="true"></app-main-menu>
2+
<app-main-menu [modules]="modules" [activeItem]="modules[0]" [appName]="appName" [isDropdrownRequired]="false" (refreshDimensionClick)="refreshDimensions()" [isSyncVisible]="true" [isDisconnectRequired]="disconnectButton" (disconnectClick)="disconnect()"></app-main-menu>
33
<div>
44
<router-outlet></router-outlet>
55
</div>

src/app/integrations/xero/xero-main/xero-main.component.ts

+19-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@ import { Component, Inject, OnInit } from '@angular/core';
22
import { Router } from '@angular/router';
33
import { MenuItem } from 'primeng/api';
44
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';
66
import { AccountingExportService } from 'src/app/core/services/common/accounting-export.service';
7+
import { IntegrationsToastService } from 'src/app/core/services/common/integrations-toast.service';
78
import { XeroHelperService } from 'src/app/core/services/xero/xero-core/xero-helper.service';
89

910
@Component({
@@ -17,6 +18,8 @@ export class XeroMainComponent implements OnInit {
1718

1819
readonly brandingContent = brandingContent.common;
1920

21+
readonly disconnectButton = brandingFeatureConfig.featureFlags.dashboard.disconnectButton;
22+
2023
modules: MenuItem[] = [
2124
{label: 'Dashboard', routerLink: '/integrations/xero/main/dashboard'},
2225
{label: this.brandingContent.exportLogTabName, routerLink: '/integrations/xero/main/export_log'},
@@ -28,12 +31,26 @@ export class XeroMainComponent implements OnInit {
2831

2932
readonly brandingFeatureConfig = brandingFeatureConfig;
3033

34+
isConnectionInProgress: boolean = false;
35+
3136
constructor(
3237
private accountingExportService: AccountingExportService,
3338
private xeroHelperService: XeroHelperService,
34-
private router: Router
39+
private router: Router,
40+
private toastService: IntegrationsToastService
3541
) { }
3642

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+
3754
refreshDimensions() {
3855
this.xeroHelperService.refreshXeroDimensions().subscribe();
3956
this.xeroHelperService.refreshFyleDimensions().subscribe();

0 commit comments

Comments
 (0)