Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed HRMS UI issues #621

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,13 @@ const SelectEmployeeType = ({ t, config, onSelect, formData = {}, userType }) =>
function SelectEmployeeType(value) {
setemployeeType(value);
}

useEffect(() => {
setEmployeeTypeData(data?.MdmsRes?.["egov-hrms"]?.EmployeeType);
setEmployeeTypeData(data?.MdmsRes?.["egov-hrms"]?.EmployeeType?.filter((x) => x?.code === "PERMANENT"));
}, [data, data?.MdmsRes]);

useEffect(() => {
onSelect(config.key, employeeType);
}, [employeeType]);
onSelect(config.key, employeeTypeData?.length == 1 ? employeeTypeData[0] : employeeType);
}, [employeeTypeData]);
const inputs = [
{
label: "HR_EMPLOYMENT_TYPE_LABEL",
Expand All @@ -48,9 +47,10 @@ const SelectEmployeeType = ({ t, config, onSelect, formData = {}, userType }) =>
</CardLabel>
<Dropdown
className="form-field"
selected={employeeType}
selected={employeeTypeData?.length > 0 ? employeeTypeData[0] : employeeType}
option={employeeTypeData}
select={SelectEmployeeType}
disable={true}
optionKey="code"
defaultValue={undefined}
t={t}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ const Assignments = ({ t, config, onSelect, userType, formData }) => {
key: 1,
fromDate: undefined,
toDate: undefined,
isCurrentAssignment: false,
department: null,
isCurrentAssignment: true,
department: "DWSS",
designation: null,
},
]
Expand All @@ -63,6 +63,13 @@ const Assignments = ({ t, config, onSelect, userType, formData }) => {
}
}

function getdepartmentdata() {
return data?.MdmsRes?.["common-masters"]?.Department?.map((ele) => {
ele["i18key"] = t("COMMON_MASTERS_DEPARTMENT_" + ele.code);
return ele;
});
}

