Skip to content
This repository has been archived by the owner on Nov 26, 2024. It is now read-only.

Commit

Permalink
Merge pull request #978 from egovernments/ISTE-454
Browse files Browse the repository at this point in the history
Iste 454 & 416 : Added hyperlink for adding localisation and Solved numeric problem issue
  • Loading branch information
pradeepkumarcm-egov authored Oct 14, 2024
2 parents 564d24a + a56eb86 commit 1dfea84
Show file tree
Hide file tree
Showing 4 changed files with 376 additions and 228 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ const HRMSCard = () => {
},
]
: [];


// only for state admin
const moduleForSomeSTATEUser =
STATE_ADMIN && MDMS_ADMIN
? [
Expand All @@ -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"),
},
]
: [];

Expand Down Expand Up @@ -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`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}
/>
Expand All @@ -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);
};

Expand All @@ -62,7 +62,7 @@ const Response = (props) => {
const onSuccess = () => {
setMutationHappened(true);
};
if (!mutationHappened ) {
if (!mutationHappened) {
if (state.key === "UPDATE") {
mutation.mutate(
{
Expand All @@ -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}
Expand All @@ -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>
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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 };
Expand All @@ -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;
Expand All @@ -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",
Expand All @@ -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();
Expand All @@ -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;
}
}
},
},
};
Loading

0 comments on commit 1dfea84

Please sign in to comment.