Skip to content

Commit

Permalink
feat: add sync dimensions polling to qbo and xero (#921)
Browse files Browse the repository at this point in the history
* feat: add sync dimensions polling to qbo onboarding

* feat: add sync dimensions polling to xero onboarding

(cherry picked from commit b78cfdf)
  • Loading branch information
JustARatherRidiculouslyLongUsername committed Aug 21, 2024
1 parent 054b4a3 commit 714a6c5
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { QBOOnboardingModel } from 'src/app/core/models/qbo/qbo-configuration/qb
import { CloneSettingService } from 'src/app/core/services/common/clone-setting.service';
import { HelperService } from 'src/app/core/services/common/helper.service';
import { IntegrationsToastService } from 'src/app/core/services/common/integrations-toast.service';
import { StorageService } from 'src/app/core/services/common/storage.service';
import { WorkspaceService } from 'src/app/core/services/common/workspace.service';
import { UserService } from 'src/app/core/services/misc/user.service';
import { QboConnectorService } from 'src/app/core/services/qbo/qbo-configuration/qbo-connector.service';
Expand Down Expand Up @@ -82,7 +83,8 @@ export class QboOnboardingConnectorComponent implements OnInit, OnDestroy {
private router: Router,
private toastService: IntegrationsToastService,
private userService: UserService,
private workspaceService: WorkspaceService
private workspaceService: WorkspaceService,
private storageService: StorageService
) { }

connectQbo(): void {
Expand Down Expand Up @@ -182,11 +184,16 @@ export class QboOnboardingConnectorComponent implements OnInit, OnDestroy {
const payload: QBOConnectorPost = QBOConnectorModel.constructPayload(code, realmId);

this.qboConnectorService.connectQBO(payload).subscribe((qboCredential: QBOCredential) => {
this.qboHelperService.refreshQBODimensions().subscribe(() => {
this.handlePostQBOConnection(qboCredential);
}, () => {
this.handlePostQBOConnection(qboCredential);
this.qboHelperService.refreshQBODimensions().subscribe();

const fyleOrgId = this.storageService.get('org').fyle_org_id;
this.helperService.pollDimensionsSyncStatus({
onPollingComplete: () => {
this.handlePostQBOConnection(qboCredential);
},
getWorkspacesObserver: () => this.workspaceService.getWorkspace(fyleOrgId)
});

}, (error) => {
const errorMessage = 'message' in error.error ? error.error.message : 'Failed to connect to QuickBooks Online. Please try again';
if (errorMessage === 'Please choose the correct QuickBooks Online account') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { XeroOnboardingModel } from 'src/app/core/models/xero/xero-configuration
import { CloneSettingService } from 'src/app/core/services/common/clone-setting.service';
import { HelperService } from 'src/app/core/services/common/helper.service';
import { IntegrationsToastService } from 'src/app/core/services/common/integrations-toast.service';
import { StorageService } from 'src/app/core/services/common/storage.service';
import { WorkspaceService } from 'src/app/core/services/common/workspace.service';
import { UserService } from 'src/app/core/services/misc/user.service';
import { XeroConnectorService } from 'src/app/core/services/xero/xero-configuration/xero-connector.service';
Expand Down Expand Up @@ -90,7 +91,8 @@ export class XeroOnboardingConnectorComponent implements OnInit {
private router: Router,
private toastService: IntegrationsToastService,
private cloneSettingService: CloneSettingService,
private xeroHelperService: XeroHelperService
private xeroHelperService: XeroHelperService,
private storageService: StorageService
) { }

private checkCloneSettingsAvailablity(): void {
Expand Down Expand Up @@ -193,15 +195,22 @@ export class XeroOnboardingConnectorComponent implements OnInit {
this.xeroCompanyName = this.xeroTenantselected.value;
const tenantMappingPayload: TenantMappingPost = TenantMappingModel.constructPayload(this.xeroTenantselected);
this.xeroConnectorService.postTenantMapping(tenantMappingPayload).subscribe((response:TenantMapping) => {
this.xeroHelperService.refreshXeroDimensions().subscribe(() => {
this.workspaceService.setOnboardingState(XeroOnboardingState.EXPORT_SETTINGS);
this.xeroConnectionInProgress = false;
this.xeroTokenExpired = false;
this.isXeroConnected = true;
this.xeroCompanyName = response.tenant_name;
this.showOrHideDisconnectXero();
this.checkCloneSettingsAvailablity();
this.xeroHelperService.refreshXeroDimensions().subscribe();

const fyleOrgId = this.storageService.get('org').fyle_org_id;
this.helperService.pollDimensionsSyncStatus({
onPollingComplete: () => {
this.workspaceService.setOnboardingState(XeroOnboardingState.EXPORT_SETTINGS);
this.xeroConnectionInProgress = false;
this.xeroTokenExpired = false;
this.isXeroConnected = true;
this.xeroCompanyName = response.tenant_name;
this.showOrHideDisconnectXero();
this.checkCloneSettingsAvailablity();
},
getWorkspacesObserver: () => this.workspaceService.getWorkspace(fyleOrgId)
});

});
} else {
return;
Expand Down

0 comments on commit 714a6c5

Please sign in to comment.