Skip to content

feat: resume QWC setup#1766

Open
JustARatherRidiculouslyLongUsername wants to merge 1 commit intoqwc-regen-existing-pathfrom
qwc-regen-handle-redirection
Open

feat: resume QWC setup#1766
JustARatherRidiculouslyLongUsername wants to merge 1 commit intoqwc-regen-existing-pathfrom
qwc-regen-handle-redirection

Conversation

@JustARatherRidiculouslyLongUsername
Copy link
Contributor

@JustARatherRidiculouslyLongUsername JustARatherRidiculouslyLongUsername commented Feb 26, 2026

Description

If the user leaves mid-setup, redirect them back to the same step once they return.

  • we check onboarding state and load the appropriate section to resume where the flow was left off
  • however, the same onboarding states are used mid-onboarding also
  • check if advanced settings exists to decide whether to redirect to onboarding to qwc regen

Clickup

https://app.clickup.com/t/86d1xnfta
https://app.clickup.com/t/86d1xnftt

Summary by CodeRabbit

  • New Features

    • Users can now resume QWC file regeneration from their last visited step in the workflow
  • Improvements

    • Enhanced visibility with improved loading state indicators during regeneration
    • Refined navigation routing for QWC file setup and connection processes
    • Streamlined UI with spacing improvements in setup connection area

If the user leaves mid-setup, redirect them back to the same step once they return.
- we check onboarding state and load the appropriate section to resume where the flow was left off
- however, the same onboarding states are used mid-onboarding also
- check if advanced settings exists to decide whether to redirect to onboarding to qwc regen
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 26, 2026

Walkthrough

This pull request introduces a QWC flow state persistence mechanism enabling users to resume from their last visited regeneration step. It adds a new QwcRouteState type and QbdDirectQwcLastVisitedFlowService for storing and retrieving flow state, then integrates these into the regenerate and main QBD Direct components to support resume navigation paths and refactored template logic.

Changes

Cohort / File(s) Summary
QWC Route State Type
src/app/core/models/qbd-direct/qbd-direct-configuration/qbd-direct-qwc-file.model.ts
Added QwcRouteState type with goToPrerequisites boolean property for route state management.
Last Visited Flow Service
src/app/core/services/qbd-direct/qbd-direct-core/qbd-direct-qwc-last-visited-flow.service.ts
New injectable service providing get() and set() methods to persist and retrieve the last visited QWC regeneration flow via StorageService.
QWC File Components
src/app/integrations/qbd-direct/qbd-direct-shared/qbd-direct-qwc-file/qbd-direct-qwc-file-landing/qbd-direct-qwc-file-landing.component.ts, src/app/integrations/qbd-direct/qbd-direct-shared/qbd-direct-qwc-file/qbd-direct-regenerate-qwc-file/qbd-direct-regenerate-qwc-file.component.ts
Inject QbdDirectQwcLastVisitedFlowService, track flow state after key actions, add resume logic via history state and last visited flow retrieval, extract polling into separate method, and update handleStatus to return Observable for composition.
Regenerate QWC Template
src/app/integrations/qbd-direct/qbd-direct-shared/qbd-direct-qwc-file/qbd-direct-regenerate-qwc-file/qbd-direct-regenerate-qwc-file.component.html
Restructured conditional rendering to gate on isLoading at top level, refactored event bindings for NEW flow type, and moved showStepNumber and ctaText bindings to setup-connection phase.
Setup Connection Template
src/app/integrations/qbd-direct/qbd-direct-shared/qbd-direct-setup-connection/qbd-direct-setup-connection.component.html
Removed wrapper div around configuration info label for cleaner DOM structure.
Main QBD Direct Component
src/app/integrations/qbd-direct/qbd-direct.component.ts
Added pre-check for onboarding-related states, fetches advanced settings and retrieves last visited QWC flow to route to appropriate qwc_file path, injects QbdDirectAdvancedSettingsService and QbdDirectQwcLastVisitedFlowService, and refactors onboarding path routing to use partial mapping.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 A rabbit bounds through flows once lost,
Remembers steps, no journey crossed!
State persists when hearts may roam—
Resume your quest and find your home.
✨ No more wandering all alone!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title 'feat: resume QWC setup' clearly summarizes the main objective of the PR - implementing the ability to resume QWC setup when users return mid-flow.
Description check ✅ Passed The description addresses the template sections and provides clear context: it explains the feature (resuming QWC setup), the implementation approach (checking onboarding state and advanced settings), and includes relevant ClickUp task links.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch qwc-regen-handle-redirection

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 4

