-
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
Payment: Attendance Approval Flow #2097
base: console
Are you sure you want to change the base?
Changes from 106 commits
0c5c504
38373ae
a616ef8
e26bb39
7fbbf53
d12482d
8c988e3
817ad5e
51b2ae1
3d92fce
7460527
6860809
bc08be1
a5dcdcd
bd357c7
4753623
87ebbfe
c49fce8
fa96bc1
ccc8c62
b3183df
ceef537
322030a
1a77329
4184080
ed322b8
275854d
68dfb09
6ca1ccc
7fc944a
28a99d2
391a0d0
c6c8855
0144d47
302df9a
42818c0
86b87ed
459e7be
bd5af59
ad0cb84
9a87660
0be1940
f92ec48
4ebea8c
3329e13
6077b9c
3d26e04
a8e1144
ccaf400
1c26a4e
ade4d3d
7cb9d3d
4a12d65
db267f0
821bcb6
c858a3f
f24b600
92b31c3
ca816f0
7567c72
b4009a9
0c78039
2cc84cb
2b30b94
2ea6c8b
696aec9
3b4bde7
576c2cd
e18e422
bba873a
9156ae0
416f422
314ff43
36801c5
c4b498c
66b907e
67b30b2
8bf196c
db0e070
54279bf
0779649
0c80699
ce025e3
a8c3413
efe93e9
8e4c472
0ae9a2a
5afe320
5c1ae6c
375792b
5668822
54fe437
47a8732
4fbb011
40700e6
74c3e13
a65ff03
2d20a68
a2a7910
d17ade5
7a9cccd
12b115b
a619132
ba199a4
45b6177
a4b50c7
30ffe96
b095cba
1d9f532
bdbf2dc
71114b0
bb0cd71
88b56f0
677fae4
dcb20d9
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 |
---|---|---|
|
@@ -26,7 +26,9 @@ | |
"react-hook-form": "6.15.8", | ||
"react-i18next": "11.16.2", | ||
"react-query": "3.6.1", | ||
"react-router-dom": "5.3.0" | ||
"react-router-dom": "5.3.0", | ||
"react-data-table-component": "7.6.2" | ||
|
||
}, | ||
"author": "Ramkrishna <[email protected]>", | ||
"license": "MIT" | ||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -1,16 +1,26 @@ | ||||||
import { Loader } from "@egovernments/digit-ui-react-components"; | ||||||
import React,{useState} from "react"; | ||||||
import React, { useState } from "react"; | ||||||
import { useRouteMatch } from "react-router-dom"; | ||||||
import { default as EmployeeApp } from "./pages/employee"; | ||||||
import PaymentsCard from "./components/PaymentsCard"; | ||||||
import { overrideHooks, updateCustomConfigs } from "./utils"; | ||||||
import { ProviderContext } from "./utils/context"; | ||||||
import BoundaryComponent from "./components/sample"; | ||||||
import CampaignNameSelection from "./components/campaign_dropdown"; | ||||||
import CustomInboxSearchComposer from "./components/custom_inbox_composer"; | ||||||
import CustomInboxSearchLinks from "./components/custom_comp/link_section"; | ||||||
import CustomSearchComponent from "./components/custom_comp/search_section"; | ||||||
import CustomFilter from "./components/custom_comp/filter_section"; | ||||||
import CustomInboxTable from "./components/custom_comp/table_inbox"; | ||||||
|
||||||
export const PaymentsModule = ({ stateCode, userType, tenants }) => { | ||||||
const { path, url } = useRouteMatch(); | ||||||
const tenantId = Digit.ULBService.getCurrentTenantId(); | ||||||
|
||||||
const moduleCode = ["payments"]; | ||||||
const hierarchyType = "MICROPLAN"; | ||||||
|
||||||
// const hierarchyType = window?.globalConfigs?.getConfig("HIERARCHY_TYPE") || "ADMIN"; | ||||||
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. 🧹 Nitpick (assertive) Remove stale commented-out code |
||||||
const moduleCode = ["payments", `boundary-${hierarchyType}`]; | ||||||
Comment on lines
+20
to
+23
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. 🧹 Nitpick (assertive) Avoid hardcoding Hardcoding |
||||||
const modulePrefix = "hcm"; | ||||||
const language = Digit.StoreData.getCurrentLanguage(); | ||||||
const { isLoading, data: store } = Digit.Services.useStore({ | ||||||
|
@@ -19,18 +29,49 @@ export const PaymentsModule = ({ stateCode, userType, tenants }) => { | |||||
language, | ||||||
modulePrefix, | ||||||
}); | ||||||
let user = Digit?.SessionStorage.get("User"); | ||||||
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. 🧹 Nitpick (assertive) Use - let user = Digit?.SessionStorage.get("User");
+ const user = Digit?.SessionStorage.get("User"); 📝 Committable suggestion
Suggested change
🧰 Tools🪛 Biome (1.9.4)[error] 32-32: This let declares a variable that is only assigned once. 'user' is never reassigned. Safe fix: Use const instead. (lint/style/useConst) |
||||||
const { isLoading: isPaymentsModuleInitializing } = Digit.Hooks.payments.usePaymentsInitialization({ | ||||||
tenantId: tenantId, | ||||||
}); | ||||||
|
||||||
|
||||||
return ( | ||||||
<ProviderContext> | ||||||
<EmployeeApp path={path} stateCode={stateCode} userType={userType} tenants={tenants}/> | ||||||
</ProviderContext> | ||||||
const { isLoading: isMDMSLoading, data: mdmsData } = Digit.Hooks.useCustomMDMS( | ||||||
Digit.ULBService.getCurrentTenantId(), | ||||||
"HCM", | ||||||
[{ name: "BOUNDARYTYPES" }, { name: "paymentsConfig" }], | ||||||
{ | ||||||
cacheTime: Infinity, | ||||||
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. 🧹 Nitpick (assertive) Use For consistency and clarity, replace 🧰 Tools🪛 Biome (1.9.4)[error] 42-42: Use Number.POSITIVE_INFINITY instead of the equivalent global. ES2015 moved some globals into the Number namespace for consistency. (lint/style/useNumberNamespace) |
||||||
}, | ||||||
{ schemaCode: "PAYMENTS_MASTER_DATA" } //mdmsv2 | ||||||
); | ||||||
|
||||||
const sortedBoundaryData = mdmsData?.MdmsRes?.HCM?.BOUNDARYTYPES?.sort((a, b) => a.order - b.order); | ||||||
const paymentsConfig = mdmsData?.MdmsRes?.HCM?.paymentsConfig?.[0]; | ||||||
|
||||||
Digit.SessionStorage.set("boundaryHierarchyOrder", sortedBoundaryData); | ||||||
Digit.SessionStorage.set("paymentsConfig", paymentsConfig); | ||||||
|
||||||
if (isPaymentsModuleInitializing || isMDMSLoading) { | ||||||
return <Loader />; | ||||||
} else { | ||||||
return ( | ||||||
<ProviderContext> | ||||||
<EmployeeApp path={path} stateCode={stateCode} userType={userType} tenants={tenants} /> | ||||||
</ProviderContext> | ||||||
); | ||||||
} | ||||||
}; | ||||||
|
||||||
const componentsToRegister = { | ||||||
PaymentsModule, | ||||||
PaymentsCard | ||||||
PaymentsCard, | ||||||
BoundaryComponent, | ||||||
CampaignNameSelection, | ||||||
// | ||||||
CustomInboxSearchComposer, | ||||||
CustomInboxSearchLinks, | ||||||
CustomSearchComponent, | ||||||
CustomFilter, | ||||||
CustomInboxTable, | ||||||
}; | ||||||
|
||||||
export const initPaymentComponents = () => { | ||||||
|
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,142 @@ | ||||||||||||||||||||||
import React, { useEffect, useState, Fragment } from "react"; | ||||||||||||||||||||||
import PropTypes from "prop-types"; | ||||||||||||||||||||||
import { Link } from "react-router-dom"; | ||||||||||||||||||||||
|
||||||||||||||||||||||
const BreadCrumbs = (props) => { | ||||||||||||||||||||||
const [expanded, setExpanded] = useState(false); | ||||||||||||||||||||||
const [crumbsToDisplay, setCrumbsToDisplay] = useState([...props?.crumbs]); | ||||||||||||||||||||||
|
||||||||||||||||||||||
useEffect(() => { | ||||||||||||||||||||||
if (props?.maxItems && props?.crumbs.length > props?.maxItems && !expanded) { | ||||||||||||||||||||||
const startCrumbs = props.crumbs.slice(0, props?.itemsBeforeCollapse || Math.ceil(props.maxItems / 2)); | ||||||||||||||||||||||
const endCrumbs = props.crumbs.slice( | ||||||||||||||||||||||
-1 * (props?.itemsAfterCollapse || Math.floor(props.maxItems / 2)) | ||||||||||||||||||||||
); | ||||||||||||||||||||||
|
||||||||||||||||||||||
let updatedCrumbs = startCrumbs.concat( | ||||||||||||||||||||||
[{ show: true, content: props?.expandText || "..." }], | ||||||||||||||||||||||
endCrumbs | ||||||||||||||||||||||
); | ||||||||||||||||||||||
setCrumbsToDisplay(updatedCrumbs); | ||||||||||||||||||||||
Comment on lines
+16
to
+20
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. 🧹 Nitpick (assertive) Use - let updatedCrumbs = startCrumbs.concat(
+ const updatedCrumbs = startCrumbs.concat( 📝 Committable suggestion
Suggested change
🧰 Tools🪛 Biome (1.9.4)[error] 16-16: This let declares a variable that is only assigned once. 'updatedCrumbs' is never reassigned. Safe fix: Use const instead. (lint/style/useConst) |
||||||||||||||||||||||
} else { | ||||||||||||||||||||||
setCrumbsToDisplay([...props.crumbs]); | ||||||||||||||||||||||
} | ||||||||||||||||||||||
}, [props.crumbs, props.maxItems, expanded, props.itemsBeforeCollapse, props.itemsAfterCollapse, props?.expandText]); | ||||||||||||||||||||||
|
||||||||||||||||||||||
function handleRedirect(path) { | ||||||||||||||||||||||
const host = window.location.origin; // Dynamically get the base URL | ||||||||||||||||||||||
window.location.href = `${host}${path}`; | ||||||||||||||||||||||
} | ||||||||||||||||||||||
|
||||||||||||||||||||||
function isLast(index) { | ||||||||||||||||||||||
// Filter crumbs to only include those that are displayed | ||||||||||||||||||||||
let validCrumbs = crumbsToDisplay?.filter((crumb) => crumb?.show === true); | ||||||||||||||||||||||
|
||||||||||||||||||||||
Comment on lines
+33
to
+34
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. 🧹 Nitpick (assertive) Prefer - let validCrumbs = crumbsToDisplay?.filter((crumb) => crumb?.show === true);
+ const validCrumbs = crumbsToDisplay?.filter((crumb) => crumb?.show === true); 📝 Committable suggestion
Suggested change
🧰 Tools🪛 Biome (1.9.4)[error] 33-33: This let declares a variable that is only assigned once. 'validCrumbs' is never reassigned. Safe fix: Use const instead. (lint/style/useConst) |
||||||||||||||||||||||
// Check if all crumbs have the same `internalLink` or `externalLink` | ||||||||||||||||||||||
const allHaveSameInternalLink = validCrumbs.every((crumb) => crumb.internalLink === validCrumbs[0].internalLink); | ||||||||||||||||||||||
const allHaveSameExternalLink = validCrumbs.every((crumb) => crumb.externalLink === validCrumbs[0].externalLink); | ||||||||||||||||||||||
|
||||||||||||||||||||||
// If all visible crumbs have the same link, determine last crumb by index | ||||||||||||||||||||||
if (allHaveSameInternalLink || allHaveSameExternalLink) { | ||||||||||||||||||||||
return index === validCrumbs.length - 1; | ||||||||||||||||||||||
} | ||||||||||||||||||||||
|
||||||||||||||||||||||
// Check if the current crumb is the last one in the validCrumbs list | ||||||||||||||||||||||
return ( | ||||||||||||||||||||||
validCrumbs?.findIndex((ob) => { | ||||||||||||||||||||||
const linkToCheck = ob?.externalLink || ob?.internalLink; // Use externalLink if it exists, else internalLink | ||||||||||||||||||||||
const currentLink = crumbsToDisplay?.[index]?.externalLink || crumbsToDisplay?.[index]?.internalLink; | ||||||||||||||||||||||
|
||||||||||||||||||||||
return linkToCheck === currentLink; | ||||||||||||||||||||||
}) === | ||||||||||||||||||||||
validCrumbs?.length - 1 | ||||||||||||||||||||||
); | ||||||||||||||||||||||
} | ||||||||||||||||||||||
|
||||||||||||||||||||||
const handleCrumbClick = () => { | ||||||||||||||||||||||
setExpanded(!expanded); | ||||||||||||||||||||||
}; | ||||||||||||||||||||||
|
||||||||||||||||||||||
const validCrumbsMain = crumbsToDisplay?.filter((crumb) => crumb?.show === true); | ||||||||||||||||||||||
|
||||||||||||||||||||||
return ( | ||||||||||||||||||||||
<ol | ||||||||||||||||||||||
className={`digit-bread-crumb ${props?.className ? props?.className : ""}`} | ||||||||||||||||||||||
style={props?.style} | ||||||||||||||||||||||
> | ||||||||||||||||||||||
{validCrumbsMain?.map((crumb, ci) => { | ||||||||||||||||||||||
if (!crumb?.show) return null; | ||||||||||||||||||||||
if (crumb?.isBack) | ||||||||||||||||||||||
return ( | ||||||||||||||||||||||
<li | ||||||||||||||||||||||
key={ci} | ||||||||||||||||||||||
style={props?.itemStyle} | ||||||||||||||||||||||
className="digit-bread-crumb--item back-crumb-item" | ||||||||||||||||||||||
> | ||||||||||||||||||||||
<span onClick={() => window.history.back()}>{crumb.content}</span> | ||||||||||||||||||||||
</li> | ||||||||||||||||||||||
Comment on lines
+76
to
+77
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 Add keyboard event handlers for accessibility. - <span onClick={() => window.history.back()}>{crumb.content}</span>
+ <span
+ onClick={() => window.history.back()}
+ onKeyDown={(e) => { if (e.key === "Enter") window.history.back(); }}
+ tabIndex={0}
+ >
+ {crumb.content}
+ </span> 📝 Committable suggestion
Suggested change
🧰 Tools🪛 Biome (1.9.4)[error] 76-76: Enforce to have the onClick mouse event with the onKeyUp, the onKeyDown, or the onKeyPress keyboard event. Actions triggered using mouse events should have corresponding keyboard events to account for keyboard-only navigation. (lint/a11y/useKeyWithClickEvents) |
||||||||||||||||||||||
); | ||||||||||||||||||||||
|
||||||||||||||||||||||
return ( | ||||||||||||||||||||||
<Fragment> | ||||||||||||||||||||||
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. Ensure proper keys for iterable fragments. - <Fragment>
+ <Fragment key={ci}>
🧰 Tools🪛 Biome (1.9.4)[error] 81-81: Missing key property for this element in iterable. The order of the items may change, and having a key can help React identify which item was moved. (lint/correctness/useJsxKeyInIterable) |
||||||||||||||||||||||
<li | ||||||||||||||||||||||
key={ci} | ||||||||||||||||||||||
style={props?.itemStyle} | ||||||||||||||||||||||
className="digit-bread-crumb--item" | ||||||||||||||||||||||
> | ||||||||||||||||||||||
{isLast(ci) || (!crumb?.internalLink && !crumb?.externalLink) ? ( | ||||||||||||||||||||||
<span | ||||||||||||||||||||||
className={`digit-bread-crumb-content ${isLast(ci) ? "current" : "default"}`} | ||||||||||||||||||||||
style={props?.spanStyle} | ||||||||||||||||||||||
onClick={(crumb.content === "..." || crumb.content === props?.expandText) ? handleCrumbClick : null} | ||||||||||||||||||||||
> | ||||||||||||||||||||||
{crumb?.icon && crumb.icon} | ||||||||||||||||||||||
{crumb.content} | ||||||||||||||||||||||
</span> | ||||||||||||||||||||||
Comment on lines
+88
to
+95
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 Handle keyboard events for the click action. - <span
- className={`digit-bread-crumb-content ${isLast(ci) ? "current" : "default"}`}
- style={props?.spanStyle}
- onClick={(crumb.content === "..." || crumb.content === props?.expandText) ? handleCrumbClick : null}
- >
+ <span
+ className={`digit-bread-crumb-content ${isLast(ci) ? "current" : "default"}`}
+ style={props?.spanStyle}
+ onClick={(crumb.content === "..." || crumb.content === props?.expandText) ? handleCrumbClick : null}
+ onKeyDown={(e) => {
+ if ((crumb.content === "..." || crumb.content === props?.expandText) && e.key === "Enter") {
+ handleCrumbClick();
+ }
+ }}
+ role="button"
+ tabIndex={0}
+ >
🧰 Tools🪛 Biome (1.9.4)[error] 88-92: Enforce to have the onClick mouse event with the onKeyUp, the onKeyDown, or the onKeyPress keyboard event. Actions triggered using mouse events should have corresponding keyboard events to account for keyboard-only navigation. (lint/a11y/useKeyWithClickEvents) |
||||||||||||||||||||||
) : crumb?.externalLink ? ( | ||||||||||||||||||||||
<Link | ||||||||||||||||||||||
className="digit-bread-crumb-content" | ||||||||||||||||||||||
onClick={() => handleRedirect(crumb?.externalLink)} | ||||||||||||||||||||||
> | ||||||||||||||||||||||
{crumb?.icon && crumb.icon} | ||||||||||||||||||||||
{crumb.content} | ||||||||||||||||||||||
</Link> | ||||||||||||||||||||||
) : ( | ||||||||||||||||||||||
<Link | ||||||||||||||||||||||
to={{ pathname: crumb.internalLink, state: { count: crumb?.count }, search: crumb?.query }} | ||||||||||||||||||||||
className={`digit-bread-crumb-content ${isLast(ci) ? "current" : "default"}`} | ||||||||||||||||||||||
> | ||||||||||||||||||||||
{crumb?.icon && crumb.icon} | ||||||||||||||||||||||
{crumb.content} | ||||||||||||||||||||||
</Link> | ||||||||||||||||||||||
)} | ||||||||||||||||||||||
{!isLast(ci) && ( | ||||||||||||||||||||||
<div className="digit-bread-crumb-seperator"> | ||||||||||||||||||||||
{props?.customSeparator ? props?.customSeparator : "/"} | ||||||||||||||||||||||
</div> | ||||||||||||||||||||||
)} | ||||||||||||||||||||||
</li> | ||||||||||||||||||||||
</Fragment> | ||||||||||||||||||||||
); | ||||||||||||||||||||||
})} | ||||||||||||||||||||||
</ol> | ||||||||||||||||||||||
); | ||||||||||||||||||||||
}; | ||||||||||||||||||||||
|
||||||||||||||||||||||
BreadCrumbs.propTypes = { | ||||||||||||||||||||||
crumbs: PropTypes.array, | ||||||||||||||||||||||
className: PropTypes.string, | ||||||||||||||||||||||
style: PropTypes.object, | ||||||||||||||||||||||
spanStyle: PropTypes.object, | ||||||||||||||||||||||
customSeparator: PropTypes.element, | ||||||||||||||||||||||
maxItems: PropTypes.number, | ||||||||||||||||||||||
itemsAfterCollapse: PropTypes.number, | ||||||||||||||||||||||
itemsBeforeCollapse: PropTypes.number, | ||||||||||||||||||||||
expandText: PropTypes.string | ||||||||||||||||||||||
}; | ||||||||||||||||||||||
|
||||||||||||||||||||||
BreadCrumbs.defaultProps = { | ||||||||||||||||||||||
successful: true, | ||||||||||||||||||||||
}; | ||||||||||||||||||||||
|
||||||||||||||||||||||
export default BreadCrumbs; |
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)
Remove unused import
useState
is not used anywhere in this component. Consider removing it to keep your imports concise.