-
Notifications
You must be signed in to change notification settings - Fork 22
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
how it works and user manual link added in the card #1570
Changes from all commits
b110249
510c4ab
b8eb25e
9af2089
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 |
---|---|---|
|
@@ -69,17 +69,7 @@ export const RoleBasedEmployeeHome = ({ modules, additionalComponent }) => { | |
acc[module].links.push({ | ||
// link: linkUrl, | ||
link: linkUrl, | ||
icon: linkUrl.includes("create") | ||
? "Person" | ||
: linkUrl.includes("inbox") | ||
? "AllInbox" | ||
: linkUrl.includes("search") | ||
? "Search" | ||
: linkUrl.includes("edit") | ||
? "Edit" | ||
: linkUrl.includes("dss") | ||
? "Dashboard" | ||
: "PhonelinkSetup", | ||
icon: item.leftIcon, | ||
// link: queryParamIndex === -1 ? linkUrl : linkUrl.substring(0, queryParamIndex), | ||
queryParams: queryParamIndex === -1 ? null : linkUrl.substring(queryParamIndex), | ||
label: t(Digit.Utils.locale.getTransformedLocale(`${module}_LINK_${item.displayName}`)), | ||
|
@@ -137,15 +127,72 @@ export const RoleBasedEmployeeHome = ({ modules, additionalComponent }) => { | |
sortedConfigEmployeesSidebar = configEmployeeSideBar; | ||
} | ||
|
||
const getHowItWorksLink = (moduleData) => { | ||
return moduleData?.links?.find((item) => { | ||
if (moduleData.module === "PGR") { | ||
return item?.displayName === "HOW_IT_WORKS_PGR"; | ||
} else if (moduleData.module === "HRMS") { | ||
return item?.displayName === "HOW_IT_WORKS_HRMS"; | ||
} else { | ||
return false; | ||
} | ||
}); | ||
}; | ||
|
||
const getUserManualLink = (moduleData) => { | ||
return moduleData?.links?.find((item) => { | ||
if (moduleData.module === "PGR") { | ||
return item?.displayName === "PGR_INFO_LINK"; | ||
} else if (moduleData.module === "HRMS") { | ||
return item?.displayName === "HRMS_INFO_LINK"; | ||
} else { | ||
return false; // No match for other modules | ||
} | ||
}); | ||
}; | ||
|
||
const getFilteredLinks = (moduleData) => { | ||
return moduleData.links?.filter((item) => { | ||
const displayName = item.displayName; | ||
const isPGR = moduleData.module === "PGR"; | ||
const isHRMS = moduleData.module === "HRMS"; | ||
const isNotConfigureMaster = displayName !== "Configure_master"; | ||
const isNotHowItWorksPGR = !(isPGR && displayName === "HOW_IT_WORKS_PGR"); | ||
const isNotHRMSInfoLink = !(isHRMS && displayName === "HRMS_INFO_LINK"); | ||
const isNotHowItWorksHRMS = !(isHRMS && displayName === "HOW_IT_WORKS_HRMS"); | ||
const isNotPGRInfoLink = !(isPGR && displayName === "PGR_INFO_LINK"); | ||
|
||
return ( | ||
isNotConfigureMaster && | ||
isNotHowItWorksPGR && | ||
isNotHRMSInfoLink && | ||
isNotHowItWorksHRMS && | ||
isNotPGRInfoLink | ||
); | ||
}); | ||
}; | ||
Comment on lines
+154
to
+173
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 Refactor suggestion: Simplify link filtering logic The const getFilteredLinks = (moduleData) => {
const excludedLinks = {
PGR: ["Configure_master", "HOW_IT_WORKS_PGR", "PGR_INFO_LINK"],
HRMS: ["Configure_master", "HRMS_INFO_LINK", "HOW_IT_WORKS_HRMS"],
default: ["Configure_master"]
};
const excludeList = excludedLinks[moduleData.module] || excludedLinks.default;
return moduleData.links?.filter(item => !excludeList.includes(item.displayName));
}; This refactored version:
|
||
|
||
const children = Object.keys(sortedConfigEmployeesSidebar)?.map((current, index) => { | ||
const moduleData = sortedConfigEmployeesSidebar?.[current]; | ||
const configureData = moduleData?.links?.find((item) => item?.label === "Configure"); | ||
const configureData = moduleData?.links?.find((item) => item?.displayName === "Configure_master"); | ||
const howItWorks = getHowItWorksLink(moduleData); | ||
const userManual = getUserManualLink(moduleData); | ||
const propsForModuleCard = { | ||
icon: "SupervisorAccount", | ||
moduleName: t(moduleData?.label), | ||
metrics: [], | ||
links: Digit.Utils.getMultiRootTenant() ? moduleData.links?.filter((item) => item.label !== "Configure") : moduleData.links, | ||
centreChildren: [<div>{t(Digit.Utils.locale.getTransformedLocale(`MODULE_CARD_DESC_${current}`))}</div>], | ||
links: Digit.Utils.getMultiRootTenant()? getFilteredLinks(moduleData): moduleData.links, | ||
centreChildren: [<div>{t(Digit.Utils.locale.getTransformedLocale(`MODULE_CARD_DESC_${current}`))}</div>, | ||
<Button | ||
variation="teritiary" | ||
label={userManual?.label} | ||
icon={userManual?.icon} | ||
type="button" | ||
size={"medium"} | ||
onClick={() => window.open(userManual?.link, "_blank")} | ||
style={{ padding: "0px" }} | ||
/>, | ||
], | ||
Comment on lines
+185
to
+195
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. Add key prop to React elements in centreChildren array. The new button for the user manual has been added correctly and aligns with the PR objectives. However, React elements in an array should have a unique Please add a unique centreChildren: [
<div key="description">{t(Digit.Utils.locale.getTransformedLocale(`MODULE_CARD_DESC_${current}`))}</div>,
<Button
key="userManual"
variation="teritiary"
label={userManual?.label}
icon={userManual?.icon}
type="button"
size={"medium"}
onClick={() => window.open(userManual?.link, "_blank")}
style={{ padding: "0px" }}
/>,
], 🧰 Tools🪛 Biome
Comment on lines
+184
to
+195
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. LGTM with minor improvements: Enhanced link filtering and new user manual button The changes in this segment look good overall:
However, there's a minor issue to address: Add centreChildren: [
<div key="description">{t(Digit.Utils.locale.getTransformedLocale(`MODULE_CARD_DESC_${current}`))}</div>,
<Button
key="userManual"
variation="teritiary"
label={userManual?.label}
icon={userManual?.icon}
type="button"
size={"medium"}
onClick={() => window.open(userManual?.link, "_blank")}
style={{ padding: "0px" }}
/>,
], 🧰 Tools🪛 Biome
|
||
endChildren: Digit.Utils.getMultiRootTenant() | ||
? [ | ||
<Button | ||
|
@@ -157,6 +204,15 @@ export const RoleBasedEmployeeHome = ({ modules, additionalComponent }) => { | |
onClick={() => history?.push(configureData?.link)} | ||
style={{ padding: "0px" }} | ||
/>, | ||
<Button | ||
variation="teritiary" | ||
label={howItWorks?.label} | ||
icon={howItWorks?.icon} | ||
type="button" | ||
size={"medium"} | ||
onClick={() => window.open(howItWorks?.link, "_blank")} | ||
style={{ padding: "0px" }} | ||
/>, | ||
Comment on lines
+207
to
+215
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. LGTM with minor improvements: New "How it works" button added The addition of the "How it works" button to the However, there's a minor issue to address: Add endChildren: Digit.Utils.getMultiRootTenant()
? [
<Button
key="configure"
variation="teritiary"
label={configureData?.label}
icon={configureData?.icon}
type="button"
size={"medium"}
onClick={() => history?.push(configureData?.link)}
style={{ padding: "0px" }}
/>,
<Button
key="howItWorks"
variation="teritiary"
label={howItWorks?.label}
icon={howItWorks?.icon}
type="button"
size={"medium"}
onClick={() => window.open(howItWorks?.link, "_blank")}
style={{ padding: "0px" }}
/>,
]
: null, 🧰 Tools🪛 Biome
|
||
] | ||
: null, | ||
}; | ||
|
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.
🧹 Nitpick (assertive)
LGTM: New functions for retrieving specific links
The introduction of
getHowItWorksLink
andgetUserManualLink
functions is a good addition. They effectively retrieve specific links based on the module type, aligning with the PR objectives.Consider using a switch statement or object lookup for better scalability if more modules are expected in the future. For example:
This approach would make it easier to add new modules in the future.