-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* update component added * update component added * tenant update component * update tenant search update * revert index.html --------- Co-authored-by: nabeelmd-eGov <[email protected]>
- Loading branch information
1 parent
58ff2f5
commit 28cae30
Showing
6 changed files
with
177 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
micro-ui/web/micro-ui-internals/packages/modules/sandbox/src/configs/tenantUpdateConfig.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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, | ||
}, | ||
], | ||
}, | ||
}, | ||
], | ||
}, | ||
]; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
97 changes: 97 additions & 0 deletions
97
...micro-ui-internals/packages/modules/sandbox/src/pages/employee/tenantMgmt/TenantUpdate.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 ( | ||
<div> | ||
<Header> {t("SANDBOX_UPDATE_TENANT_HEADER")}</Header> | ||
<FormComposerV2 | ||
label={t("SANDBOX_UPDATE_TENANT_SUBMIT_BUTTON")} | ||
config={tenantUpdateConfig.map((config) => { | ||
return { | ||
...config, | ||
}; | ||
})} | ||
defaultValues={defaultValue} | ||
onFormValueChange={(setValue, formData, formState, reset, setError, clearErrors, trigger, getValues) => {}} | ||
onSubmit={(data) => onSubmit(data)} | ||
fieldStyle={fieldStyle} | ||
noBreakLine={true} | ||
/> | ||
|
||
{showToast && <Toast error={showToast?.isError} label={showToast?.label} isDleteBtn={"true"} onClose={() => setShowToast(false)} />} | ||
</div> | ||
); | ||
}; | ||
|
||
export default TenantUpdate; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
micro-ui/web/micro-ui-internals/packages/modules/sandbox/src/utils/TenantUpdateUtil.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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, | ||
}, | ||
}; | ||
}; | ||
|