-
Notifications
You must be signed in to change notification settings - Fork 0
fix:QBD direct advanced settings fix #1133
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
WalkthroughThe pull request introduces modifications to the Changes
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🔭 Outside diff range comments (2)
src/app/integrations/qbd-direct/qbd-direct-shared/qbd-direct-advanced-settings/qbd-direct-advanced-settings.component.ts (2)
Line range hint
132-141: Improve async operations handlingThe current implementation doesn't properly handle multiple async delete operations. Consider using Promise.all or forkJoin for better control:
private saveSkipExport(): void { if (!this.advancedSettingsForm.value.skipExport && this.expenseFilters.results.length > 0){ - this.expenseFilters.results.forEach((value) => { - this.deleteExpenseFilter(value.id); - }); + const deletePromises = this.expenseFilters.results.map((value) => + this.deleteExpenseFilter(value.id).toPromise() + ); + Promise.all(deletePromises).catch(error => { + this.toastService.displayToastMessage(ToastSeverity.ERROR, 'Error deleting expense filters'); + }); } if (this.advancedSettingsForm.value.skipExport) { this.saveSkipExportFields(); } }
Line range hint
164-169: Enhance error handling and operation orderingThe save method combines multiple operations but could benefit from better error handling and operation ordering:
- Consider using RxJS operators to handle the operation sequence:
save() { this.saveInProgress = true; - this.saveSkipExport(); - const advancedSettingPayload = QbdDirectAdvancedSettingsModel.constructPayload(this.advancedSettingsForm, this.adminEmails); - this.advancedSettingsService.postQbdAdvancedSettings(advancedSettingPayload).subscribe( + const advancedSettingPayload = QbdDirectAdvancedSettingsModel.constructPayload(this.advancedSettingsForm, this.adminEmails); + + // First save skip export settings, then save advanced settings + of(null).pipe( + tap(() => this.saveSkipExport()), + switchMap(() => this.advancedSettingsService.postQbdAdvancedSettings(advancedSettingPayload)), + catchError((error) => { + this.saveInProgress = false; + const errorMessage = error.status === 400 + ? 'Invalid advanced settings configuration' + : 'Error saving advanced settings, please try again later'; + this.toastService.displayToastMessage(ToastSeverity.ERROR, errorMessage); + return EMPTY; + }) + ).subscribe(
- Add specific error handling for different error scenarios (400, 401, 500, etc.)
- Consider adding retry logic for transient failures
🧹 Nitpick comments (1)
src/app/integrations/qbd-direct/qbd-direct-shared/qbd-direct-advanced-settings/qbd-direct-advanced-settings.component.ts (1)
117-118: Consider enhancing validation checksWhile the added validation for
field_nameandvalue1is good, consider implementing more comprehensive validation:
- Type checking for the values
- Validation for edge cases (empty strings, whitespace)
- Proper error feedback to the user when validation fails
- if (!valueField.condition1.field_name || !valueField.value1) { + if (!valueField.condition1?.field_name?.trim() || !valueField.value1?.toString()?.trim()) { + this.toastService.displayToastMessage(ToastSeverity.ERROR, 'Please fill in all required fields for skip export'); return; }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/app/integrations/qbd-direct/qbd-direct-shared/qbd-direct-advanced-settings/qbd-direct-advanced-settings.component.ts(1 hunks)
🔇 Additional comments (1)
src/app/integrations/qbd-direct/qbd-direct-shared/qbd-direct-advanced-settings/qbd-direct-advanced-settings.component.ts (1)
Line range hint 117-169: Verify edge cases and error scenarios
Please ensure the following scenarios are properly handled:
- Concurrent saves from multiple users
- Network timeouts during save operations
- Partial save failures (skip export succeeds but advanced settings fails)
- Form validation state after failed saves
|
Description
fix:QBD direct advanced settings fix
Clickup
htpps://app.clickup.com
Summary by CodeRabbit
New Features
Bug Fixes