🧹 Nitpick comments (1)
src/app/core/services/qbd-direct/qbd-direct-core/qbd-direct-qwc-last-visited-flow.service.ts (1)

14-20: Consider adding a clear() method for cleanup.

When the QWC regeneration flow completes successfully, you may want to clear the stored last-visited flow to avoid stale state on subsequent regeneration attempts.

♻️ Suggested addition
  set(flow: QwcRegenerationFlowType): void {
    this.storageService.set('qwc-last-visited-flow', flow);
  }
+
+  clear(): void {
+    this.storageService.remove('qwc-last-visited-flow');
+  }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@src/app/core/services/qbd-direct/qbd-direct-core/qbd-direct-qwc-last-visited-flow.service.ts`
around lines 14 - 20, The service currently exposes get() and set(flow:
QwcRegenerationFlowType) but lacks a clear() method to remove stale state; add a
public clear(): void method on the same service (the class containing get and
set) that calls this.storageService.remove('qwc-last-visited-flow') (or the
appropriate delete/remove API on storageService) and use clear() after a
successful QWC regeneration to avoid persisting the last-visited flow.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In
`@src/app/integrations/qbd-direct/qbd-direct-shared/qbd-direct-qwc-file/qbd-direct-regenerate-qwc-file/qbd-direct-regenerate-qwc-file.component.ts`:
- Around line 327-333: The workspace fetch in ngOnInit sets this.isLoading =
true and calls this.workspaceService.getWorkspace(user.org_id).subscribe(...)
but has no error handling, so if the API fails isLoading stays true; update the
call to handle errors by adding an error path (either a second subscribe
callback or pipe + catchError) on workspaceService.getWorkspace(user.org_id) to
set this.isLoading = false, surface an appropriate user-facing message or toast,
and avoid calling this.navigate when the fetch fails; reference the symbols
this.isLoading, storageService.get('user'), workspaceService.getWorkspace, and
this.navigate to locate and update the code.
- Around line 317-322: Destructuring goToPrerequisites from history.state with a
direct `as QwcRouteState` can be misleading and risky if history.state is
null/undefined; update the logic to defensively read history.state (e.g., guard
or default to an empty object) before extracting goToPrerequisites, remove the
unsafe assertion, and then keep the existing check that calls
this.state.set(QwcFlowState.PREREQUISITES) when goToPrerequisites is truthy so
the code safely handles direct navigation or refresh cases.

In `@src/app/integrations/qbd-direct/qbd-direct.component.ts`:
- Around line 83-96: The onboardingStateComponentMap lookup can return undefined
for this.workspace.onboarding_state and then pass that to
this.router.navigateByUrl; add a defensive guard or fallback before calling
navigateByUrl: compute the target via
onboardingStateComponentMap[this.workspace.onboarding_state], verify it is a
non-empty string (or select a default route like
'/integrations/qbd_direct/onboarding/landing' or
'/integrations/qbd_direct/main'), and only call
this.router.navigateByUrl(target) when target is valid (otherwise handle the
unexpected state via a log/warning and navigate to the safe default).
- Around line 66-79: The error handler for
qbdDirectAdvancedSettingsService.getQbdAdvancedSettings().subscribe is treating
every failure as a 404; change the error callback to inspect the error status
(e.g., HttpErrorResponse.status) and only navigate to
'/integrations/qbd_direct/onboarding/connector' when status === 404, otherwise
handle non-404 errors separately (log or surface a user error state) and ensure
isLoading is set to false in all cases; keep references to
qbdDirectAdvancedSettingsService.getQbdAdvancedSettings(),
qbdDirectQwcLastVisitedFlowService.get(), router.navigateByUrl(...) and
isLoading when implementing the change.

---

Nitpick comments:
In
`@src/app/core/services/qbd-direct/qbd-direct-core/qbd-direct-qwc-last-visited-flow.service.ts`:
- Around line 14-20: The service currently exposes get() and set(flow:
QwcRegenerationFlowType) but lacks a clear() method to remove stale state; add a
public clear(): void method on the same service (the class containing get and
set) that calls this.storageService.remove('qwc-last-visited-flow') (or the
appropriate delete/remove API on storageService) and use clear() after a
successful QWC regeneration to avoid persisting the last-visited flow.

ℹ️ Review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 61c357e and ab9f385.

📒 Files selected for processing (7)
  • src/app/core/models/qbd-direct/qbd-direct-configuration/qbd-direct-qwc-file.model.ts
  • src/app/core/services/qbd-direct/qbd-direct-core/qbd-direct-qwc-last-visited-flow.service.ts
  • src/app/integrations/qbd-direct/qbd-direct-shared/qbd-direct-qwc-file/qbd-direct-qwc-file-landing/qbd-direct-qwc-file-landing.component.ts
  • src/app/integrations/qbd-direct/qbd-direct-shared/qbd-direct-qwc-file/qbd-direct-regenerate-qwc-file/qbd-direct-regenerate-qwc-file.component.html
  • src/app/integrations/qbd-direct/qbd-direct-shared/qbd-direct-qwc-file/qbd-direct-regenerate-qwc-file/qbd-direct-regenerate-qwc-file.component.ts
  • src/app/integrations/qbd-direct/qbd-direct-shared/qbd-direct-setup-connection/qbd-direct-setup-connection.component.html
  • src/app/integrations/qbd-direct/qbd-direct.component.ts

Comment on lines +317 to +322

const { goToPrerequisites } = history.state as QwcRouteState;
if (goToPrerequisites) {
this.state.set(QwcFlowState.PREREQUISITES);
return;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Potential runtime error when history.state is null or undefined.

Destructuring goToPrerequisites from history.state assumes the state object exists. If the user navigates directly to this route (e.g., via URL or refresh), history.state may be null or an empty object, causing goToPrerequisites to be undefined.

The current logic handles undefined correctly (falsy check), but the type assertion as QwcRouteState is misleading. Consider adding a null check for clarity.

🛡️ Proposed defensive handling
-    const { goToPrerequisites } = history.state as QwcRouteState;
-    if (goToPrerequisites) {
+    const routeState = history.state as QwcRouteState | null;
+    if (routeState?.goToPrerequisites) {
       this.state.set(QwcFlowState.PREREQUISITES);
       return;
     }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const { goToPrerequisites } = history.state as QwcRouteState;
if (goToPrerequisites) {
this.state.set(QwcFlowState.PREREQUISITES);
return;
}
const routeState = history.state as QwcRouteState | null;
if (routeState?.goToPrerequisites) {
this.state.set(QwcFlowState.PREREQUISITES);
return;
}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@src/app/integrations/qbd-direct/qbd-direct-shared/qbd-direct-qwc-file/qbd-direct-regenerate-qwc-file/qbd-direct-regenerate-qwc-file.component.ts`
around lines 317 - 322, Destructuring goToPrerequisites from history.state with
a direct `as QwcRouteState` can be misleading and risky if history.state is
null/undefined; update the logic to defensively read history.state (e.g., guard
or default to an empty object) before extracting goToPrerequisites, remove the
unsafe assertion, and then keep the existing check that calls
this.state.set(QwcFlowState.PREREQUISITES) when goToPrerequisites is truthy so
the code safely handles direct navigation or refresh cases.

