Skip to content

Commit

Permalink
Merge pull request #554 from odisha-muktasoft/RA-FIXES-2
Browse files Browse the repository at this point in the history
[UCEM-586,UCEM-590,UCEM-595] : updated the code for the validation fo…
  • Loading branch information
Tulika-eGov authored Jul 19, 2024
2 parents fc9553a + 6de5705 commit 995b95f
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import WorksCard from "./components/WorksCard";
import { UICustomizations } from "./configs/UICustomizations";
import HRMSCard from "./components/HRMSCard";
import Captcha from "./components/Captcha";
import DSSCard from "./components/DSSCard";

const MuktaModule = ({ stateCode, userType, tenants }) => {
const moduleCode = ["Mukta"];
Expand All @@ -32,7 +33,8 @@ const componentsToRegister = {
DSSCard:null, // TO HIDE THE DSS CARD IN HOME SCREEN as per MUKTA
AttendenceMgmtCard:null , // TO HIDE THE Attendance Mgmt CARD IN HOME SCREEN as per MUKTA
HRMSCard, // Overridden the HRMS card as per MUKTA
MeasurementCard:null
MeasurementCard:null,
DSSCard
};

const overrideHooks = () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import { HRIcon, EmployeeModuleCard } from "@egovernments/digit-ui-react-components";
import React from "react";
import { useTranslation } from "react-i18next";

const ROLES = {
MUKTADASHBOARD: ["DASHBOARD_VIEWER"]
};

const DSSCard = () => {
if (!Digit.Utils.didEmployeeHasAtleastOneRole(Object.values(ROLES).flatMap((e) => e))) {
return null;
}

const { t } = useTranslation();

let isProduction = window.location.href.includes("odisha.gov.in") ? true : false;
const propsForModuleCard = {
Icon: <HRIcon />,
moduleName: t("ACTION_TEST_10DSS"),
kpis: [
// {
// count: isLoading ? "-" : data?.EmployeCount?.totalEmployee,
// label: t("TOTAL_EMPLOYEES"),
// link: `/${window?.contextPath}/employee/hrms/inbox`
// },
// {
// count: isLoading ? "-" : data?.EmployeCount?.activeEmployee,
// label: t("ACTIVE_EMPLOYEES"),
// link: `/${window?.contextPath}/employee/hrms/inbox`
// }
],
links: [
{
label: t("DSS_MUKTA_DASHBOARD"),
link: isProduction ? `/kibana-v8/app/dashboards#/view/fcba7d24-851a-4b11-b792-e790a86bab3d?_g=[…]!t,value:60000),time:(from:now-1y%2Fd,to:now))` : `/kibana-v8/app/dashboards#/view/c8d7e730-2252-11ef-98df-3bbfa2125b2b?_g=(filters:!(),time:(from:now-1y,to:now))`,
roles: ROLES.MUKTADASHBOARD,
},
{
label: t("DSS_ROLLOUT_DASHBOARD"),
link: isProduction ? `/kibana-v8/app/dashboards#/view/1cb35e7c-2a53-45e2-a46b-018d17ae4c15?_g=[…]!t,value:60000),time:(from:now-1y%2Fd,to:now))`: `/kibana-v8/app/dashboards#/view/261cb0b0-fbde-11ee-b08d-8b505ceea182?_g=[…]use:!t,value:60000),time:(from:now-1y,to:now))`,
roles: ROLES.MUKTADASHBOARD,
},
],
};

return <EmployeeModuleCard {...propsForModuleCard} />;
};

export default DSSCard;
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,11 @@ const ExtraCharges = ({ control, watch, config, ...props }) => {
setValue(`${formFieldName}[${rowIndex}].description`, e.target.value);
};

const isValidQuantity = (value) => {
const regex = /^\d{0,4}(\.\d{0,2})?$/;
return regex.test(value);
};

const cellContainerStyle = { display: "flex", flexDirection: "column" };
const errorCardStyle = { width: "100%", fontSize: "12px", whiteSpace: "nowrap", overflow: "hidden", textOverflow: "ellipsis" };
const errorContainerStyles = { display: "block", height: "1rem", overflow: "hidden" };
Expand Down Expand Up @@ -315,7 +320,7 @@ const ExtraCharges = ({ control, watch, config, ...props }) => {
pattern: /^\s*(?=.*[1-9])\d*(?:\.\d{1,2})?\s*$/,
})}
onChange={(e) => {
if(has4DecimalPlaces(parseFloat(e?.target.value))){
if(isValidQuantity(parseFloat(e?.target.value))){
setAmountField(e, rowIndex)
}
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,14 @@ export const CreateConfig = ({ defaultValue, isUpdate, measurement }) => {
"label": "RA_ANALYSIS_QUANTITY_DEFINED",
"isMandatory": true,
"key": "analysis_qty_defined",
"type": "text",
"type": "number",
"disable": false,
"populators": {
"name": "analysis_qty_defined",
"validation": {
"pattern": "\\d{1,4}(\\.\\d{1,2})?",
"ValidationRequired" : true,
}
}
},
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,8 @@ export const FormComposer = (props) => {
minlength={populators?.validation?.minlength}
customIcon={populators?.customIcon}
customClass={populators?.customClass}
ValidationRequired={populators?.validation?.ValidationRequired}
validation={populators?.validation}
/>
)}
name={populators.name}
Expand Down

0 comments on commit 995b95f

Please sign in to comment.