Skip to content
Closed
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
47 changes: 18 additions & 29 deletions app/client/src/ce/utils/signupHelpers.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
import {
firstTimeUserOnboardingInit,
setCurrentApplicationIdForCreateNewApp,
} from "actions/onboardingActions";
import { setCurrentApplicationIdForCreateNewApp } from "actions/onboardingActions";
import {
SIGNUP_SUCCESS_URL,
BUILDER_PATH,
Expand All @@ -19,18 +16,21 @@ import type {
SocialLoginType,
} from "ee/constants/SocialLogin";
import { SocialLoginButtonPropsList } from "ee/constants/SocialLogin";
import type { Dispatch } from "redux";

export interface RedirectUserAfterSignupProps {
redirectUrl: string;
shouldEnableFirstTimeUserOnboarding: string | null;
validLicense?: boolean;
dispatch: Dispatch;
isAiAgentFlowEnabled: boolean;
}

export const redirectUserAfterSignup = (
redirectUrl: string,
shouldEnableFirstTimeUserOnboarding: string | null,
_validLicense?: boolean,
// TODO: Fix this the next time the file is edited
// eslint-disable-next-line @typescript-eslint/no-explicit-any
dispatch?: any,
isEnabledForCreateNew?: boolean, // is Enabled for only non-invited users
// TODO: Fix this the next time the file is edited
// eslint-disable-next-line @typescript-eslint/no-explicit-any
): any => {
props: RedirectUserAfterSignupProps,
) => {
const { dispatch, redirectUrl, shouldEnableFirstTimeUserOnboarding } = props;

Comment on lines 29 to +33

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

Updated function signature to use interface

The function now accepts a single object parameter with a defined interface. However, isAiAgentFlowEnabled is defined in the interface but not used in the function body.


🏁 Script executed:

#!/bin/bash
# Check if isAiAgentFlowEnabled is being used elsewhere in the codebase

echo "Searching for isAiAgentFlowEnabled usage..."
rg "isAiAgentFlowEnabled" --type ts

Length of output: 1301


Action Required: Address the Unused Parameter in Signup Helpers

In the updated function signature for redirectUserAfterSignup, the interface now includes the isAiAgentFlowEnabled property. However, this property isn’t being utilized within the function body. Please either remove isAiAgentFlowEnabled from the RedirectUserAfterSignupProps interface if it isn’t needed in this context, or update the function logic to incorporate it appropriately if it's intended to affect the redirection behavior.

  • File: app/client/src/ce/utils/signupHelpers.ts (Lines 29-33)
  • Suggestion: Remove the unused parameter from the interface or integrate it into the function's logic.

if (redirectUrl) {
try {
if (
Expand Down Expand Up @@ -65,21 +65,10 @@ export const redirectUserAfterSignup = (
* passing baseApplicationId as applicationId should be fine
* **/
if (baseApplicationId || basePageId) {
if (isEnabledForCreateNew) {
dispatch(
setCurrentApplicationIdForCreateNewApp(
baseApplicationId as string,
),
);
history.replace(APPLICATIONS_URL);
} else {
dispatch(
firstTimeUserOnboardingInit(
baseApplicationId,
basePageId as string,
),
);
}
dispatch(
setCurrentApplicationIdForCreateNewApp(baseApplicationId as string),
);
history.replace(APPLICATIONS_URL);
} else {
if (!urlObject) {
try {
Expand Down
9 changes: 5 additions & 4 deletions app/client/src/pages/setup/SignupSuccess.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { isValidLicense } from "ee/selectors/organizationSelectors";
import { redirectUserAfterSignup } from "ee/utils/signupHelpers";
import { setUserSignedUpFlag } from "utils/storage";
import AnalyticsUtil from "ee/utils/AnalyticsUtil";
import { getIsAiAgentFlowEnabled } from "ee/selectors/aiAgentSelectors";

export function SignupSuccess() {
const dispatch = useDispatch();
Expand All @@ -27,17 +28,17 @@ export function SignupSuccess() {
user?.email && setUserSignedUpFlag(user?.email);
}, []);

const isNonInvitedUser = shouldEnableFirstTimeUserOnboarding === "true";
const isAiAgentFlowEnabled = useSelector(getIsAiAgentFlowEnabled);

const redirectUsingQueryParam = useCallback(
() =>
redirectUserAfterSignup(
redirectUserAfterSignup({
redirectUrl,
shouldEnableFirstTimeUserOnboarding,
validLicense,
dispatch,
isNonInvitedUser,
),
isAiAgentFlowEnabled,
}),
Comment on lines +35 to +41

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Updated function call to use object parameter

The function call has been updated to use an object parameter which improves maintainability. However, the dependency array is empty which could lead to stale values if the dependencies change.

Consider adding the dependencies to the array:

  const redirectUsingQueryParam = useCallback(
    () =>
      redirectUserAfterSignup({
        redirectUrl,
        shouldEnableFirstTimeUserOnboarding,
        validLicense,
        dispatch,
        isAiAgentFlowEnabled,
      }),
-    [],
+    [redirectUrl, shouldEnableFirstTimeUserOnboarding, validLicense, dispatch, isAiAgentFlowEnabled],
  );
📝 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
redirectUserAfterSignup({
redirectUrl,
shouldEnableFirstTimeUserOnboarding,
validLicense,
dispatch,
isNonInvitedUser,
),
isAiAgentFlowEnabled,
}),
const redirectUsingQueryParam = useCallback(
() =>
redirectUserAfterSignup({
redirectUrl,
shouldEnableFirstTimeUserOnboarding,
validLicense,
dispatch,
isAiAgentFlowEnabled,
}),
[redirectUrl, shouldEnableFirstTimeUserOnboarding, validLicense, dispatch, isAiAgentFlowEnabled],
);

[],
);

Expand Down