diff --git a/micro-ui/web/micro-ui-internals/packages/modules/sandbox/src/configs/tenantSearchConfig.js b/micro-ui/web/micro-ui-internals/packages/modules/sandbox/src/configs/tenantSearchConfig.js index 488aa78515..81bb521fef 100644 --- a/micro-ui/web/micro-ui-internals/packages/modules/sandbox/src/configs/tenantSearchConfig.js +++ b/micro-ui/web/micro-ui-internals/packages/modules/sandbox/src/configs/tenantSearchConfig.js @@ -18,7 +18,6 @@ export const tenantSearchConfig = () => tableFormJsonPath: "requestBody.inbox", filterFormJsonPath: "requestBody.tenant", searchFormJsonPath: "requestBody.tenant", - }, sections: { search: { diff --git a/micro-ui/web/micro-ui-internals/packages/modules/sandbox/src/configs/tenantUpdateConfig.js b/micro-ui/web/micro-ui-internals/packages/modules/sandbox/src/configs/tenantUpdateConfig.js new file mode 100644 index 0000000000..2838103587 --- /dev/null +++ b/micro-ui/web/micro-ui-internals/packages/modules/sandbox/src/configs/tenantUpdateConfig.js @@ -0,0 +1,60 @@ +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, + }, + ], + }, + }, + ], + }, + ]; + \ No newline at end of file diff --git a/micro-ui/web/micro-ui-internals/packages/modules/sandbox/src/pages/employee/index.js b/micro-ui/web/micro-ui-internals/packages/modules/sandbox/src/pages/employee/index.js index 09e5377e71..f9daf34385 100644 --- a/micro-ui/web/micro-ui-internals/packages/modules/sandbox/src/pages/employee/index.js +++ b/micro-ui/web/micro-ui-internals/packages/modules/sandbox/src/pages/employee/index.js @@ -9,6 +9,7 @@ import TenantView from "./tenantMgmt/TenantView"; import TenantCreate from "./tenantMgmt/TenantCreate"; import ApplicationHome from "./applicationMgmt/ApplicationHome"; import ModuleMasterTable from "./applicationMgmt/ModuleMasterTable"; +import TenantUpdate from "./tenantMgmt/TenantUpdate"; import SetupMaster from "./applicationMgmt/SetupMaster"; const bredCrumbStyle = { maxWidth: "min-content" }; @@ -56,6 +57,7 @@ const App = ({ path, stateCode, userType, tenants }) => { } /> } /> } /> + } /> } /> } /> } /> diff --git a/micro-ui/web/micro-ui-internals/packages/modules/sandbox/src/pages/employee/tenantMgmt/TenantUpdate.js b/micro-ui/web/micro-ui-internals/packages/modules/sandbox/src/pages/employee/tenantMgmt/TenantUpdate.js new file mode 100644 index 0000000000..30703accc1 --- /dev/null +++ b/micro-ui/web/micro-ui-internals/packages/modules/sandbox/src/pages/employee/tenantMgmt/TenantUpdate.js @@ -0,0 +1,97 @@ +import React, { useState, useEffect } from "react"; +import { useTranslation } from "react-i18next"; +import { useHistory ,useLocation} from "react-router-dom"; +import { FormComposerV2, Header, Toast } from "@egovernments/digit-ui-react-components"; +import { transformCreateData } from "../../../utils/TenantUpdateUtil"; +import { tenantUpdateConfig } from "../../../configs/tenantUpdateConfig"; + +const fieldStyle = { marginRight: 0 }; + +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 closeToast = () => { + setTimeout(() => { + setShowToast(false); + }, 5000); + }; + const reqCreate = { + url: `/tenant-management/subTenant/_update`, + params: {}, + body: {}, + config: { + enable: false, + }, + }; + const mutation = Digit.Hooks.useCustomAPIMutationHook(reqCreate); + const onSubmit = async (data) => { + if(tenantId==code){ + setShowToast({ + label: t("SANDBOX_TENANT_CANNOT_UPDATE_TOAST"), + isError: true, + }); + } + else{ + await mutation.mutate( + { + url: `/tenant-management/subTenant/_update`, + body: transformCreateData(data), + config: { + enable: true, + }, + }, + { + onError: (error, variables) => { + setShowToast({ + label: error.toString(), + isError: true, + }); + setTimeout(() => { + setShowToast(false); + }, 5000); + }, + onSuccess: async (data) => { + setShowToast({ key: "success", label: t("SANDBOX_TENANT_UPDATE_SUCCESS_TOAST") }); + setTimeout(() => { + closeToast(); + history.push(`/${window?.contextPath}/employee/sandbox/tenant-management/search`); + }, 3000); + }, + } + ); + } + }; + return ( +
+
{t("SANDBOX_UPDATE_TENANT_HEADER")}
+ { + return { + ...config, + }; + })} + defaultValues={defaultValue} + onFormValueChange={(setValue, formData, formState, reset, setError, clearErrors, trigger, getValues) => {}} + onSubmit={(data) => onSubmit(data)} + fieldStyle={fieldStyle} + noBreakLine={true} + /> + + {showToast && setShowToast(false)} />} +
+ ); +}; + +export default TenantUpdate; diff --git a/micro-ui/web/micro-ui-internals/packages/modules/sandbox/src/pages/employee/tenantMgmt/TenantView.js b/micro-ui/web/micro-ui-internals/packages/modules/sandbox/src/pages/employee/tenantMgmt/TenantView.js index ae0d4c3aed..c33639bb88 100644 --- a/micro-ui/web/micro-ui-internals/packages/modules/sandbox/src/pages/employee/tenantMgmt/TenantView.js +++ b/micro-ui/web/micro-ui-internals/packages/modules/sandbox/src/pages/employee/tenantMgmt/TenantView.js @@ -32,7 +32,10 @@ const TenantView = () => { }, []); const onClickRow = ({ original: row }) => { - const value = row?.code; + const code = row?.code; + const name= row?.name; + const email=row?.email; + history.push(`/${window?.contextPath}/employee/sandbox/tenant-management/update`, {name,code,email}); }; return ( diff --git a/micro-ui/web/micro-ui-internals/packages/modules/sandbox/src/utils/TenantUpdateUtil.js b/micro-ui/web/micro-ui-internals/packages/modules/sandbox/src/utils/TenantUpdateUtil.js new file mode 100644 index 0000000000..fdee7c17a7 --- /dev/null +++ b/micro-ui/web/micro-ui-internals/packages/modules/sandbox/src/utils/TenantUpdateUtil.js @@ -0,0 +1,14 @@ +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, + }, + }; + }; + \ No newline at end of file