Comment on lines +327 to +333
this.isLoading = true;
const user: MinimalUser = this.storageService.get('user');
this.workspaceService.getWorkspace(user.org_id).subscribe((workspaces: QbdDirectWorkspace[]) => {
this.navigate(workspaces[0].onboarding_state).subscribe(() => {
this.isLoading = false;
});
});
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Missing error handling for workspace fetch during resume flow.

The getWorkspace call in ngOnInit does not handle errors. If the API fails, isLoading will remain true indefinitely, leaving the user stuck on the loading screen.

🛡️ Proposed error handling
     this.isLoading = true;
     const user: MinimalUser = this.storageService.get('user');
     this.workspaceService.getWorkspace(user.org_id).subscribe((workspaces: QbdDirectWorkspace[]) => {
       this.navigate(workspaces[0].onboarding_state).subscribe(() => {
         this.isLoading = false;
       });
+    }, (error) => {
+      console.error('Error fetching workspace:', error);
+      this.toastService.displayToastMessage(ToastSeverity.ERROR, this.translocoService.translate('qbdDirectRegenerateQwcFile.somethingWentWrong'));
+      this.isLoading = false;
     });
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
this.isLoading = true;
const user: MinimalUser = this.storageService.get('user');
this.workspaceService.getWorkspace(user.org_id).subscribe((workspaces: QbdDirectWorkspace[]) => {
this.navigate(workspaces[0].onboarding_state).subscribe(() => {
this.isLoading = false;
});
});
this.isLoading = true;
const user: MinimalUser = this.storageService.get('user');
this.workspaceService.getWorkspace(user.org_id).subscribe((workspaces: QbdDirectWorkspace[]) => {
this.navigate(workspaces[0].onboarding_state).subscribe(() => {
this.isLoading = false;
});
}, (error) => {
console.error('Error fetching workspace:', error);
this.toastService.displayToastMessage(ToastSeverity.ERROR, this.translocoService.translate('qbdDirectRegenerateQwcFile.somethingWentWrong'));
this.isLoading = false;
});
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@src/app/integrations/qbd-direct/qbd-direct-shared/qbd-direct-qwc-file/qbd-direct-regenerate-qwc-file/qbd-direct-regenerate-qwc-file.component.ts`
around lines 327 - 333, The workspace fetch in ngOnInit sets this.isLoading =
true and calls this.workspaceService.getWorkspace(user.org_id).subscribe(...)
but has no error handling, so if the API fails isLoading stays true; update the
call to handle errors by adding an error path (either a second subscribe
callback or pipe + catchError) on workspaceService.getWorkspace(user.org_id) to
set this.isLoading = false, surface an appropriate user-facing message or toast,
and avoid calling this.navigate when the fetch fails; reference the symbols
this.isLoading, storageService.get('user'), workspaceService.getWorkspace, and
this.navigate to locate and update the code.

Comment on lines +66 to +79
this.qbdDirectAdvancedSettingsService.getQbdAdvancedSettings().subscribe({
next: () => {
// 200: advanced settings exists - we are regenerating the QWC file
const lastVisitedFlow = this.qbdDirectQwcLastVisitedFlowService.get();
const flowRoute = lastVisitedFlow === QwcRegenerationFlowType.EXISTING ? 'existing' : 'new';
this.router.navigateByUrl(`/integrations/qbd_direct/main/configuration/qwc_file/${flowRoute}`);
this.isLoading = false;
},
error: () => {
// 404: advanced settings does not exist - we are onboarding
this.router.navigateByUrl('/integrations/qbd_direct/onboarding/connector');
this.isLoading = false;
}
});
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Error handling assumes all errors indicate missing advanced settings.

The error callback treats any error as a 404 (advanced settings not found), but network errors, server errors, or other issues would also redirect to onboarding. Consider checking the error status code explicitly.

🛡️ Proposed fix to check error status
        error: () => {
-          // 404: advanced settings does not exist - we are onboarding
-          this.router.navigateByUrl('/integrations/qbd_direct/onboarding/connector');
-          this.isLoading = false;
+          error: (error) => {
+            if (error?.status === 404) {
+              // 404: advanced settings does not exist - we are onboarding
+              this.router.navigateByUrl('/integrations/qbd_direct/onboarding/connector');
+            } else {
+              // Unexpected error - fallback to onboarding but log the issue
+              console.error('Error fetching advanced settings:', error);
+              this.router.navigateByUrl('/integrations/qbd_direct/onboarding/connector');
+            }
+            this.isLoading = false;
+          }
        }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
this.qbdDirectAdvancedSettingsService.getQbdAdvancedSettings().subscribe({
next: () => {
// 200: advanced settings exists - we are regenerating the QWC file
const lastVisitedFlow = this.qbdDirectQwcLastVisitedFlowService.get();
const flowRoute = lastVisitedFlow === QwcRegenerationFlowType.EXISTING ? 'existing' : 'new';
this.router.navigateByUrl(`/integrations/qbd_direct/main/configuration/qwc_file/${flowRoute}`);
this.isLoading = false;
},
error: () => {
// 404: advanced settings does not exist - we are onboarding
this.router.navigateByUrl('/integrations/qbd_direct/onboarding/connector');
this.isLoading = false;
}
});
this.qbdDirectAdvancedSettingsService.getQbdAdvancedSettings().subscribe({
next: () => {
// 200: advanced settings exists - we are regenerating the QWC file
const lastVisitedFlow = this.qbdDirectQwcLastVisitedFlowService.get();
const flowRoute = lastVisitedFlow === QwcRegenerationFlowType.EXISTING ? 'existing' : 'new';
this.router.navigateByUrl(`/integrations/qbd_direct/main/configuration/qwc_file/${flowRoute}`);
this.isLoading = false;
},
error: (error) => {
if (error?.status === 404) {
// 404: advanced settings does not exist - we are onboarding
this.router.navigateByUrl('/integrations/qbd_direct/onboarding/connector');
} else {
// Unexpected error - fallback to onboarding but log the issue
console.error('Error fetching advanced settings:', error);
this.router.navigateByUrl('/integrations/qbd_direct/onboarding/connector');
}
this.isLoading = false;
}
});
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/app/integrations/qbd-direct/qbd-direct.component.ts` around lines 66 -
79, The error handler for
qbdDirectAdvancedSettingsService.getQbdAdvancedSettings().subscribe is treating
every failure as a 404; change the error callback to inspect the error status
(e.g., HttpErrorResponse.status) and only navigate to
'/integrations/qbd_direct/onboarding/connector' when status === 404, otherwise
handle non-404 errors separately (log or surface a user error state) and ensure
isLoading is set to false in all cases; keep references to
qbdDirectAdvancedSettingsService.getQbdAdvancedSettings(),
qbdDirectQwcLastVisitedFlowService.get(), router.navigateByUrl(...) and
isLoading when implementing the change.

