-
Notifications
You must be signed in to change notification settings - Fork 0
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
fixes: qbd direct prod fix #1128
Conversation
WalkthroughThis pull request introduces consistent whitespace handling for chart of accounts across multiple components in the QuickBooks Direct integration. The changes primarily focus on transforming chart of accounts arrays by removing whitespace from each account name. This modification is applied in several components including the dashboard, base mapping, onboarding connector, and error section components. The changes aim to standardize account name formatting and ensure clean data processing. Changes
Suggested labels
Possibly related PRs
Poem
Tip CodeRabbit's docstrings feature is now available as part of our Early Access Program! Simply use the command Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 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 (
|
PR title must start with "fix:", "feat:", "chore:", "refactor", or "test:" (case-insensitive) |
1 similar comment
PR title must start with "fix:", "feat:", "chore:", "refactor", or "test:" (case-insensitive) |
|
PR title must start with "fix:", "feat:", "chore:", "refactor", or "test:" (case-insensitive) |
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: 2
🧹 Nitpick comments (2)
src/app/integrations/qbd-direct/qbd-direct-main/qbd-direct-mapping/qbd-direct-base-mapping/qbd-direct-base-mapping.component.ts (1)
110-110
: Consider extracting the whitespace removal logic to a utility function.The whitespace removal logic is consistent with other components, improving the handling of account names. However, since this transformation is used across multiple components, consider extracting it to a shared utility function.
Example implementation:
// Add to a shared utility file (e.g., src/app/core/utils/string-utils.ts) +export const removeWhitespace = (str: string): string => str.replace(/\s+/g, ''); // Update the current implementation -this.chartOfAccounts = responses[1].import_settings.import_account_as_category ? responses[1].import_settings.chart_of_accounts.map((item: string) => item.replace(/\s+/g, '')) : QbdDirectImportSettingModel.getChartOfAccountTypesList().map((item: string) => item.replace(/\s+/g, '')); +this.chartOfAccounts = responses[1].import_settings.import_account_as_category ? responses[1].import_settings.chart_of_accounts.map(removeWhitespace) : QbdDirectImportSettingModel.getChartOfAccountTypesList().map(removeWhitespace);src/app/shared/components/dashboard/dashboard-error-section/dashboard-error-section.component.ts (1)
129-129
: Add null check and use shared utility for whitespace removal.While the whitespace removal logic is consistent with other components, consider:
- Adding null/undefined checks since this is in the error handling path.
- Using the shared utility function as suggested in previous comments.
Example implementation:
-this.detailAccountType = this.chartOfAccounts.map((item: string) => item.replace(/\s+/g, '')); +this.detailAccountType = this.chartOfAccounts?.map(removeWhitespace) ?? [];
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
src/app/integrations/qbd-direct/qbd-direct-main/qbd-direct-dashboard/qbd-direct-dashboard.component.ts
(1 hunks)src/app/integrations/qbd-direct/qbd-direct-main/qbd-direct-mapping/qbd-direct-base-mapping/qbd-direct-base-mapping.component.ts
(1 hunks)src/app/integrations/qbd-direct/qbd-direct-onboarding/qbd-direct-onboarding-connector/qbd-direct-onboarding-connector.component.ts
(2 hunks)src/app/shared/components/dashboard/dashboard-error-section/dashboard-error-section.component.ts
(1 hunks)
🔇 Additional comments (3)
src/app/integrations/qbd-direct/qbd-direct-main/qbd-direct-dashboard/qbd-direct-dashboard.component.ts (1)
155-155
: Duplicate whitespace removal logic found.
The whitespace removal logic is identical to the one in QbdDirectBaseMappingComponent
. This reinforces the need to extract this logic into a shared utility function as suggested in the previous comment.
src/app/integrations/qbd-direct/qbd-direct-onboarding/qbd-direct-onboarding-connector/qbd-direct-onboarding-connector.component.ts (2)
57-57
: Verify the impact of uninitialized validation flag
The isCompanyPathInvalid
property is now uninitialized instead of being set to true
. This change could affect the initial UI state and validation behavior. Please verify:
- The initial form validation state is correct
- Error messages display appropriately
- The UI elements dependent on this flag behave as expected
✅ Verification successful
Let me gather more context about how this property is used in the component's logic.
Let me try a different approach to search for the usage of this property.
Based on the search results, I can now provide a final response:
Uninitialized validation flag is safe to use
The uninitialized isCompanyPathInvalid
property is properly managed within the component's logic:
- It's explicitly set to
false
when a valid file path is provided intriggerDownload()
- It's set to
true
when an invalid/empty file path is provided - It's reset to
true
when handling errors - The template uses this flag correctly for validation states
The removal of the initial true
value is safe as the property is properly initialized in all code paths before being used.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Search for template usage of isCompanyPathInvalid to understand UI impact
rg -A 3 "isCompanyPathInvalid" --type html
Length of output: 2378
Script:
#!/bin/bash
# Search for usage of isCompanyPathInvalid in the component
ast-grep --pattern 'isCompanyPathInvalid' src/app/integrations/qbd-direct/qbd-direct-onboarding/qbd-direct-onboarding-connector/qbd-direct-onboarding-connector.component.ts
# Also check the initialization in constructor and lifecycle hooks
ast-grep --pattern 'constructor($$$) {
$$$
}' src/app/integrations/qbd-direct/qbd-direct-onboarding/qbd-direct-onboarding-connector/qbd-direct-onboarding-connector.component.ts
ast-grep --pattern 'ngOnInit() {
$$$
}' src/app/integrations/qbd-direct/qbd-direct-onboarding/qbd-direct-onboarding-connector/qbd-direct-onboarding-connector.component.ts
Length of output: 528
Script:
#!/bin/bash
# Search for all occurrences of isCompanyPathInvalid in the component file with context
rg -A 3 -B 3 "isCompanyPathInvalid" src/app/integrations/qbd-direct/qbd-direct-onboarding/qbd-direct-onboarding-connector/qbd-direct-onboarding-connector.component.ts
# Also get the content of the triggerDownload method where this property is likely used
ast-grep --pattern 'triggerDownload($_) {
$$$
}' src/app/integrations/qbd-direct/qbd-direct-onboarding/qbd-direct-onboarding-connector/qbd-direct-onboarding-connector.component.ts
Length of output: 1210
Line range hint 1-1
: Verify alignment with PR objectives
The changes in this file focus on QBD connection setup and don't appear related to the whitespace handling mentioned in the PR summary. Please clarify:
- Is this an additional fix separate from the whitespace handling?
- Are there missing changes related to whitespace handling?
this.password = connectionResponse.password; | ||
this.xmlFileContent = connectionResponse.qwc; |
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.
Security: Avoid storing sensitive data in component properties
Storing the password and XML content in component properties could expose sensitive data. Consider:
- Using a secure credential manager service
- Clearing sensitive data after use
Suggested approach:
// Create a secure service to handle credentials
@Injectable({providedIn: 'root'})
export class QbdCredentialService {
private password: string;
setPassword(pwd: string): void {
this.password = pwd;
}
getPassword(): string {
const pwd = this.password;
this.password = undefined; // Clear after use
return pwd;
}
}
this.qbdDirectConnectorService.postQbdDirectConntion({file_location: filePath}).subscribe((connectionResponse: QbdConnectorGet) => { | ||
this.password = connectionResponse.password; | ||
this.xmlFileContent = connectionResponse.qwc; | ||
this.triggerManualDownload(); | ||
this.showDownloadLink = true; | ||
this.password = connectionResponse.password; | ||
this.xmlFileContent = connectionResponse.qwc; | ||
this.showDownloadLink = true; | ||
this.isDownloadfileLoading = false; | ||
this.triggerManualDownload(); | ||
}); |
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.
Add error handling to prevent stuck loading states
The subscription lacks error handling which could leave isDownloadfileLoading
stuck as true if the request fails.
Add error handling:
this.qbdDirectConnectorService.postQbdDirectConntion({file_location: filePath}).subscribe((connectionResponse: QbdConnectorGet) => {
this.password = connectionResponse.password;
this.xmlFileContent = connectionResponse.qwc;
this.showDownloadLink = true;
this.isDownloadfileLoading = false;
this.triggerManualDownload();
+}, error => {
+ this.isDownloadfileLoading = false;
+ this.toastService.displayToastMessage(ToastSeverity.ERROR, 'Failed to setup QBD connection');
});
Committable suggestion skipped: line range outside the PR's diff.
Description
fixes: qbd direct prod fix
Clickup
https://app.clickup.com/
Summary by CodeRabbit