From 6892ae66b5bd7b0a4f27a30188418851b50ec8c7 Mon Sep 17 00:00:00 2001 From: fahad-aot Date: Mon, 16 Dec 2024 00:57:39 -0800 Subject: [PATCH] Moved functions to helper --- .../components/Form/EditForm/FormSettings.js | 17 +---------------- forms-flow-web/src/helper/helper.js | 18 +++++++++++++++++- 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/forms-flow-web/src/components/Form/EditForm/FormSettings.js b/forms-flow-web/src/components/Form/EditForm/FormSettings.js index ec52e57961..ee0961b99f 100644 --- a/forms-flow-web/src/components/Form/EditForm/FormSettings.js +++ b/forms-flow-web/src/components/Form/EditForm/FormSettings.js @@ -16,7 +16,7 @@ import { import MultiSelectComponent from "../../CustomComponents/MultiSelect"; import { MULTITENANCY_ENABLED } from "../../../constants/constants"; -import { addTenantkey } from "../../../helper/helper"; +import { addTenantkey, addTenantkeyAsSuffix,removeTenantKeyFromPath } from "../../../helper/helper"; import { useDispatch, useSelector } from "react-redux"; import { getUserRoles } from "../../../apiManager/services/authorizationService"; import { useTranslation } from "react-i18next"; @@ -108,21 +108,6 @@ const FormSettings = forwardRef((props, ref) => { } },[MULTITENANCY_ENABLED]); - const addTenantkeyAsSuffix = (value, tenantkey) => { - if (value.toLowerCase().endsWith(`-${tenantkey}`)) { - return value.toLowerCase(); - } else { - return `${value.toLowerCase()}${tenantkey}-`; - } - }; - - const removeTenantKeyFromPath = (value, tenantKey) => { - const tenantKeyCheck = value.match(`${tenantKey}-`)?.[0]; - return tenantKeyCheck?.toLowerCase() === `${tenantKey.toLowerCase()}-` - ? value.replace(`${tenantKey.toLowerCase()}-`, "") - : value; - }; - /* ------------------------- validating form name and path ------------------------ */ const validateField = async (field, value) => { diff --git a/forms-flow-web/src/helper/helper.js b/forms-flow-web/src/helper/helper.js index 88dae6402e..17ea59160c 100644 --- a/forms-flow-web/src/helper/helper.js +++ b/forms-flow-web/src/helper/helper.js @@ -105,5 +105,21 @@ const isFormComponentsChanged = ({restoredFormData, restoredFormId, formData, fo ); }; +// Adding tenantKey as suffix +const addTenantkeyAsSuffix = (value, tenantkey) => { + if (value.toLowerCase().endsWith(`-${tenantkey}`)) { + return value.toLowerCase(); + } else { + return `${value.toLowerCase()}${tenantkey}-`; + } +}; +//removing Tenantkey from path if there is tenantkey ekse return the value +const removeTenantKeyFromPath = (value, tenantKey) => { + const tenantKeyCheck = value.match(`${tenantKey}-`)?.[0]; + return tenantKeyCheck?.toLowerCase() === `${tenantKey.toLowerCase()}-` + ? value.replace(`${tenantKey.toLowerCase()}-`, "") + : value; +}; + export { generateUniqueId, replaceUrl, addTenantkey, removeTenantKey, textTruncate, renderPage, - filterSelectOptionByLabel, isFormComponentsChanged}; + filterSelectOptionByLabel, isFormComponentsChanged, removeTenantKeyFromPath,addTenantkeyAsSuffix};