Comment on lines 83 to 96
if (pathName === '/integrations/qbd_direct') {
const onboardingStateComponentMap: Record<QbdDirectOnboardingState, string> = {
const onboardingStateComponentMap: Partial<Record<QbdDirectOnboardingState, string>> = {
[QbdDirectOnboardingState.YET_TO_START]: '/integrations/qbd_direct/onboarding/landing',
[QbdDirectOnboardingState.CONFIRM_PRE_REQUISITES]: '/integrations/qbd_direct/onboarding/pre_requisite',
[QbdDirectOnboardingState.CONNECTION]: '/integrations/qbd_direct/onboarding/connector',
[QbdDirectOnboardingState.PENDING_QWC_UPLOAD]: '/integrations/qbd_direct/onboarding/connector',
[QbdDirectOnboardingState.INCORRECT_COMPANY_PATH]: '/integrations/qbd_direct/onboarding/connector',
[QbdDirectOnboardingState.INCORRECT_PASSWORD]: '/integrations/qbd_direct/onboarding/connector',
[QbdDirectOnboardingState.DESTINATION_SYNC_IN_PROGRESS]: '/integrations/qbd_direct/onboarding/connector',
[QbdDirectOnboardingState.DESTINATION_SYNC_COMPLETE]: '/integrations/qbd_direct/onboarding/connector',
[QbdDirectOnboardingState.EXPORT_SETTINGS]: '/integrations/qbd_direct/onboarding/export_settings',
[QbdDirectOnboardingState.IMPORT_SETTINGS]: '/integrations/qbd_direct/onboarding/import_settings',
[QbdDirectOnboardingState.ADVANCED_SETTINGS]: '/integrations/qbd_direct/onboarding/advanced_settings',
[QbdDirectOnboardingState.COMPANY_NAME_MISMATCH]: '/integrations/qbd_direct/main',
[QbdDirectOnboardingState.COMPLETE]: '/integrations/qbd_direct/main'
};
this.router.navigateByUrl(onboardingStateComponentMap[this.workspace.onboarding_state]);
this.router.navigateByUrl(
onboardingStateComponentMap[this.workspace.onboarding_state] as string
);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Potential undefined route when state is not in the map.

The onboardingStateComponentMap is now a Partial<Record>, so if this.workspace.onboarding_state is not in the map (e.g., one of the connection states that should have been handled earlier), the cast as string will result in undefined as string, causing navigateByUrl to receive undefined.

While the early return at line 80 should prevent this, consider adding a fallback or guard for robustness.

🛡️ Proposed defensive check
-      this.router.navigateByUrl(
-        onboardingStateComponentMap[this.workspace.onboarding_state] as string
-      );
+      const route = onboardingStateComponentMap[this.workspace.onboarding_state];
+      if (route) {
+        this.router.navigateByUrl(route);
+      } else {
+        console.warn('Unexpected onboarding state:', this.workspace.onboarding_state);
+        this.router.navigateByUrl('/integrations/qbd_direct/onboarding/landing');
+      }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if (pathName === '/integrations/qbd_direct') {
const onboardingStateComponentMap: Record<QbdDirectOnboardingState, string> = {
const onboardingStateComponentMap: Partial<Record<QbdDirectOnboardingState, string>> = {
[QbdDirectOnboardingState.YET_TO_START]: '/integrations/qbd_direct/onboarding/landing',
[QbdDirectOnboardingState.CONFIRM_PRE_REQUISITES]: '/integrations/qbd_direct/onboarding/pre_requisite',
[QbdDirectOnboardingState.CONNECTION]: '/integrations/qbd_direct/onboarding/connector',
[QbdDirectOnboardingState.PENDING_QWC_UPLOAD]: '/integrations/qbd_direct/onboarding/connector',
[QbdDirectOnboardingState.INCORRECT_COMPANY_PATH]: '/integrations/qbd_direct/onboarding/connector',
[QbdDirectOnboardingState.INCORRECT_PASSWORD]: '/integrations/qbd_direct/onboarding/connector',
[QbdDirectOnboardingState.DESTINATION_SYNC_IN_PROGRESS]: '/integrations/qbd_direct/onboarding/connector',
[QbdDirectOnboardingState.DESTINATION_SYNC_COMPLETE]: '/integrations/qbd_direct/onboarding/connector',
[QbdDirectOnboardingState.EXPORT_SETTINGS]: '/integrations/qbd_direct/onboarding/export_settings',
[QbdDirectOnboardingState.IMPORT_SETTINGS]: '/integrations/qbd_direct/onboarding/import_settings',
[QbdDirectOnboardingState.ADVANCED_SETTINGS]: '/integrations/qbd_direct/onboarding/advanced_settings',
[QbdDirectOnboardingState.COMPANY_NAME_MISMATCH]: '/integrations/qbd_direct/main',
[QbdDirectOnboardingState.COMPLETE]: '/integrations/qbd_direct/main'
};
this.router.navigateByUrl(onboardingStateComponentMap[this.workspace.onboarding_state]);
this.router.navigateByUrl(
onboardingStateComponentMap[this.workspace.onboarding_state] as string
);
}
if (pathName === '/integrations/qbd_direct') {
const onboardingStateComponentMap: Partial<Record<QbdDirectOnboardingState, string>> = {
[QbdDirectOnboardingState.YET_TO_START]: '/integrations/qbd_direct/onboarding/landing',
[QbdDirectOnboardingState.CONFIRM_PRE_REQUISITES]: '/integrations/qbd_direct/onboarding/pre_requisite',
[QbdDirectOnboardingState.CONNECTION]: '/integrations/qbd_direct/onboarding/connector',
[QbdDirectOnboardingState.EXPORT_SETTINGS]: '/integrations/qbd_direct/onboarding/export_settings',
[QbdDirectOnboardingState.IMPORT_SETTINGS]: '/integrations/qbd_direct/onboarding/import_settings',
[QbdDirectOnboardingState.ADVANCED_SETTINGS]: '/integrations/qbd_direct/onboarding/advanced_settings',
[QbdDirectOnboardingState.COMPLETE]: '/integrations/qbd_direct/main'
};
const route = onboardingStateComponentMap[this.workspace.onboarding_state];
if (route) {
this.router.navigateByUrl(route);
} else {
console.warn('Unexpected onboarding state:', this.workspace.onboarding_state);
this.router.navigateByUrl('/integrations/qbd_direct/onboarding/landing');
}
}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/app/integrations/qbd-direct/qbd-direct.component.ts` around lines 83 -
96, The onboardingStateComponentMap lookup can return undefined for
this.workspace.onboarding_state and then pass that to this.router.navigateByUrl;
add a defensive guard or fallback before calling navigateByUrl: compute the
target via onboardingStateComponentMap[this.workspace.onboarding_state], verify
it is a non-empty string (or select a default route like
'/integrations/qbd_direct/onboarding/landing' or
'/integrations/qbd_direct/main'), and only call
this.router.navigateByUrl(target) when target is valid (otherwise handle the
unexpected state via a log/warning and navigate to the safe default).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/L Large PR

Development

Successfully merging this pull request may close these issues.

1 participant