const handleAddUnit = () => {
setassignments((prev) => [
...prev,
Expand Down Expand Up @@ -97,8 +104,10 @@ const Assignments = ({ t, config, onSelect, userType, formData }) => {
fromDate: assignment?.fromDate ? new Date(assignment?.fromDate).getTime() : undefined,
toDate: assignment?.toDate ? new Date(assignment?.toDate).getTime() : undefined,
isCurrentAssignment: assignment?.isCurrentAssignment,
department: assignment?.department?.code,
designation: STATE_ADMIN ? getdesignationdata()?.length > 0 && getdesignationdata()[0]?.code : assignment?.designation?.code,
department: assignment?.department?.code || "DWSS",
designation: STATE_ADMIN
? getdesignationdata()?.length > 0 && (getdesignationdata()[0]?.code || "DIV_ADMIN")
: assignment?.designation?.code,
})
: [];
});
Expand All @@ -119,13 +128,6 @@ const Assignments = ({ t, config, onSelect, userType, formData }) => {
let department = [];
let designation = [];
const [focusIndex, setFocusIndex] = useState(-1);

function getdepartmentdata() {
return data?.MdmsRes?.["common-masters"]?.Department?.map((ele) => {
ele["i18key"] = t("COMMON_MASTERS_DEPARTMENT_" + ele.code);
return ele;
});
}
if (isLoading) {
return <Loader />;
}
Expand All @@ -152,9 +154,9 @@ const Assignments = ({ t, config, onSelect, userType, formData }) => {
currentassignemtDate={currentassignemtDate}
/>
))}
<label onClick={handleAddUnit} className="link-label" style={{ width: "12rem" }}>
{/* <label onClick={handleAddUnit} className="link-label" style={{ width: "12rem" }}>
{t("HR_ADD_ASSIGNMENT")}
</label>
</label> */}
</div>
);
};
Expand All @@ -177,7 +179,7 @@ function Assignment({
}) {
const STATE_ADMIN = Digit.UserService.hasAccess(["STATE_ADMIN"]);
const selectDepartment = (value) => {
setassignments((pre) => pre.map((item) => (item.key === assignment.key ? { ...item, department: value } : item)));
setassignments((pre) => pre.map((item) => (item.key === assignment.key ? { ...item, department: getdepartmentdata(department)[0] } : item)));
};
const selectDesignation = (value) => {
setassignments((pre) => pre.map((item) => (item.key === assignment.key ? { ...item, designation: value } : item)));
Expand Down Expand Up @@ -286,8 +288,8 @@ function Assignment({
<CardLabel className={assignment?.id ? "card-label-smaller" : "card-label-smaller"}> {`${t("HR_DEPT_LABEL")} * `}</CardLabel>
<Dropdown
className="form-field"
selected={assignment?.department}
disable={assignment?.id ? true : false}
selected={getdepartmentdata(department)[0] || assignment?.department}
disable={getdepartmentdata(department)?.length == 1 ? true : false}
optionKey={"i18key"}
option={getdepartmentdata(department) || []}
select={selectDepartment}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,21 @@ const Jurisdictions = ({ t, config, onSelect, userType, formData }) => {
};
finalData.push(obj);
});
finalData?.map((items, index) => {
if (items?.division == undefined && items?.divisionBoundary?.length == 0 && jurisdictionsData[index]?.divisionBoundary?.length > 0) {
finalData[index] = jurisdictionsData[index] !== undefined && jurisdictionsData[index];
} else if (
finalData?.length > jurisdictionsData?.length &&
jurisdictionsData[index]?.division == undefined &&
items?.division != undefined &&
jurisdictionsData?.length + 1 == finalData?.length
) {
finalData = jurisdictionsData;
}
// else if (finalData?.length > jurisdictionsData?.length && jurisdictionsData?.length + 1 !== finalData?.length) {
// finalData.splice(jurisdictionsData?.length, 1);
// }
});
jurisdictionData = finalData;
}
onSelect(
Expand Down Expand Up @@ -200,6 +215,7 @@ const Jurisdictions = ({ t, config, onSelect, userType, formData }) => {
}
setInactiveJurisdictions([...inactiveJurisdictions, res]);
}
setJuristictionsData((pre) => pre.filter((el) => el.key !== unit.key));
setjurisdictions((prev) => prev.filter((el) => el.key !== unit.key));
if (FormData.errors?.Jurisdictions?.type == unit.key) {
clearErrors("Jurisdictions");
Expand Down Expand Up @@ -353,7 +369,7 @@ function Jurisdiction({
return { ...city, i18text: Digit.Utils.locale.getCityLocale(city.code) };
})
);
}, [jurisdiction?.boundaryType, data?.MdmsRes]);
}, [jurisdiction?.hierarchy, jurisdiction?.boundaryType, data?.MdmsRes]);

useEffect(() => {
if (Boundary?.length > 0) {
Expand Down Expand Up @@ -415,7 +431,7 @@ function Jurisdiction({
}));
return finalProjects;
};
const selectrole = (e, data) => {
const selectrole = (e) => {
let res = [];
e &&
e?.map((ob) => {
Expand All @@ -425,6 +441,25 @@ function Jurisdiction({
res?.forEach((resData) => {
resData.labelKey = "ACCESSCONTROL_ROLES_ROLES_" + resData.code;
});

if (isEdit && STATE_ADMIN) setJuristictionsData((pre) => pre.map((item) => (item.key === jurisdiction.key ? { ...item, roles: res } : item)));
let data = jurisdictionsData?.map((items, index) => {
let obj = {};
if (index === jurisdiction?.key) {
obj = {
...items,
roles: res,
};
} else {
obj = { ...items };
}
return obj;
});
if (isEdit && STATE_ADMIN)
onSelect(
config?.key,
[...data].filter((value) => Object.keys(value).length !== 0)
);
setjurisdictions((pre) => pre.map((item) => (item.key === jurisdiction.key ? { ...item, roles: res } : item)));
};

Expand Down Expand Up @@ -619,4 +654,4 @@ function Jurisdiction({
);
}

export default Jurisdictions;
export default Jurisdictions;
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ const EditForm = ({ tenantId, data }) => {

for (let i = 0; i < formData?.Jurisdictions?.length; i++) {
let key = formData?.Jurisdictions[i];
if (!(key?.boundary && key?.boundaryType && key?.hierarchy && key?.roles?.length > 0)) {
if (!((key?.boundary || key?.divisionBoundary) && (key?.boundaryType || key?.division) && key?.hierarchy && key?.roles?.length > 0)) {
setcheck(false);
break;
} else {
Expand Down