diff --git a/frontend/micro-ui/web/micro-ui-internals/packages/modules/hrms/src/components/hrmscard.js b/frontend/micro-ui/web/micro-ui-internals/packages/modules/hrms/src/components/hrmscard.js index 0525b7087..63fa5fd65 100644 --- a/frontend/micro-ui/web/micro-ui-internals/packages/modules/hrms/src/components/hrmscard.js +++ b/frontend/micro-ui/web/micro-ui-internals/packages/modules/hrms/src/components/hrmscard.js @@ -32,7 +32,8 @@ const HRMSCard = () => { }, ] : []; - + + // only for state admin const moduleForSomeSTATEUser = STATE_ADMIN && MDMS_ADMIN ? [ @@ -41,6 +42,11 @@ const HRMSCard = () => { link: `${window?.location?.origin}/workbench-ui/employee/workbench/mdms-search-v2?moduleName=tenant&masterName=tenants`, category: t("HR_EDIT_MASTER"), }, + { + label: t("WORK_BENCH_URL_LOCALISATION"), + link: `${window?.location?.origin}/workbench-ui/employee/workbench/localisation-search`, + category: t("HR_EDIT_MASTER"), + }, ] : []; @@ -88,11 +94,11 @@ const HRMSCard = () => { category: t("SEARCH_USER_HEADER"), }, - { - label: t("HR_STATE_ REPORTS"), - link: `/${window?.contextPath}/employee/hrms/dashboard?moduleName=dashboard&pageName=state`, - category: t("HR_DASHBOARD_HEADER"), - }, + { + label: t("HR_STATE_ REPORTS"), + link: `/${window?.contextPath}/employee/hrms/dashboard?moduleName=dashboard&pageName=state`, + category: t("HR_DASHBOARD_HEADER"), + }, { label: t("HR_RATE_DASHBOARD"), link: `/${window?.contextPath}/employee/hrms/dashboard?moduleName=dashboard&pageName=rate-master`, diff --git a/frontend/micro-ui/web/micro-ui-internals/packages/modules/hrms/src/pages/Response.js b/frontend/micro-ui/web/micro-ui-internals/packages/modules/hrms/src/pages/Response.js index 7b55756e9..e4fcf80b7 100644 --- a/frontend/micro-ui/web/micro-ui-internals/packages/modules/hrms/src/pages/Response.js +++ b/frontend/micro-ui/web/micro-ui-internals/packages/modules/hrms/src/pages/Response.js @@ -22,7 +22,7 @@ const BannerPicker = (props) => { return ( <Banner message={GetActionMessage(props.action, props.isSuccess, props.isEmployee, props.t)} - applicationNumber={props.isSuccess?props?.data?.Employees?.[0]?.code:''} + applicationNumber={props.isSuccess ? props?.data?.Employees?.[0]?.code : ""} info={GetLabel(props.action, props.isSuccess, props.isEmployee, props.t)} successful={props.isSuccess} /> @@ -40,17 +40,17 @@ const Response = (props) => { const mutation = state.key === "UPDATE" ? Digit.Hooks.hrms.useHRMSUpdate(tenantId) : Digit.Hooks.hrms.useHRMSCreate(tenantId); const employeeCreateSession = Digit.Hooks.useSessionStorage("NEW_EMPLOYEE_CREATE", {}); - const [sessionFormData,setSessionFormData, clearSessionFormData] = employeeCreateSession; + const [sessionFormData, setSessionFormData, clearSessionFormData] = employeeCreateSession; // remove session form data if user navigates away from the estimate create screen - useEffect(()=>{ + useEffect(() => { if (!window.location.href.includes("/hrms/create") && sessionFormData && Object.keys(sessionFormData) != 0) { - clearSessionFormData(); + clearSessionFormData(); } -},[location]); + }, [location]); const onError = (error, variables) => { - setErrorInfo(error?.response?.data?.Errors[0]?.code || 'ERROR'); + setErrorInfo(error?.response?.data?.Errors[0]?.code || "ERROR"); setMutationHappened(true); }; @@ -62,7 +62,7 @@ const Response = (props) => { const onSuccess = () => { setMutationHappened(true); }; - if (!mutationHappened ) { + if (!mutationHappened) { if (state.key === "UPDATE") { mutation.mutate( { @@ -83,20 +83,20 @@ const Response = (props) => { const DisplayText = (action, isSuccess, isEmployee, t) => { if (!isSuccess) { - return mutation?.error?.response?.data?.Errors[0].code||errorInfo; + return mutation?.error?.response?.data?.Errors[0].code || "ERROR"; } else { Digit.SessionStorage.set("isupdate", Math.floor(100000 + Math.random() * 900000)); - return state.key === "CREATE"?"HRMS_CREATE_EMPLOYEE_INFO" :""; + return state.key === "CREATE" ? "HRMS_CREATE_EMPLOYEE_INFO" : ""; } }; - if (mutation.isLoading || (mutation.isIdle && !mutationHappened)) { + if (mutation.isLoading || (mutation.isIdle && !mutationHappened)) { return <Loader />; } return ( <Card> <BannerPicker t={t} - data={mutation?.data|| successData} + data={mutation?.data || successData} action={state.action} isSuccess={!successData ? mutation?.isSuccess : true} isLoading={(mutation.isIdle && !mutationHappened) || mutation?.isLoading} @@ -105,7 +105,7 @@ const Response = (props) => { <CardText>{t(DisplayText(state.action, mutation.isSuccess || !!successData, props.parentRoute.includes("employee"), t), t)}</CardText> <ActionBar> - <Link to={`${props.parentRoute.includes("employee") ? `/${window?.contextPath}/employee` : `/${window?.contextPath}/citizen`}`}> + <Link to={`${props.parentRoute.includes("employee") ? `/${window?.contextPath}/employee` : `/${window?.contextPath}/citizen`}`}> <SubmitBar label={t("CORE_COMMON_GO_TO_HOME")} /> </Link> </ActionBar> diff --git a/frontend/micro-ui/web/micro-ui-internals/packages/modules/payment/src/configs/UICustomizations.js b/frontend/micro-ui/web/micro-ui-internals/packages/modules/payment/src/configs/UICustomizations.js index 07d9858ff..350e5ed31 100644 --- a/frontend/micro-ui/web/micro-ui-internals/packages/modules/payment/src/configs/UICustomizations.js +++ b/frontend/micro-ui/web/micro-ui-internals/packages/modules/payment/src/configs/UICustomizations.js @@ -1,6 +1,7 @@ import { Link, useHistory } from "react-router-dom"; import _ from "lodash"; import React from "react"; +import { useTranslation } from "react-i18next"; function anonymizeHalfString(input) { // Initialize an empty string to store the anonymized output @@ -22,28 +23,27 @@ function anonymizeHalfString(input) { } export const UICustomizations = { - OpenPaymentSearch:{ + OpenPaymentSearch: { preProcess: (data, additionalDetails) => { - //we need to get three things -> consumerCode,businessService,tenantId // businessService and tenantId can be either in queryParams or in form - let {consumerCode,businessService,tenantId} = data?.state?.searchForm || {}; - businessService = businessService?.code - tenantId = tenantId?.[0]?.code - if(!businessService){ - businessService = additionalDetails?.queryParams?.businessService + let { consumerCode, businessService, tenantId } = data?.state?.searchForm || {}; + businessService = businessService?.code; + tenantId = tenantId?.[0]?.code; + if (!businessService) { + businessService = additionalDetails?.queryParams?.businessService; } - if(!tenantId){ - tenantId = additionalDetails?.queryParams?.tenantId + if (!tenantId) { + tenantId = additionalDetails?.queryParams?.tenantId; } const finalParams = { // consumerCode, tenantId, businessService, - connectionNumber:consumerCode, - isOpenPaymentSearch:true - } - data.params = finalParams + connectionNumber: consumerCode, + isOpenPaymentSearch: true, + }; + data.params = finalParams; // data.params.textSearch = finalParams.consumerCode // const tenantId = Digit.ULBService.getCurrentTenantId(); // data.body = { RequestInfo: data.body.RequestInfo }; @@ -69,9 +69,9 @@ export const UICustomizations = { delete data.body.custom; delete data.body.pagination; data.options = { - userService:false, - auth:false - } + userService: false, + auth: false, + }; // delete data.body.inbox; // delete data.params; return data; @@ -85,70 +85,60 @@ export const UICustomizations = { return link; }, additionalCustomizations: (row, key, column, value, t, searchResult) => { - switch (key) { case "OP_CONS_CODE": - return <span className="link"> - <Link - to={`/${window.contextPath}/citizen/payment/open-view?tenantId=${row.tenantId}&businessService=WS&consumerCode=${row.connectionNo}`} - > - {String(value ? (column.translate ? t(column.prefix ? `${column.prefix}${value}` : value) : value) : t("ES_COMMON_NA"))} - </Link> - </span> - + return ( + <span className="link"> + <Link + to={`/${window.contextPath}/citizen/payment/open-view?tenantId=${row.tenantId}&businessService=WS&consumerCode=${row.connectionNo}`} + > + {String(value ? (column.translate ? t(column.prefix ? `${column.prefix}${value}` : value) : value) : t("ES_COMMON_NA"))} + </Link> + </span> + ); + case "OP_APPLICATION_TYPE": - return <div> - { value ? t(Digit.Utils.locale.getTransformedLocale(`OP_APPLICATION_TYPE_${value}`)) : t("ES_COMMON_NA")} - </div> - + return <div>{value ? t(Digit.Utils.locale.getTransformedLocale(`OP_APPLICATION_TYPE_${value}`)) : t("ES_COMMON_NA")}</div>; + case "OP_APPLICATION_STATUS": - return <div> - { value ? t(Digit.Utils.locale.getTransformedLocale(`OP_APPLICATION_STATUS_${value}`)) : t("ES_COMMON_NA")} - </div> + return <div>{value ? t(Digit.Utils.locale.getTransformedLocale(`OP_APPLICATION_STATUS_${value}`)) : t("ES_COMMON_NA")}</div>; case "OP_CONNECTION_TYPE": - return <div> - { value ? t(Digit.Utils.locale.getTransformedLocale(`OP_CONNECTION_TYPE_${value}`)) : t("ES_COMMON_NA")} - </div> + return <div>{value ? t(Digit.Utils.locale.getTransformedLocale(`OP_CONNECTION_TYPE_${value}`)) : t("ES_COMMON_NA")}</div>; case "OP_METER_INSTALLATION_DATE": - return <div> - {value ? Digit.DateUtils.ConvertEpochToDate(value) : t("ES_COMMON_NA")} - </div> + return <div>{value ? Digit.DateUtils.ConvertEpochToDate(value) : t("ES_COMMON_NA")}</div>; case "OP_METER_READING_DATE": - return <div> - {value ? Digit.DateUtils.ConvertEpochToDate(value) : t("ES_COMMON_NA")} - </div> + return <div>{value ? Digit.DateUtils.ConvertEpochToDate(value) : t("ES_COMMON_NA")}</div>; case "OP_PROPERTY_TYPE": - return <div> - { value ? t(Digit.Utils.locale.getTransformedLocale(`OP_PROPERTY_TYPE_${value}`)) : t("ES_COMMON_NA")} - </div> + return <div>{value ? t(Digit.Utils.locale.getTransformedLocale(`OP_PROPERTY_TYPE_${value}`)) : t("ES_COMMON_NA")}</div>; case "OP_PAYER_NAME": - return <div> - {value ? anonymizeHalfString(value) : t("ES_COMMON_NA")} - </div> - - + return <div>{value ? anonymizeHalfString(value) : t("ES_COMMON_NA")}</div>; + default: - return <span>{t("ES_COMMON_DEFAULT_NA")}</span> + return <span>{t("ES_COMMON_DEFAULT_NA")}</span>; } if (key === "OP_BILL_DATE") { return Digit.DateUtils.ConvertEpochToDate(value); } - if(key === "OP_BILL_TOTAL_AMT"){ - return <span>{`₹ ${value}`}</span> + if (key === "OP_BILL_TOTAL_AMT") { + return <span>{`₹ ${value}`}</span>; } - if(key === "OP_CONS_CODE") { - return <span className="link"> + if (key === "OP_CONS_CODE") { + return ( + <span className="link"> <Link to={`/${window.contextPath}/citizen/payment/open-view?tenantId=${row.tenantId}&businessService=${row.businessService}&consumerCode=${row.consumerCode}`} > {String(value ? (column.translate ? t(column.prefix ? `${column.prefix}${value}` : value) : value) : t("ES_COMMON_NA"))} </Link> - </span> + </span> + ); } }, populateReqCriteria: () => { + const { t } = useTranslation(); + const tenantId = Digit.ULBService.getCurrentTenantId(); return { url: "/mdms-v2/v1/_search", @@ -171,12 +161,14 @@ export const UICustomizations = { config: { enabled: true, select: (data) => { - const result = data?.MdmsRes?.tenant?.tenants?.filter(row => row?.divisionCode && row?.divisionName)?.map(row => { - return { - ...row, - updatedCode:`${row.divisionName} - ${row?.name}` - } - }); + const result = data?.MdmsRes?.tenant?.tenants + ?.filter((row) => row?.divisionCode && row?.divisionName) + ?.map((row) => { + return { + ...row, + updatedCode: `${row?.divisionName} - ${t(row?.code)}`, + }; + }); result.sort((a, b) => { const nameA = (a.divisionName || "").toLowerCase().trim(); const nameB = (b?.divisionName || "").toLowerCase().trim(); @@ -188,17 +180,16 @@ export const UICustomizations = { }; }, customValidationCheck: (data) => { - //checking both to and from date are present const { consumerCode } = data; - if(!consumerCode) return false; - if(consumerCode.length < 10 || consumerCode.length > 25){ + if (!consumerCode) return false; + if (consumerCode.length < 10 || consumerCode.length > 25) { return { warning: true, label: "ES_COMMON_ENTER_VALID_CONSUMER_CODE" }; } // if ((createdFrom === "" && createdTo !== "") || (createdFrom !== "" && createdTo === "")) // return { warning: true, label: "ES_COMMON_ENTER_DATE_RANGE" }; return false; - } - } + }, + }, }; diff --git a/frontend/micro-ui/web/src/Customisations/UICustomizations.js b/frontend/micro-ui/web/src/Customisations/UICustomizations.js index 042175868..afcc1e003 100644 --- a/frontend/micro-ui/web/src/Customisations/UICustomizations.js +++ b/frontend/micro-ui/web/src/Customisations/UICustomizations.js @@ -1,16 +1,14 @@ import { Link } from "react-router-dom"; import _ from "lodash"; +import { useTranslation } from "react-i18next"; //create functions here based on module name set in mdms(eg->SearchProjectConfig) //how to call these -> Digit?.Customizations?.[masterName]?.[moduleName] // these functions will act as middlewares var Digit = window.Digit || {}; - - const businessServiceMap = { - - "muster roll": "MR" + "muster roll": "MR", }; const inboxModuleNameMap = { @@ -20,7 +18,6 @@ const inboxModuleNameMap = { export const UICustomizations = { businessServiceMap, updatePayload: (applicationDetails, data, action, businessService) => { - if (businessService === businessServiceMap.estimate) { const workflow = { comment: data.comments, @@ -96,7 +93,7 @@ export const UICustomizations = { workflow, }; } - if(businessService === businessServiceMap?.["works.purchase"]){ + if (businessService === businessServiceMap?.["works.purchase"]) { const workflow = { comment: data.comments, documents: data?.documents?.map((document) => { @@ -117,35 +114,41 @@ export const UICustomizations = { }); const additionalFieldsToSet = { - projectId:applicationDetails.additionalDetails.projectId, - invoiceDate:applicationDetails.billDate, - invoiceNumber:applicationDetails.referenceId.split('_')?.[1], - contractNumber:applicationDetails.referenceId.split('_')?.[0], - documents:applicationDetails.additionalDetails.documents - } + projectId: applicationDetails.additionalDetails.projectId, + invoiceDate: applicationDetails.billDate, + invoiceNumber: applicationDetails.referenceId.split("_")?.[1], + contractNumber: applicationDetails.referenceId.split("_")?.[0], + documents: applicationDetails.additionalDetails.documents, + }; return { - bill: {...applicationDetails,...additionalFieldsToSet}, + bill: { ...applicationDetails, ...additionalFieldsToSet }, workflow, }; } }, - enableModalSubmit:(businessService,action,setModalSubmit,data)=>{ - if(businessService === businessServiceMap?.["muster roll"] && action.action==="APPROVE"){ - setModalSubmit(data?.acceptTerms) + enableModalSubmit: (businessService, action, setModalSubmit, data) => { + if ( + businessService === businessServiceMap?.["muster roll"] && + action.action === "APPROVE" + ) { + setModalSubmit(data?.acceptTerms); } }, enableHrmsSearch: (businessService, action) => { if (businessService === businessServiceMap.estimate) { - return action.action.includes("TECHNICALSANCTION") || action.action.includes("VERIFYANDFORWARD"); + return ( + action.action.includes("TECHNICALSANCTION") || + action.action.includes("VERIFYANDFORWARD") + ); } if (businessService === businessServiceMap.contract) { return action.action.includes("VERIFY_AND_FORWARD"); } - if (businessService === businessServiceMap?.["muster roll"]) { + if (businessService === businessServiceMap?.["muster roll"]) { return action.action.includes("VERIFY"); } - if(businessService === businessServiceMap?.["works.purchase"]){ - return action.action.includes("VERIFY_AND_FORWARD") + if (businessService === businessServiceMap?.["works.purchase"]) { + return action.action.includes("VERIFY_AND_FORWARD"); } return false; }, @@ -156,17 +159,13 @@ export const UICustomizations = { return businessServiceMap?.contract; } else if (moduleCode?.includes("muster roll")) { return businessServiceMap?.["muster roll"]; - } - else if (moduleCode?.includes("works.purchase")) { + } else if (moduleCode?.includes("works.purchase")) { return businessServiceMap?.["works.purchase"]; - } - else if (moduleCode?.includes("works.wages")) { + } else if (moduleCode?.includes("works.wages")) { return businessServiceMap?.["works.wages"]; - } - else if (moduleCode?.includes("works.supervision")) { + } else if (moduleCode?.includes("works.supervision")) { return businessServiceMap?.["works.supervision"]; - } - else { + } else { return businessServiceMap; } }, @@ -184,31 +183,43 @@ export const UICustomizations = { AttendanceInboxConfig: { preProcess: (data) => { - //set tenantId data.body.inbox.tenantId = Digit.ULBService.getCurrentTenantId(); - data.body.inbox.processSearchCriteria.tenantId = Digit.ULBService.getCurrentTenantId(); + data.body.inbox.processSearchCriteria.tenantId = + Digit.ULBService.getCurrentTenantId(); - const musterRollNumber = data?.body?.inbox?.moduleSearchCriteria?.musterRollNumber?.trim(); - if(musterRollNumber) data.body.inbox.moduleSearchCriteria.musterRollNumber = musterRollNumber + const musterRollNumber = + data?.body?.inbox?.moduleSearchCriteria?.musterRollNumber?.trim(); + if (musterRollNumber) + data.body.inbox.moduleSearchCriteria.musterRollNumber = + musterRollNumber; - const attendanceRegisterName = data?.body?.inbox?.moduleSearchCriteria?.attendanceRegisterName?.trim(); - if(attendanceRegisterName) data.body.inbox.moduleSearchCriteria.attendanceRegisterName = attendanceRegisterName + const attendanceRegisterName = + data?.body?.inbox?.moduleSearchCriteria?.attendanceRegisterName?.trim(); + if (attendanceRegisterName) + data.body.inbox.moduleSearchCriteria.attendanceRegisterName = + attendanceRegisterName; // deleting them for now(assignee-> need clarity from pintu,ward-> static for now,not implemented BE side) const assignee = _.clone(data.body.inbox.moduleSearchCriteria.assignee); delete data.body.inbox.moduleSearchCriteria.assignee; if (assignee?.code === "ASSIGNED_TO_ME") { - data.body.inbox.moduleSearchCriteria.assignee = Digit.UserService.getUser().info.uuid; + data.body.inbox.moduleSearchCriteria.assignee = + Digit.UserService.getUser().info.uuid; } //cloning locality and workflow states to format them // let locality = _.clone(data.body.inbox.moduleSearchCriteria.locality ? data.body.inbox.moduleSearchCriteria.locality : []); - - let selectedOrg = _.clone(data.body.inbox.moduleSearchCriteria.orgId ? data.body.inbox.moduleSearchCriteria.orgId : null); + + let selectedOrg = _.clone( + data.body.inbox.moduleSearchCriteria.orgId + ? data.body.inbox.moduleSearchCriteria.orgId + : null + ); delete data.body.inbox.moduleSearchCriteria.orgId; - if(selectedOrg) { - data.body.inbox.moduleSearchCriteria.orgId = selectedOrg?.[0]?.applicationNumber; + if (selectedOrg) { + data.body.inbox.moduleSearchCriteria.orgId = + selectedOrg?.[0]?.applicationNumber; } // let selectedWard = _.clone(data.body.inbox.moduleSearchCriteria.ward ? data.body.inbox.moduleSearchCriteria.ward : null); @@ -217,8 +228,16 @@ export const UICustomizations = { // data.body.inbox.moduleSearchCriteria.ward = selectedWard?.[0]?.code; // } - let states = _.clone(data.body.inbox.moduleSearchCriteria.state ? data.body.inbox.moduleSearchCriteria.state : []); - let ward = _.clone(data.body.inbox.moduleSearchCriteria.ward ? data.body.inbox.moduleSearchCriteria.ward : []); + let states = _.clone( + data.body.inbox.moduleSearchCriteria.state + ? data.body.inbox.moduleSearchCriteria.state + : [] + ); + let ward = _.clone( + data.body.inbox.moduleSearchCriteria.ward + ? data.body.inbox.moduleSearchCriteria.ward + : [] + ); // delete data.body.inbox.moduleSearchCriteria.locality; delete data.body.inbox.moduleSearchCriteria.state; delete data.body.inbox.moduleSearchCriteria.ward; @@ -226,30 +245,43 @@ export const UICustomizations = { // locality = locality?.map((row) => row?.code); states = Object.keys(states)?.filter((key) => states[key]); ward = ward?.map((row) => row?.code); - - + // //adding formatted data to these keys // if (locality.length > 0) data.body.inbox.moduleSearchCriteria.locality = locality; - if (states.length > 0) data.body.inbox.moduleSearchCriteria.status = states; + if (states.length > 0) + data.body.inbox.moduleSearchCriteria.status = states; if (ward.length > 0) data.body.inbox.moduleSearchCriteria.ward = ward; - const projectType = _.clone(data.body.inbox.moduleSearchCriteria.projectType ? data.body.inbox.moduleSearchCriteria.projectType : {}); - if (projectType?.code) data.body.inbox.moduleSearchCriteria.projectType = projectType.code; + const projectType = _.clone( + data.body.inbox.moduleSearchCriteria.projectType + ? data.body.inbox.moduleSearchCriteria.projectType + : {} + ); + if (projectType?.code) + data.body.inbox.moduleSearchCriteria.projectType = projectType.code; //adding tenantId to moduleSearchCriteria - data.body.inbox.moduleSearchCriteria.tenantId = Digit.ULBService.getCurrentTenantId(); + data.body.inbox.moduleSearchCriteria.tenantId = + Digit.ULBService.getCurrentTenantId(); - //setting limit and offset becoz somehow they are not getting set in muster inbox - data.body.inbox .limit = data.state.tableForm.limit - data.body.inbox.offset = data.state.tableForm.offset - delete data.state + //setting limit and offset becoz somehow they are not getting set in muster inbox + data.body.inbox.limit = data.state.tableForm.limit; + data.body.inbox.offset = data.state.tableForm.offset; + delete data.state; return data; }, postProcess: (responseArray, uiConfig) => { const statusOptions = responseArray?.statusMap ?.filter((item) => item.applicationstatus) - ?.map((item) => ({ code: item.applicationstatus, i18nKey: `COMMON_MASTERS_${item.applicationstatus}` })); + ?.map((item) => ({ + code: item.applicationstatus, + i18nKey: `COMMON_MASTERS_${item.applicationstatus}`, + })); if (uiConfig?.type === "filter") { - let fieldConfig = uiConfig?.fields?.filter((item) => item.type === "dropdown" && item.populators.name === "musterRollStatus"); + let fieldConfig = uiConfig?.fields?.filter( + (item) => + item.type === "dropdown" && + item.populators.name === "musterRollStatus" + ); if (fieldConfig.length) { fieldConfig[0].populators.options = statusOptions; } @@ -260,15 +292,26 @@ export const UICustomizations = { return ( <span className="link"> <Link - to={`/${window.contextPath}/employee/attendencemgmt/view-attendance?tenantId=${Digit.ULBService.getCurrentTenantId()}&musterRollNumber=${value}`} + to={`/${ + window.contextPath + }/employee/attendencemgmt/view-attendance?tenantId=${Digit.ULBService.getCurrentTenantId()}&musterRollNumber=${value}`} > - {String(value ? (column.translate ? t(column.prefix ? `${column.prefix}${value}` : value) : value) : t("ES_COMMON_NA"))} + {String( + value + ? column.translate + ? t(column.prefix ? `${column.prefix}${value}` : value) + : value + : t("ES_COMMON_NA") + )} </Link> </span> ); } if (key === "ATM_ATTENDANCE_WEEK") { - const week = `${Digit.DateUtils.ConvertTimestampToDate(value?.startDate, "dd/MM/yyyy")}-${Digit.DateUtils.ConvertTimestampToDate( + const week = `${Digit.DateUtils.ConvertTimestampToDate( + value?.startDate, + "dd/MM/yyyy" + )}-${Digit.DateUtils.ConvertTimestampToDate( value?.endDate, "dd/MM/yyyy" )}`; @@ -277,8 +320,14 @@ export const UICustomizations = { if (key === "ATM_NO_OF_INDIVIDUALS") { return <div>{value?.length}</div>; } - if(key === "ATM_AMOUNT_IN_RS"){ - return <span>{value ? Digit.Utils.dss.formatterWithoutRound(value, "number") : t("ES_COMMON_NA")}</span>; + if (key === "ATM_AMOUNT_IN_RS") { + return ( + <span> + {value + ? Digit.Utils.dss.formatterWithoutRound(value, "number") + : t("ES_COMMON_NA")} + </span> + ); } if (key === "ATM_SLA") { return parseInt(value) > 0 ? ( @@ -288,10 +337,10 @@ export const UICustomizations = { ); } if (key === "COMMON_WORKFLOW_STATES") { - return <span>{t(`WF_MUSTOR_${value}`)}</span> + return <span>{t(`WF_MUSTOR_${value}`)}</span>; } //added this in case we change the key and not updated here , it'll throw that nothing was returned from cell error if that case is not handled here. To prevent that error putting this default - return <span>{t(`CASE_NOT_HANDLED`)}</span> + return <span>{t(`CASE_NOT_HANDLED`)}</span>; }, MobileDetailsOnClick: (row, tenantId) => { let link; @@ -309,9 +358,9 @@ export const UICustomizations = { body: { SearchCriteria: { tenantId: tenantId, - functions : { - type : "CBO" - } + functions: { + type: "CBO", + }, }, }, config: { @@ -323,17 +372,23 @@ export const UICustomizations = { }; }, }, - SearchWageSeekerConfig: { + SearchWageSeekerConfig: { customValidationCheck: (data) => { //checking both to and from date are present const { createdFrom, createdTo } = data; - if ((createdFrom === "" && createdTo !== "") || (createdFrom !== "" && createdTo === "")) + if ( + (createdFrom === "" && createdTo !== "") || + (createdFrom !== "" && createdTo === "") + ) return { warning: true, label: "ES_COMMON_ENTER_DATE_RANGE" }; return false; }, preProcess: (data) => { - data.params = { ...data.params, tenantId: Digit.ULBService.getCurrentTenantId() }; + data.params = { + ...data.params, + tenantId: Digit.ULBService.getCurrentTenantId(), + }; let requestBody = { ...data.body.Individual }; const pathConfig = { @@ -347,7 +402,7 @@ export const UICustomizations = { wardCode: "wardCode[0].code", socialCategory: "socialCategory.code", }; - const textConfig = ["name", "individualId"] + const textConfig = ["name", "individualId"]; let Individual = Object.keys(requestBody) .map((key) => { if (selectConfig[key]) { @@ -355,7 +410,7 @@ export const UICustomizations = { } else if (typeof requestBody[key] == "object") { requestBody[key] = requestBody[key]?.code; } else if (textConfig?.includes(key)) { - requestBody[key] = requestBody[key]?.trim() + requestBody[key] = requestBody[key]?.trim(); } return key; }) @@ -364,7 +419,14 @@ export const UICustomizations = { if (pathConfig[curr]) { _.set(acc, pathConfig[curr], requestBody[curr]); } else if (dateConfig[curr] && dateConfig[curr]?.includes("day")) { - _.set(acc, curr, Digit.Utils.date.convertDateToEpoch(requestBody[curr], dateConfig[curr])); + _.set( + acc, + curr, + Digit.Utils.date.convertDateToEpoch( + requestBody[curr], + dateConfig[curr] + ) + ); } else { _.set(acc, curr, requestBody[curr]); } @@ -382,28 +444,56 @@ export const UICustomizations = { case "MASTERS_WAGESEEKER_ID": return ( <span className="link"> - <Link to={`/${window.contextPath}/employee/masters/view-wageseeker?tenantId=${row?.tenantId}&individualId=${value}`}> - {String(value ? (column.translate ? t(column.prefix ? `${column.prefix}${value}` : value) : value) : t("ES_COMMON_NA"))} + <Link + to={`/${window.contextPath}/employee/masters/view-wageseeker?tenantId=${row?.tenantId}&individualId=${value}`} + > + {String( + value + ? column.translate + ? t(column.prefix ? `${column.prefix}${value}` : value) + : value + : t("ES_COMMON_NA") + )} </Link> </span> ); case "MASTERS_SOCIAL_CATEGORY": - return value ? <span style={{ whiteSpace: "nowrap" }}>{String(t(`MASTERS_${value}`))}</span> : t("ES_COMMON_NA"); + return value ? ( + <span style={{ whiteSpace: "nowrap" }}> + {String(t(`MASTERS_${value}`))} + </span> + ) : ( + t("ES_COMMON_NA") + ); case "CORE_COMMON_PROFILE_CITY": - return value ? <span style={{ whiteSpace: "nowrap" }}>{String(t(Digit.Utils.locale.getCityLocale(value)))}</span> : t("ES_COMMON_NA"); + return value ? ( + <span style={{ whiteSpace: "nowrap" }}> + {String(t(Digit.Utils.locale.getCityLocale(value)))} + </span> + ) : ( + t("ES_COMMON_NA") + ); case "MASTERS_WARD": return value ? ( - <span style={{ whiteSpace: "nowrap" }}>{String(t(Digit.Utils.locale.getMohallaLocale(value, row?.tenantId)))}</span> + <span style={{ whiteSpace: "nowrap" }}> + {String( + t(Digit.Utils.locale.getMohallaLocale(value, row?.tenantId)) + )} + </span> ) : ( t("ES_COMMON_NA") ); case "MASTERS_LOCALITY": return value ? ( - <span style={{ whiteSpace: "break-spaces" }}>{String(t(Digit.Utils.locale.getMohallaLocale(value, row?.tenantId)))}</span> + <span style={{ whiteSpace: "break-spaces" }}> + {String( + t(Digit.Utils.locale.getMohallaLocale(value, row?.tenantId)) + )} + </span> ) : ( t("ES_COMMON_NA") ); @@ -421,32 +511,36 @@ export const UICustomizations = { }, additionalValidations: (type, data, keys) => { if (type === "date") { - return data[keys.start] && data[keys.end] ? () => new Date(data[keys.start]).getTime() <= new Date(data[keys.end]).getTime() : true; + return data[keys.start] && data[keys.end] + ? () => + new Date(data[keys.start]).getTime() <= + new Date(data[keys.end]).getTime() + : true; } - } + }, }, - OpenPaymentSearch:{ + OpenPaymentSearch: { preProcess: (data, additionalDetails) => { - //we need to get three things -> consumerCode,businessService,tenantId // businessService and tenantId can be either in queryParams or in form - let {consumerCode,businessService,tenantId} = data?.state?.searchForm || {}; - businessService = businessService?.code - tenantId = tenantId?.[0]?.code - if(!businessService){ - businessService = additionalDetails?.queryParams?.businessService + let { consumerCode, businessService, tenantId } = + data?.state?.searchForm || {}; + businessService = businessService?.code; + tenantId = tenantId?.[0]?.code; + if (!businessService) { + businessService = additionalDetails?.queryParams?.businessService; } - if(!tenantId){ - tenantId = additionalDetails?.queryParams?.tenantId + if (!tenantId) { + tenantId = additionalDetails?.queryParams?.tenantId; } const finalParams = { // consumerCode, tenantId, businessService, - connectionNumber:consumerCode, - isOpenPaymentSearch:true - } - data.params = finalParams + connectionNumber: consumerCode, + isOpenPaymentSearch: true, + }; + data.params = finalParams; // data.params.textSearch = finalParams.consumerCode // const tenantId = Digit.ULBService.getCurrentTenantId(); // data.body = { RequestInfo: data.body.RequestInfo }; @@ -472,78 +566,134 @@ export const UICustomizations = { delete data.body.custom; delete data.body.pagination; data.options = { - userService:false, - auth:false - } + userService: false, + auth: false, + }; // delete data.body.inbox; // delete data.params; return data; }, additionalCustomizations: (row, key, column, value, t, searchResult) => { - switch (key) { case "OP_CONS_CODE": - return <span className="link"> - <Link - to={`/${window.contextPath}/citizen/payment/open-view?tenantId=${row.tenantId}&businessService=WS&consumerCode=${row.connectionNo}`} - > - {String(value ? (column.translate ? t(column.prefix ? `${column.prefix}${value}` : value) : value) : t("ES_COMMON_NA"))} - </Link> - </span> - + return ( + <span className="link"> + <Link + to={`/${window.contextPath}/citizen/payment/open-view?tenantId=${row.tenantId}&businessService=WS&consumerCode=${row.connectionNo}`} + > + {String( + value + ? column.translate + ? t(column.prefix ? `${column.prefix}${value}` : value) + : value + : t("ES_COMMON_NA") + )} + </Link> + </span> + ); + case "OP_APPLICATION_TYPE": - return <div> - { value ? t(Digit.Utils.locale.getTransformedLocale(`OP_APPLICATION_TYPE_${value}`)) : t("ES_COMMON_NA")} - </div> - + return ( + <div> + {value + ? t( + Digit.Utils.locale.getTransformedLocale( + `OP_APPLICATION_TYPE_${value}` + ) + ) + : t("ES_COMMON_NA")} + </div> + ); + case "OP_APPLICATION_STATUS": - return <div> - { value ? t(Digit.Utils.locale.getTransformedLocale(`OP_APPLICATION_STATUS_${value}`)) : t("ES_COMMON_NA")} - </div> + return ( + <div> + {value + ? t( + Digit.Utils.locale.getTransformedLocale( + `OP_APPLICATION_STATUS_${value}` + ) + ) + : t("ES_COMMON_NA")} + </div> + ); case "OP_CONNECTION_TYPE": - return <div> - { value ? t(Digit.Utils.locale.getTransformedLocale(`OP_CONNECTION_TYPE_${value}`)) : t("ES_COMMON_NA")} - </div> + return ( + <div> + {value + ? t( + Digit.Utils.locale.getTransformedLocale( + `OP_CONNECTION_TYPE_${value}` + ) + ) + : t("ES_COMMON_NA")} + </div> + ); case "OP_METER_INSTALLATION_DATE": - return <div> - {value ? Digit.DateUtils.ConvertEpochToDate(value) : t("ES_COMMON_NA")} - </div> + return ( + <div> + {value + ? Digit.DateUtils.ConvertEpochToDate(value) + : t("ES_COMMON_NA")} + </div> + ); case "OP_METER_READING_DATE": - return <div> - {value ? Digit.DateUtils.ConvertEpochToDate(value) : t("ES_COMMON_NA")} - </div> + return ( + <div> + {value + ? Digit.DateUtils.ConvertEpochToDate(value) + : t("ES_COMMON_NA")} + </div> + ); case "OP_PROPERTY_TYPE": - return <div> - { value ? t(Digit.Utils.locale.getTransformedLocale(`OP_PROPERTY_TYPE_${value}`)) : t("ES_COMMON_NA")} - </div> + return ( + <div> + {value + ? t( + Digit.Utils.locale.getTransformedLocale( + `OP_PROPERTY_TYPE_${value}` + ) + ) + : t("ES_COMMON_NA")} + </div> + ); case "OP_PAYER_NAME": - return <div> - {value ? anonymizeHalfString(value) : t("ES_COMMON_NA")} - </div> - - + return ( + <div>{value ? anonymizeHalfString(value) : t("ES_COMMON_NA")}</div> + ); + default: - return <span>{t("ES_COMMON_DEFAULT_NA")}</span> + return <span>{t("ES_COMMON_DEFAULT_NA")}</span>; } if (key === "OP_BILL_DATE") { return Digit.DateUtils.ConvertEpochToDate(value); } - if(key === "OP_BILL_TOTAL_AMT"){ - return <span>{`₹ ${value}`}</span> + if (key === "OP_BILL_TOTAL_AMT") { + return <span>{`₹ ${value}`}</span>; } - if(key === "OP_CONS_CODE") { - return <span className="link"> + if (key === "OP_CONS_CODE") { + return ( + <span className="link"> <Link to={`/${window.contextPath}/citizen/payment/open-view?tenantId=${row.tenantId}&businessService=${row.businessService}&consumerCode=${row.consumerCode}`} > - {String(value ? (column.translate ? t(column.prefix ? `${column.prefix}${value}` : value) : value) : t("ES_COMMON_NA"))} + {String( + value + ? column.translate + ? t(column.prefix ? `${column.prefix}${value}` : value) + : value + : t("ES_COMMON_NA") + )} </Link> - </span> + </span> + ); } }, populateReqCriteria: () => { + const { t } = useTranslation(); + const tenantId = Digit.ULBService.getCurrentTenantId(); return { url: "/mdms-v2/v1/_search", @@ -566,29 +716,30 @@ export const UICustomizations = { config: { enabled: true, select: (data) => { - const result = data?.MdmsRes?.tenant?.tenants?.filter(row => row?.divisionCode && row?.divisionName)?.map(row => { - return { - ...row, - updatedCode:`${row.divisionName} - ${row?.name}` - } - }); + const result = data?.MdmsRes?.tenant?.tenants + ?.filter((row) => row?.divisionCode && row?.divisionName) + ?.map((row) => { + return { + ...row, + updatedCode: `${row?.divisionName} - ${t(row?.code)}`, + }; + }); return result; }, }, }; }, customValidationCheck: (data) => { - //checking both to and from date are present const { consumerCode } = data; - if(!consumerCode) return false; - if(consumerCode.length < 10 || consumerCode.length > 25){ + if (!consumerCode) return false; + if (consumerCode.length < 10 || consumerCode.length > 25) { return { warning: true, label: "ES_COMMON_ENTER_VALID_CONSUMER_CODE" }; } // if ((createdFrom === "" && createdTo !== "") || (createdFrom !== "" && createdTo === "")) // return { warning: true, label: "ES_COMMON_ENTER_DATE_RANGE" }; return false; - } - } + }, + }, };