Skip to content

Commit

Permalink
qbd direct integration advanced settings save changes (#951)
Browse files Browse the repository at this point in the history
* qbd direct integration advanced settings save changes
  • Loading branch information
DhaaraniCIT authored Sep 24, 2024
1 parent b6dcbf4 commit 98e00e0
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,21 @@ export class QbdDirectAdvancedSettingsModel extends AdvancedSettingsModel {
searchOption: new FormControl('')
});
}

static constructPayload (advancedSettingForm: FormGroup): QbdDirectAdvancedSettingsPost {

const topMemo: string[] = [];
topMemo.push(advancedSettingForm.value.topMemoStructure);

const advancedSettingPayload: QbdDirectAdvancedSettingsPost = {
expense_memo_structure: advancedSettingForm.get('expenseMemoStructure')?.value ? advancedSettingForm.get('expenseMemoStructure')?.value : null,
top_memo_structure: advancedSettingForm.get('topMemoStructure')?.value ? topMemo : null,
schedule_is_enabled: advancedSettingForm.get('exportSchedule')?.value ? advancedSettingForm.get('exportSchedule')?.value : false,
emails_selected: advancedSettingForm.get('exportSchedule')?.value ? advancedSettingForm.get('email')?.value : null,
interval_hours: advancedSettingForm.get('exportSchedule')?.value ? advancedSettingForm.get('exportScheduleFrequency')?.value : null
};

return advancedSettingPayload;
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ import { Router } from '@angular/router';
import { forkJoin } from 'rxjs';
import { brandingConfig, brandingContent, brandingFeatureConfig } from 'src/app/branding/branding-config';
import { EmailOption, SelectFormOption } from 'src/app/core/models/common/select-form-option.model';
import { AppName, ConfigurationCta, QBDScheduleFrequency } from 'src/app/core/models/enum/enum.model';
import { AppName, ConfigurationCta, QBDOnboardingState, QBDScheduleFrequency, ToastSeverity } from 'src/app/core/models/enum/enum.model';
import { QbdDirectAdvancedSettingsGet, QbdDirectAdvancedSettingsModel } from 'src/app/core/models/qbd-direct/qbd-direct-configuration/qbd-direct-advanced-settings.model';
import { HelperService } from 'src/app/core/services/common/helper.service';
import { IntegrationsToastService } from 'src/app/core/services/common/integrations-toast.service';
import { WorkspaceService } from 'src/app/core/services/common/workspace.service';
import { OrgService } from 'src/app/core/services/org/org.service';
import { QbdDirectAdvancedSettingsService } from 'src/app/core/services/qbd-direct/qbd-direct-configuration/qbd-direct-advanced-settings.service';
import { SharedModule } from 'src/app/shared/shared.module';
Expand Down Expand Up @@ -68,12 +70,27 @@ export class QbdDirectAdvancedSettingsComponent implements OnInit {
private advancedSettingsService: QbdDirectAdvancedSettingsService,
public helper: HelperService,
private router: Router,
private orgService: OrgService
// Private toastService: IntegrationsToastService,
// Private workspaceService: WorkspaceService
private orgService: OrgService,
private toastService: IntegrationsToastService,
private workspaceService: WorkspaceService
) { }

save() {}
save() {
this.saveInProgress = true;
const advancedSettingPayload = QbdDirectAdvancedSettingsModel.constructPayload(this.advancedSettingsForm);
this.advancedSettingsService.postQbdAdvancedSettings(advancedSettingPayload).subscribe((response: QbdDirectAdvancedSettingsGet) => {
this.saveInProgress = false;
this.toastService.displayToastMessage(ToastSeverity.SUCCESS, 'Advanced settings saved successfully');

if (this.isOnboarding) {
this.workspaceService.setOnboardingState(QBDOnboardingState.COMPLETE);
this.router.navigate([`/integrations/qbd_direct/onboarding/done`]);
}
}, () => {
this.saveInProgress = false;
this.toastService.displayToastMessage(ToastSeverity.ERROR, 'Error saving advanced settings, please try again later');
});
}

private createMemoStructureWatcher(): void {
this.memoStructure = this.advancedSettingsForm.value.expenseMemoStructure;
Expand Down

0 comments on commit 98e00e0

Please sign in to comment.