-
Notifications
You must be signed in to change notification settings - Fork 20
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
hrms edit and deactivate bug fixes #1655
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -21,6 +21,7 @@ const Details = () => { | |||||||||||||||||||||||||||||||||
const [mutationHappened, setMutationHappened, clear] = Digit.Hooks.useSessionStorage("EMPLOYEE_HRMS_MUTATION_HAPPENED", false); | ||||||||||||||||||||||||||||||||||
const [successData, setsuccessData, clearSuccessData] = Digit.Hooks.useSessionStorage("EMPLOYEE_HRMS_MUTATION_SUCCESS_DATA", false); | ||||||||||||||||||||||||||||||||||
const isMobile = window.Digit.Utils.browser.isMobile(); | ||||||||||||||||||||||||||||||||||
const isMultiRootTenant = Digit.Utils.getMultiRootTenant(); | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
useEffect(() => { | ||||||||||||||||||||||||||||||||||
setMutationHappened(false); | ||||||||||||||||||||||||||||||||||
|
@@ -62,6 +63,9 @@ const Details = () => { | |||||||||||||||||||||||||||||||||
return <Loader />; | ||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
console.log(":data of the employee", data); | ||||||||||||||||||||||||||||||||||
console.log("role data is", data?.Employees?.[0]?.user.roles.map((ele) => t(`ACCESSCONTROL_ROLES_ROLES_` + ele?.code))); | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove console.log statements. Debug console logs should not be committed to production code. These statements expose sensitive employee data and role information which could be a security concern. Apply this diff to remove the debug statements: - console.log(":data of the employee", data);
- console.log("role data is", data?.Employees?.[0]?.user.roles.map((ele) => t(`ACCESSCONTROL_ROLES_ROLES_` + ele?.code)));
- 📝 Committable suggestion
Suggested change
🧰 Tools🪛 Biome
|
||||||||||||||||||||||||||||||||||
return ( | ||||||||||||||||||||||||||||||||||
<React.Fragment> | ||||||||||||||||||||||||||||||||||
<div style={isMobile ? {marginLeft: "-12px", fontFamily: "calibri", color: "#FF0000"} :{ marginLeft: "15px", fontFamily: "calibri", color: "#FF0000" }}> | ||||||||||||||||||||||||||||||||||
|
@@ -169,7 +173,8 @@ const Details = () => { | |||||||||||||||||||||||||||||||||
<Row label={t("HR_BOUNDARY_LABEL")} text={t(element?.boundary)} /> | ||||||||||||||||||||||||||||||||||
<Row | ||||||||||||||||||||||||||||||||||
label={t("HR_ROLE_LABEL")} | ||||||||||||||||||||||||||||||||||
text={data?.Employees?.[0]?.user.roles.filter((ele) => ele.tenantId == element?.boundary).map((ele) => t(`ACCESSCONTROL_ROLES_ROLES_` + ele?.code))} | ||||||||||||||||||||||||||||||||||
text={ | ||||||||||||||||||||||||||||||||||
isMultiRootTenant? data?.Employees?.[0]?.user.roles.map((ele) => t(`ACCESSCONTROL_ROLES_ROLES_` + ele?.code)):(data?.Employees?.[0]?.user.roles.filter((ele) => ele.tenantId == element?.boundary).map((ele) => t(`ACCESSCONTROL_ROLES_ROLES_` + ele?.code)))} | ||||||||||||||||||||||||||||||||||
Comment on lines
+174
to
+175
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Improve role display logic for better maintainability and safety. The current implementation has several areas for improvement:
Consider this enhanced version of the previous refactoring suggestion: text={
- isMultiRootTenant? data?.Employees?.[0]?.user.roles.map((ele) => t(`ACCESSCONTROL_ROLES_ROLES_` + ele?.code)):(data?.Employees?.[0]?.user.roles.filter((ele) => ele.tenantId == element?.boundary).map((ele) => t(`ACCESSCONTROL_ROLES_ROLES_` + ele?.code)))}
+ (() => {
+ const roles = data?.Employees?.[0]?.user?.roles;
+ if (!roles?.length) return 'NA';
+
+ const filteredRoles = isMultiRootTenant
+ ? roles
+ : roles.filter((role) => role?.tenantId === element?.boundary);
+
+ return filteredRoles.map((role) =>
+ t(`ACCESSCONTROL_ROLES_ROLES_${role?.code || ''}`)
+ );
+ })()
+ } This refactoring:
📝 Committable suggestion
Suggested change
🧰 Tools🪛 Biome
|
||||||||||||||||||||||||||||||||||
/> | ||||||||||||||||||||||||||||||||||
</StatusTable> | ||||||||||||||||||||||||||||||||||
); | ||||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove them