Skip to content
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

Tenant update #1340

Merged
merged 8 commits into from
Sep 5, 2024
Merged

Tenant update #1340

merged 8 commits into from
Sep 5, 2024

Conversation

mithunhegde-egov
Copy link

tenant update component and config added

@mithunhegde-egov mithunhegde-egov requested a review from a team as a code owner August 28, 2024 05:09
Copy link
Contributor

coderabbitai bot commented Aug 28, 2024

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Base branches to auto review (7)
  • master
  • develop
  • hcm-test
  • mf-build-docker
  • base-hcm-workbench
  • microplan
  • campaign

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

Walkthrough

A new configuration file for tenant updates has been added, along with a TenantUpdate component for managing tenant information updates. The routing structure has been modified to include navigation to the tenant update page. Additionally, existing components have been adjusted to handle more comprehensive data during tenant management operations, enhancing the overall functionality.

Changes

Files Change Summary
.../sandbox/src/configs/tenantSearchConfig.js Removed a blank line in the tenantSearchConfig function for formatting.
.../sandbox/src/configs/tenantUpdateConfig.js Introduced a new configuration object for managing tenant updates with mandatory fields and validation.
.../sandbox/src/pages/employee/index.js Added routing for the TenantUpdate component to enable tenant information updates.
.../sandbox/src/pages/employee/tenantMgmt/TenantUpdate.js Created TenantUpdate component for updating tenant information, utilizing hooks and API mutation handling.
.../sandbox/src/pages/employee/tenantMgmt/TenantView.js Enhanced onClickRow function to capture additional tenant data during navigation to the update page.
.../sandbox/src/utils/TenantUpdateUtil.js Introduced transformCreateData function to format input data for tenant creation.
.../example/public/index.html Replaced commented-out script tag with an inline script defining globalConfigs for application configuration.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant App
    participant TenantUpdate
    participant API

    User->>App: Navigate to Tenant Management
    App->>User: Show tenant list
    User->>TenantUpdate: Click update button
    TenantUpdate->>API: Fetch tenant data
    API-->>TenantUpdate: Return tenant data
    User->>TenantUpdate: Submit updated information
    TenantUpdate->>API: Send update request
    API-->>TenantUpdate: Confirm update
    TenantUpdate->>User: Show success notification
Loading

Poem

🐇 In the garden of code, changes bloom,
A TenantUpdate, dispelling gloom.
With routes that guide, and forms that flow,
Our app now dances, in a vibrant show!
So hop along, let updates be bright,
For every tenant, a future in sight! ✨


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?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

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

Outside diff range, codebase verification and nitpick comments (2)
micro-ui/web/micro-ui-internals/packages/modules/sandbox/src/pages/employee/tenantMgmt/TenantUpdate.js (2)

10-18: Ensure consistent key naming in defaultValue.

The keys in the defaultValue object should follow a consistent naming convention. For example, use camelCase for all keys.

-  const defaultValue = {
-    tenantName:name,
-    tenantCode:code,
-    emailId:email,
-    isActive:""
-  };
+  const defaultValue = {
+    tenantName: name,
+    tenantCode: code,
+    emailId: email,
+    isActive: ""
+  };

29-36: Remove unused reqCreate object.

The reqCreate object is defined but not used in the component. Remove it to clean up the code.

-  const reqCreate = {
-    url: `/tenant-management/tenant/_update`,
-    params: {},
-    body: {},
-    config: {
-      enable: false,
-    },
-  };
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between a941198 and e463f19.

Files selected for processing (6)
  • micro-ui/web/micro-ui-internals/packages/modules/sandbox/src/configs/tenantSearchConfig.js (1 hunks)
  • micro-ui/web/micro-ui-internals/packages/modules/sandbox/src/configs/tenantUpdateConfig.js (1 hunks)
  • micro-ui/web/micro-ui-internals/packages/modules/sandbox/src/pages/employee/index.js (2 hunks)
  • micro-ui/web/micro-ui-internals/packages/modules/sandbox/src/pages/employee/tenantMgmt/TenantUpdate.js (1 hunks)
  • micro-ui/web/micro-ui-internals/packages/modules/sandbox/src/pages/employee/tenantMgmt/TenantView.js (1 hunks)
  • micro-ui/web/micro-ui-internals/packages/modules/sandbox/src/utils/TenantUpdateUtil.js (1 hunks)
Files skipped from review due to trivial changes (1)
  • micro-ui/web/micro-ui-internals/packages/modules/sandbox/src/configs/tenantSearchConfig.js
Additional context used
Path-based instructions (5)
micro-ui/web/micro-ui-internals/packages/modules/sandbox/src/utils/TenantUpdateUtil.js (1)

Pattern **/*.js: check

micro-ui/web/micro-ui-internals/packages/modules/sandbox/src/pages/employee/tenantMgmt/TenantView.js (1)

Pattern **/*.js: check

micro-ui/web/micro-ui-internals/packages/modules/sandbox/src/configs/tenantUpdateConfig.js (1)

Pattern **/*.js: check

micro-ui/web/micro-ui-internals/packages/modules/sandbox/src/pages/employee/index.js (1)

Pattern **/*.js: check

micro-ui/web/micro-ui-internals/packages/modules/sandbox/src/pages/employee/tenantMgmt/TenantUpdate.js (1)

Pattern **/*.js: check

Additional comments not posted (5)
micro-ui/web/micro-ui-internals/packages/modules/sandbox/src/configs/tenantUpdateConfig.js (2)

1-59: Review validation patterns for accuracy.

Ensure that the validation patterns are accurate and meet the expected requirements.

populators: { name: "tenantName", error: "Required", validation: { pattern: /^[A-Za-z0-9]+$/i } },
populators: { name: "emailId", error: "Required", validation: { pattern: /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/i } },
populators: { name: "tenantCode", error: "Required", validation: { pattern: /^[A-Za-z0-9.]+$/i } },

1-59: Ensure alignment with the expected data structure.

Verify that the configuration aligns with the expected data structure for tenant updates.

export const tenantUpdateConfig = [
    {
      head: null,
      body: [
        {
          inline: true,
          label: "SANDBOX_CREATE_TENANT_NAME_LABEL",
          isMandatory: true,
          key: "tenantName",
          type: "text",
          disable: true,
          populators: { name: "tenantName", error: "Required", validation: { pattern: /^[A-Za-z0-9]+$/i } },
        },
        {
          inline: true,
          label: "SANDBOX_CREATE_TENANT_EMAIL_LABEL",
          isMandatory: true,
          key: "emailId",
          type: "text",
          disable: true,
          populators: { name: "emailId", error: "Required", validation: { pattern: /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/i } },
        },
        {
            inline: true,
            label: "SANDBOX_CREATE_TENANT_CODE_LABEL",
            isMandatory: true,
            key: "tenantCode",
            type: "text",
            disable: true,
            populators: { name: "tenantCode", error: "Required", validation: { pattern: /^[A-Za-z0-9.]+$/i } },
          },
        {
          isMandatory: false,
          key: "isActive",
          type: "dropdown",
          label: "SANDBOX_CREATE_TENANT_ACTIVE_LABEL",
          disable: false,
          populators: {
            name: "isActive",
            optionsKey: "name",
            error: " Required",
            required: true,
            options: [
              {
                code: "true",
                name: "TRUE",
                active: true,
              },
              {
                code: "false",
                name: "FALSE",
                active: true,
              },
            ],
          },
        },
      ],
    },
  ];
micro-ui/web/micro-ui-internals/packages/modules/sandbox/src/pages/employee/index.js (2)

12-12: LGTM!

The import statement for TenantUpdate is correctly added.

The code changes are approved.


59-59: LGTM!

The route for TenantUpdate is correctly added and follows the existing pattern for private routes.

The code changes are approved.

micro-ui/web/micro-ui-internals/packages/modules/sandbox/src/pages/employee/tenantMgmt/TenantUpdate.js (1)

1-6: LGTM!

The import statements are correctly added.

The code changes are approved.

Comment on lines +1 to +13
export const transformCreateData = (data) => {
const tenantId = Digit.ULBService.getCurrentTenantId();

return {
tenant: {
name: data.tenantName,
email: data.emailId,
code: data.tenantCode,
isActive:data.isActive.code,
parentId: tenantId,
},
};
};
Copy link
Contributor

Choose a reason for hiding this comment

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

Add error handling for Digit.ULBService.getCurrentTenantId().

The function should handle potential errors when retrieving the current tenant ID.

export const transformCreateData = (data) => {
-    const tenantId = Digit.ULBService.getCurrentTenantId();
+    let tenantId;
+    try {
+        tenantId = Digit.ULBService.getCurrentTenantId();
+    } catch (error) {
+        console.error("Failed to get current tenant ID:", error);
+        // Handle error appropriately, e.g., return or throw an error
+        return;
+    }
  
    return {
      tenant: {
        name: data.tenantName,
        email: data.emailId,
        code: data.tenantCode,
        isActive: data.isActive.code,
        parentId: tenantId,
      },
    };
  };
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
export const transformCreateData = (data) => {
const tenantId = Digit.ULBService.getCurrentTenantId();
return {
tenant: {
name: data.tenantName,
email: data.emailId,
code: data.tenantCode,
isActive:data.isActive.code,
parentId: tenantId,
},
};
};
export const transformCreateData = (data) => {
let tenantId;
try {
tenantId = Digit.ULBService.getCurrentTenantId();
} catch (error) {
console.error("Failed to get current tenant ID:", error);
// Handle error appropriately, e.g., return or throw an error
return;
}
return {
tenant: {
name: data.tenantName,
email: data.emailId,
code: data.tenantCode,
isActive: data.isActive.code,
parentId: tenantId,
},
};
};

Validate input data.

The function should validate the input data to ensure it meets the expected structure.

export const transformCreateData = (data) => {
+    if (!data || typeof data !== 'object') {
+        console.error("Invalid input data:", data);
+        // Handle error appropriately, e.g., return or throw an error
+        return;
+    }
  
    let tenantId;
    try {
        tenantId = Digit.ULBService.getCurrentTenantId();
    } catch (error) {
        console.error("Failed to get current tenant ID:", error);
        // Handle error appropriately, e.g., return or throw an error
        return;
    }
  
    return {
      tenant: {
        name: data.tenantName,
        email: data.emailId,
        code: data.tenantCode,
        isActive: data.isActive.code,
        parentId: tenantId,
      },
    };
  };
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
export const transformCreateData = (data) => {
const tenantId = Digit.ULBService.getCurrentTenantId();
return {
tenant: {
name: data.tenantName,
email: data.emailId,
code: data.tenantCode,
isActive:data.isActive.code,
parentId: tenantId,
},
};
};
export const transformCreateData = (data) => {
if (!data || typeof data !== 'object') {
console.error("Invalid input data:", data);
// Handle error appropriately, e.g., return or throw an error
return;
}
let tenantId;
try {
tenantId = Digit.ULBService.getCurrentTenantId();
} catch (error) {
console.error("Failed to get current tenant ID:", error);
// Handle error appropriately, e.g., return or throw an error
return;
}
return {
tenant: {
name: data.tenantName,
email: data.emailId,
code: data.tenantCode,
isActive: data.isActive.code,
parentId: tenantId,
},
};
};

Comment on lines +35 to +38
const code = row?.code;
const name= row?.name;
const email=row?.email;
history.push(`/${window?.contextPath}/employee/sandbox/tenant-management/update`, {name,code,email});
Copy link
Contributor

Choose a reason for hiding this comment

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

Validate the row object.

The function should ensure that the row object contains the expected properties.

const onClickRow = ({ original: row }) => {
+    if (!row || typeof row !== 'object') {
+        console.error("Invalid row data:", row);
+        return;
+    }
    const code = row?.code;
    const name = row?.name || "N/A";
    const email = row?.email || "N/A";
    history.push(`/${window?.contextPath}/employee/sandbox/tenant-management/update`, { name, code, email });
};
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 code = row?.code;
const name= row?.name;
const email=row?.email;
history.push(`/${window?.contextPath}/employee/sandbox/tenant-management/update`, {name,code,email});
const onClickRow = ({ original: row }) => {
if (!row || typeof row !== 'object') {
console.error("Invalid row data:", row);
return;
}
const code = row?.code;
const name = row?.name || "N/A";
const email = row?.email || "N/A";
history.push(`/${window?.contextPath}/employee/sandbox/tenant-management/update`, { name, code, email });
};

Add null checks for name and email properties.

The function should handle cases where name or email properties are missing.

const onClickRow = ({ original: row }) => {
    const code = row?.code;
-    const name = row?.name;
-    const email = row?.email;
+    const name = row?.name || "N/A";
+    const email = row?.email || "N/A";
    history.push(`/${window?.contextPath}/employee/sandbox/tenant-management/update`, { name, code, email });
};
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 code = row?.code;
const name= row?.name;
const email=row?.email;
history.push(`/${window?.contextPath}/employee/sandbox/tenant-management/update`, {name,code,email});
const code = row?.code;
const name = row?.name || "N/A";
const email = row?.email || "N/A";
history.push(`/${window?.contextPath}/employee/sandbox/tenant-management/update`, { name, code, email });

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: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between e463f19 and a24d26a.

Files selected for processing (1)
  • micro-ui/web/micro-ui-internals/packages/modules/sandbox/src/pages/employee/tenantMgmt/TenantUpdate.js (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • micro-ui/web/micro-ui-internals/packages/modules/sandbox/src/pages/employee/tenantMgmt/TenantUpdate.js

@nabeelmd-eGov nabeelmd-eGov changed the base branch from develop to SN-117 September 5, 2024 17:49
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: 3

Outside diff range, codebase verification and nitpick comments (1)
micro-ui/web/micro-ui-internals/packages/modules/sandbox/src/pages/employee/tenantMgmt/TenantUpdate.js (1)

1-7: Review of imports and initial setup.

  • The imports are generally well-organized and relevant to the functionality of the component.
  • The spacing in the import from react-router-dom is inconsistent (useHistory ,useLocation). Consider adding a space after the comma for consistency.
  • The utility functions and configurations are properly imported, which is good for modularity.

Consider fixing the spacing in the import statement:

-import { useHistory ,useLocation} from "react-router-dom";
+import { useHistory, useLocation } from "react-router-dom";
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between a24d26a and cd49a27.

Files selected for processing (2)
  • micro-ui/web/micro-ui-internals/example/public/index.html (2 hunks)
  • micro-ui/web/micro-ui-internals/packages/modules/sandbox/src/pages/employee/tenantMgmt/TenantUpdate.js (1 hunks)
Additional context used
Path-based instructions (1)
micro-ui/web/micro-ui-internals/packages/modules/sandbox/src/pages/employee/tenantMgmt/TenantUpdate.js (1)

Pattern **/*.js: check

Gitleaks
micro-ui/web/micro-ui-internals/example/public/index.html

19-19: Uncovered a GCP API key, which could lead to unauthorized access to Google Cloud services and data breaches.

(gcp-api-key)

Additional comments not posted (3)
micro-ui/web/micro-ui-internals/packages/modules/sandbox/src/pages/employee/tenantMgmt/TenantUpdate.js (3)

30-36: API request configuration for tenant updates.

  • The configuration object for the API request is well-defined.
  • The enable flag within config is set to false initially, which might be intentional to prevent automatic triggering. Ensure this aligns with the intended behavior.

Verify the intended use of the enable flag within the API request configuration to ensure it aligns with the expected behavior.


38-74: Form submission and mutation handling.

  • The form submission logic includes proper error handling and success management.
  • The use of a conditional to prevent updates if the tenantId matches the code is a good security practice.
  • The mutation hook is used effectively to manage API requests.

The implementation of form submission and mutation handling is robust and follows best practices.


76-94: Rendering of the TenantUpdate component.

  • The component structure is clear and functional.
  • The use of FormComposerV2 and Header from the DIGIT UI library is appropriate.
  • The conditional rendering of the Toast component based on showToast state is implemented correctly.

The rendering logic and component usage are well-implemented and follow React best practices.

