Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@
<button *ngIf="isIntegrationConnected && (appName === AppName.BAMBOO_HR || appName === AppName.TRAVELPERK)" pButton type="button" class="p-button danger-outline" (click)="disconnect()">
{{ isConnectionInProgress ? 'Disconnecting' : 'Disconnect' }}
</button>
<button *ngIf="!isIntegrationConnected && (appName === AppName.QBD || appName === AppName.NETSUITE || appName === AppName.INTACCT || appName === AppName.SAGE300 || appName === AppName.BUSINESS_CENTRAL || appName.includes(AppName.QBD_DIRECT))" pButton type="button" class="p-button-raised" (click)="connect()">
<button *ngIf="!isIntegrationConnected && (appName === AppName.QBD || appName === AppName.NETSUITE || appName === AppName.INTACCT || appName === AppName.SAGE300 || appName === AppName.BUSINESS_CENTRAL || appName.includes('QuickBooks Desktop - Direct Integration'))" pButton type="button" class="p-button-raised" (click)="connect()">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Simplify complex conditional and use enum constants

The *ngIf condition is overly complex and uses string literals. This makes the template harder to read and maintain.

Consider moving the condition to a component method:

-<button *ngIf="!isIntegrationConnected && (appName === AppName.QBD || appName === AppName.NETSUITE || appName === AppName.INTACCT || appName === AppName.SAGE300 || appName === AppName.BUSINESS_CENTRAL || appName.includes('QuickBooks Desktop - Direct Integration'))" 
+<button *ngIf="!isIntegrationConnected && shouldShowConnectButton()" 

Add this method to your component:

shouldShowConnectButton(): boolean {
  return [
    AppName.QBD,
    AppName.NETSUITE,
    AppName.INTACCT,
    AppName.SAGE300,
    AppName.BUSINESS_CENTRAL,
    AppName.QBD_DIRECT
  ].includes(this.appName as AppName);
}

{{buttonText}}
<app-svg-icon *ngIf="(appName === AppName.QBD || appName.includes(AppName.QBD_DIRECT)) && brandingFeatureConfig.isIconsInsideButtonAllowed" [svgSource]="'arrow-tail-right-medium'" [width]="'18px'" [height]="'18px'" [styleClasses]="'tw-pl-10-px tw-pt-2-px !tw-text-12-px'"></app-svg-icon>
<app-svg-icon *ngIf="(appName === AppName.QBD || appName.includes('QuickBooks Desktop - Direct Integration')) && brandingFeatureConfig.isIconsInsideButtonAllowed" [svgSource]="'arrow-tail-right-medium'" [width]="'18px'" [height]="'18px'" [styleClasses]="'tw-pl-10-px tw-pt-2-px !tw-text-12-px'"></app-svg-icon>
<app-loader class="tw-ml-10-px" *ngIf="isConnectionInProgress" [styleClass]="'spinner-16-white tw-top-2-px'"></app-loader>
</button>
<iframe *ngIf="iframeSourceUrl && (appName === AppName.TRAVELPERK)" scrolling="no" [src]="iframeSourceUrl" class="tw-mt-40-px tw-w-270-px tw-h-84-px"></iframe>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export class AppLandingPageHeaderComponent implements OnInit {
}

connect(): void {
if (this.appName === AppName.TRAVELPERK || this.appName === AppName.BUSINESS_CENTRAL || this.appName === AppName.BAMBOO_HR || this.appName === AppName.XERO || this.appName.includes(AppName.QBD_DIRECT)) {
if (this.appName === AppName.TRAVELPERK || this.appName === AppName.BUSINESS_CENTRAL || this.appName === AppName.BAMBOO_HR || this.appName === AppName.XERO || this.appName.includes('QuickBooks Desktop - Direct Integration')) {
this.initiateOAuth();
return;
} else if (this.postConnectionRoute === 'qbd/onboarding/export_settings') {
Expand Down
Loading