Comment on lines +10 to +22
const TenantUpdate = () => {
const location = useLocation();
const { name,code,email} = location.state || {};
const defaultValue = {
tenantName:name,
tenantCode:code,
emailId:email,
isActive:""
};
const tenantId = Digit.ULBService.getCurrentTenantId();
const { t } = useTranslation();
const history = useHistory();
const [showToast, setShowToast] = useState(false);
Copy link
Contributor

Choose a reason for hiding this comment

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

Initialization and state management in TenantUpdate component.

  • The use of React hooks for state and effect management is appropriate.
  • The destructuring from location.state is concise, but lacks null-checking which could lead to runtime errors if location.state is undefined.
  • The useState for showToast is initialized correctly.

Add null-checking for location.state to prevent potential runtime errors:

-  const { name,code,email} = location.state || {};
+  const { name, code, email } = location.state ? location.state : { name: '', code: '', email: '' };
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 TenantUpdate = () => {
const location = useLocation();
const { name,code,email} = location.state || {};
const defaultValue = {
tenantName:name,
tenantCode:code,
emailId:email,
isActive:""
};
const tenantId = Digit.ULBService.getCurrentTenantId();
const { t } = useTranslation();
const history = useHistory();
const [showToast, setShowToast] = useState(false);
const TenantUpdate = () => {
const location = useLocation();
const { name, code, email } = location.state ? location.state : { name: '', code: '', email: '' };
const defaultValue = {
tenantName:name,
tenantCode:code,
emailId:email,
isActive:""
};
const tenantId = Digit.ULBService.getCurrentTenantId();
const { t } = useTranslation();
const history = useHistory();
const [showToast, setShowToast] = useState(false);

Comment on lines +24 to +28
const closeToast = () => {
setTimeout(() => {
setShowToast(false);
}, 5000);
};
Copy link
Contributor

Choose a reason for hiding this comment

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

Toast timeout management.

  • The closeToast function uses setTimeout to hide the toast, which is a common pattern.
  • However, there is no cleanup for the timeout, which could lead to memory leaks or unexpected behavior if the component unmounts before the timeout completes.

Add cleanup for the timeout in closeToast to prevent potential memory leaks:

+  useEffect(() => {
+    return () => clearTimeout(toastTimeout);
+  }, []);
+
   const closeToast = () => {
+    const toastTimeout = setTimeout(() => {
       setShowToast(false);
-    }, 5000);
+    }, 5000);
   };

Committable suggestion was skipped due to low confidence.

Comment on lines 17 to 76
var globalConfigs = (function () {
var stateTenantId = "pg";
var gmaps_api_key = 'AIzaSyCslxyiD1nuQuoshbu_E3WkIV8J2SUA6KI';
var contextPath = 'sandbox-ui';
var configModuleName = 'commonUiConfig';
var centralInstanceEnabled = false;
var localeRegion = "IN";
var multiRootTenant = true;
var isOTPBasedLogin = true;
var localeDefault = "en";
var mdmsContextV1 = "egov-mdms-service";
var mdmsContextV2 = "mdms-v2";
var footerBWLogoURL = 'https://s3.ap-south-1.amazonaws.com/egov-uat-assets/digit-footer-bw.png';
var footerLogoURL = 'https://unified-dev.digit.org/egov-dev-assets/digit-footer.png';
var digitHomeURL = 'https://www.digit.org/';
var assetS3Bucket = 'works-qa-asset';
var invalidEmployeeRoles = []
var getConfig = function (key) {
if (key === 'STATE_LEVEL_TENANT_ID') {
return stateTenantId;
}
else if (key === 'GMAPS_API_KEY') {
return gmaps_api_key;
}
else if (key === 'ENABLE_SINGLEINSTANCE') {
return centralInstanceEnabled;
} else if (key === 'MULTI_ROOT_TENANT') {
return multiRootTenant;
} else if (key === 'OTP_BASED_LOGIN') {
return isOTPBasedLogin;
} else if (key === 'DIGIT_FOOTER_BW') {
return footerBWLogoURL;
} else if (key === 'DIGIT_FOOTER') {
return footerLogoURL;
} else if (key === 'DIGIT_HOME_URL') {
return digitHomeURL;
} else if (key === 'xstate-webchat-services') {
return xstateWebchatServices;
} else if (key === 'S3BUCKET') {
return assetS3Bucket;
} else if (key === 'CONTEXT_PATH') {
return contextPath;
} else if (key === 'UICONFIG_MODULENAME') {
return configModuleName;
} else if (key === "LOCALE_REGION") {
return localeRegion;
} else if (key === "LOCALE_DEFAULT") {
return localeDefault;
} else if (key === "MDMS_V1_CONTEXT_PATH") {
return mdmsContextV2;
} else if (key === "MDMS_V2_CONTEXT_PATH") {
return mdmsContextV2;
} if (key === 'INVALIDROLES') {
return invalidEmployeeRoles;
}
};
return {
getConfig
};
}());
Copy link
Contributor

Choose a reason for hiding this comment

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

Security Issue: Exposed API Key and Suggested Improvements for getConfig Function.

The inclusion of a hardcoded Google Maps API key in the script poses a significant security risk. It is recommended to remove this key from the public files and instead load it securely from environment variables or a secure configuration management service.

Additionally, the getConfig function currently does not handle cases where the key is not defined, which could lead to undefined behavior or errors in the application. Consider adding a default case or error handling mechanism to manage undefined keys gracefully.

Proposed changes for the getConfig function:

-var getConfig = function (key) {
+var getConfig = function (key) {
+  var configMap = {
+    'STATE_LEVEL_TENANT_ID': stateTenantId,
+    'GMAPS_API_KEY': gmaps_api_key,
+    // other keys...
+  };
+  return configMap[key] || 'Key not found'; // Default message or throw an error
+};

Committable suggestion was skipped due to low confidence.

Tools
Gitleaks

19-19: Uncovered a GCP API key, which could lead to unauthorized access to Google Cloud services and data breaches.

(gcp-api-key)

@nabeelmd-eGov nabeelmd-eGov merged commit 28cae30 into SN-117 Sep 5, 2024
2 checks passed
@nabeelmd-eGov nabeelmd-eGov deleted the tenant-update branch September 5, 2024 17:52
jagankumar-egov added a commit that referenced this pull request Sep 9, 2024
* Application Management Updated

> module master added
> boundary update
> workbench enhance

* Pgr sandbox (#1360)

* pgr

* pgr (#1357)

* fix (#1358)

* Update index.html

---------

Co-authored-by: nabeelmd-eGov <[email protected]>

* hrms create and search (#1361)

* hrms create and search

* Update index.html

* review changes

* Update createEmployee.js

---------

Co-authored-by: nabeelmd-eGov <[email protected]>

* fix (#1362)

Co-authored-by: nabeelmd-eGov <[email protected]>

* Tenant update (#1340)

* update component added

* update component added

* tenant update component

* update tenant search update

* revert index.html

---------

Co-authored-by: nabeelmd-eGov <[email protected]>

* adding CSS changes (#1363)

Co-authored-by: NabeelAyubee <[email protected]>

* fix (#1364)

Co-authored-by: nabeelmd-eGov <[email protected]>

* fix (#1365)

* fix

* Update Home.js

---------

Co-authored-by: nabeelmd-eGov <[email protected]>

* hrms changes (#1367)

* hrms changes

* removed console log

* review changes

---------

Co-authored-by: nabeelmd-eGov <[email protected]>

* PR comment resolve (#1368)

Co-authored-by: NabeelAyubee <[email protected]>

* css update

* Update index.js

* PR resolve

* pr resolve

* pr resolve

* pr resolve

* Pr resolve

* pr resolve

* prresolve

* resolve

* pr resolve

* resolve

* resolve

---------

Co-authored-by: NabeelAyubee <[email protected]>
Co-authored-by: aaradhya-egov <[email protected]>
Co-authored-by: mithunhegde-egov <[email protected]>
Co-authored-by: Jagankumar <[email protected]>
Co-authored-by: aaradhya-egov <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants