amp-workflow-ui 0.1.27 → 0.1.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +128 -128
- package/dist/index.js +84 -64
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +28 -8
- package/dist/index.mjs.map +1 -1
- package/package.json +21 -2
package/README.md
CHANGED
|
@@ -1,128 +1,128 @@
|
|
|
1
|
-
# amp-workflow-ui
|
|
2
|
-
|
|
3
|
-
Reusable Approval Workflow UI components (DialogOpener, ApprovalWorkflow) for Ampersand portals. Components are decoupled from app internals and accept an injected API client and optional URL builder.
|
|
4
|
-
|
|
5
|
-
## Install
|
|
6
|
-
|
|
7
|
-
```bash
|
|
8
|
-
npm install amp-workflow-ui
|
|
9
|
-
# or
|
|
10
|
-
yarn add amp-workflow-ui
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
Peer dependencies required in host:
|
|
14
|
-
|
|
15
|
-
- react, react-dom (18.x)
|
|
16
|
-
- @mui/material, @mui/system, @mui/icons-material
|
|
17
|
-
- @emotion/react, @emotion/styled
|
|
18
|
-
- react-hot-toast
|
|
19
|
-
|
|
20
|
-
## Usage
|
|
21
|
-
|
|
22
|
-
### 1) Basic React usage
|
|
23
|
-
|
|
24
|
-
```tsx
|
|
25
|
-
import { DialogOpener } from 'amp-workflow-ui'
|
|
26
|
-
import axios from 'axios'
|
|
27
|
-
|
|
28
|
-
const api = {
|
|
29
|
-
get: (p: any) => axios({ method: 'GET', baseURL: 'https://api.example.com', url: p.url }),
|
|
30
|
-
post: (p: any) => axios({ method: 'POST', baseURL: 'https://api.example.com', url: p.url, data: p.data })
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
<DialogOpener
|
|
34
|
-
openDialog={open}
|
|
35
|
-
handleClose={() => setOpen(false)}
|
|
36
|
-
userInfoData={userInfo}
|
|
37
|
-
api={api}
|
|
38
|
-
// optional
|
|
39
|
-
urlBuilder={(moduleName, moduleId, ctx, referenceId) => `/${moduleName}/${moduleId}${referenceId ? `?ref=${referenceId}` : ''}`}
|
|
40
|
-
/>
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
Or render inline:
|
|
44
|
-
|
|
45
|
-
```tsx
|
|
46
|
-
import { ApprovalWorkflow } from 'amp-workflow-ui'
|
|
47
|
-
|
|
48
|
-
<ApprovalWorkflow userInfo={userInfo} api={api} />
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
Props overview:
|
|
52
|
-
- DialogOpener
|
|
53
|
-
- required: openDialog, userInfoData, api
|
|
54
|
-
- optional: handleClose, selectedWorkflowsList, urlBuilder, loadingComponent
|
|
55
|
-
- ApprovalWorkflow
|
|
56
|
-
- required: userInfo, api
|
|
57
|
-
- optional: selectedWorkflowsList, urlBuilder, loadingComponent
|
|
58
|
-
|
|
59
|
-
### 2) Next.js usage (recommended)
|
|
60
|
-
|
|
61
|
-
Next.js may SSR your imports by default. To ensure client-only execution and avoid Node ESM resolver issues, dynamically import the package in a client component:
|
|
62
|
-
|
|
63
|
-
```tsx
|
|
64
|
-
// app or pages client component
|
|
65
|
-
import React from 'react'
|
|
66
|
-
import dynamic from 'next/dynamic'
|
|
67
|
-
|
|
68
|
-
export const WorkflowDialog = dynamic(
|
|
69
|
-
async () => {
|
|
70
|
-
// Prefer the package root; if your environment errors on ESM resolution,
|
|
71
|
-
// fall back to the CJS build at /dist/index.cjs.js.
|
|
72
|
-
try {
|
|
73
|
-
const mod = await import('amp-workflow-ui')
|
|
74
|
-
return mod.DialogOpener
|
|
75
|
-
} catch {
|
|
76
|
-
const mod = await import('amp-workflow-ui/dist/index.cjs.js')
|
|
77
|
-
return mod.DialogOpener
|
|
78
|
-
}
|
|
79
|
-
},
|
|
80
|
-
{ ssr: false, loading: () => <div>Loading Approval Management...</div> }
|
|
81
|
-
)
|
|
82
|
-
```
|
|
83
|
-
|
|
84
|
-
If you still see “Directory import '@mui/material/Button' is not supported” during SSR, force the CJS build:
|
|
85
|
-
```tsx
|
|
86
|
-
const WorkflowDialog = dynamic(() => import('amp-workflow-ui/dist/index.cjs.js').then(m => m.DialogOpener), { ssr: false })
|
|
87
|
-
```
|
|
88
|
-
|
|
89
|
-
## Build (package maintainers)
|
|
90
|
-
|
|
91
|
-
```bash
|
|
92
|
-
npm run build
|
|
93
|
-
```
|
|
94
|
-
|
|
95
|
-
## Publish (package maintainers)
|
|
96
|
-
|
|
97
|
-
```bash
|
|
98
|
-
# 1) Ensure you are logged in and have publish rights
|
|
99
|
-
npm whoami || npm login
|
|
100
|
-
|
|
101
|
-
# 2) Bump version (semver)
|
|
102
|
-
npm version patch # or minor | major
|
|
103
|
-
|
|
104
|
-
# 3) Build
|
|
105
|
-
npm run build
|
|
106
|
-
|
|
107
|
-
# 4) Publish (public)
|
|
108
|
-
npm publish --access public
|
|
109
|
-
```
|
|
110
|
-
|
|
111
|
-
Notes:
|
|
112
|
-
- Do not publish pre-releases unless explicitly needed; otherwise npm requires --tag.
|
|
113
|
-
- If your org enforces 2FA for publish, complete the OTP step in your terminal.
|
|
114
|
-
- Keep peerDependencies in sync to avoid duplicate React/MUI bundles in hosts.
|
|
115
|
-
|
|
116
|
-
## Troubleshooting
|
|
117
|
-
|
|
118
|
-
- Error: Element type is invalid … got: object
|
|
119
|
-
- Ensure you are importing the React component (named export) and not the module object. When using dynamic(), return the component (e.g., m.DialogOpener).
|
|
120
|
-
|
|
121
|
-
- Error: Directory import '@mui/material/Button' is not supported resolving ES modules
|
|
122
|
-
- This comes from Node’s ESM resolver during SSR. Use dynamic import with ssr: false or import the CJS build: `amp-workflow-ui/dist/index.cjs.js`.
|
|
123
|
-
|
|
124
|
-
## License
|
|
125
|
-
|
|
126
|
-
MIT
|
|
127
|
-
|
|
128
|
-
|
|
1
|
+
# amp-workflow-ui
|
|
2
|
+
|
|
3
|
+
Reusable Approval Workflow UI components (DialogOpener, ApprovalWorkflow) for Ampersand portals. Components are decoupled from app internals and accept an injected API client and optional URL builder.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install amp-workflow-ui
|
|
9
|
+
# or
|
|
10
|
+
yarn add amp-workflow-ui
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Peer dependencies required in host:
|
|
14
|
+
|
|
15
|
+
- react, react-dom (18.x)
|
|
16
|
+
- @mui/material, @mui/system, @mui/icons-material
|
|
17
|
+
- @emotion/react, @emotion/styled
|
|
18
|
+
- react-hot-toast
|
|
19
|
+
|
|
20
|
+
## Usage
|
|
21
|
+
|
|
22
|
+
### 1) Basic React usage
|
|
23
|
+
|
|
24
|
+
```tsx
|
|
25
|
+
import { DialogOpener } from 'amp-workflow-ui'
|
|
26
|
+
import axios from 'axios'
|
|
27
|
+
|
|
28
|
+
const api = {
|
|
29
|
+
get: (p: any) => axios({ method: 'GET', baseURL: 'https://api.example.com', url: p.url }),
|
|
30
|
+
post: (p: any) => axios({ method: 'POST', baseURL: 'https://api.example.com', url: p.url, data: p.data })
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
<DialogOpener
|
|
34
|
+
openDialog={open}
|
|
35
|
+
handleClose={() => setOpen(false)}
|
|
36
|
+
userInfoData={userInfo}
|
|
37
|
+
api={api}
|
|
38
|
+
// optional
|
|
39
|
+
urlBuilder={(moduleName, moduleId, ctx, referenceId) => `/${moduleName}/${moduleId}${referenceId ? `?ref=${referenceId}` : ''}`}
|
|
40
|
+
/>
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Or render inline:
|
|
44
|
+
|
|
45
|
+
```tsx
|
|
46
|
+
import { ApprovalWorkflow } from 'amp-workflow-ui'
|
|
47
|
+
|
|
48
|
+
<ApprovalWorkflow userInfo={userInfo} api={api} />
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Props overview:
|
|
52
|
+
- DialogOpener
|
|
53
|
+
- required: openDialog, userInfoData, api
|
|
54
|
+
- optional: handleClose, selectedWorkflowsList, urlBuilder, loadingComponent
|
|
55
|
+
- ApprovalWorkflow
|
|
56
|
+
- required: userInfo, api
|
|
57
|
+
- optional: selectedWorkflowsList, urlBuilder, loadingComponent
|
|
58
|
+
|
|
59
|
+
### 2) Next.js usage (recommended)
|
|
60
|
+
|
|
61
|
+
Next.js may SSR your imports by default. To ensure client-only execution and avoid Node ESM resolver issues, dynamically import the package in a client component:
|
|
62
|
+
|
|
63
|
+
```tsx
|
|
64
|
+
// app or pages client component
|
|
65
|
+
import React from 'react'
|
|
66
|
+
import dynamic from 'next/dynamic'
|
|
67
|
+
|
|
68
|
+
export const WorkflowDialog = dynamic(
|
|
69
|
+
async () => {
|
|
70
|
+
// Prefer the package root; if your environment errors on ESM resolution,
|
|
71
|
+
// fall back to the CJS build at /dist/index.cjs.js.
|
|
72
|
+
try {
|
|
73
|
+
const mod = await import('amp-workflow-ui')
|
|
74
|
+
return mod.DialogOpener
|
|
75
|
+
} catch {
|
|
76
|
+
const mod = await import('amp-workflow-ui/dist/index.cjs.js')
|
|
77
|
+
return mod.DialogOpener
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
{ ssr: false, loading: () => <div>Loading Approval Management...</div> }
|
|
81
|
+
)
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
If you still see “Directory import '@mui/material/Button' is not supported” during SSR, force the CJS build:
|
|
85
|
+
```tsx
|
|
86
|
+
const WorkflowDialog = dynamic(() => import('amp-workflow-ui/dist/index.cjs.js').then(m => m.DialogOpener), { ssr: false })
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
## Build (package maintainers)
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
npm run build
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
## Publish (package maintainers)
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
# 1) Ensure you are logged in and have publish rights
|
|
99
|
+
npm whoami || npm login
|
|
100
|
+
|
|
101
|
+
# 2) Bump version (semver)
|
|
102
|
+
npm version patch # or minor | major
|
|
103
|
+
|
|
104
|
+
# 3) Build
|
|
105
|
+
npm run build
|
|
106
|
+
|
|
107
|
+
# 4) Publish (public)
|
|
108
|
+
npm publish --access public
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
Notes:
|
|
112
|
+
- Do not publish pre-releases unless explicitly needed; otherwise npm requires --tag.
|
|
113
|
+
- If your org enforces 2FA for publish, complete the OTP step in your terminal.
|
|
114
|
+
- Keep peerDependencies in sync to avoid duplicate React/MUI bundles in hosts.
|
|
115
|
+
|
|
116
|
+
## Troubleshooting
|
|
117
|
+
|
|
118
|
+
- Error: Element type is invalid … got: object
|
|
119
|
+
- Ensure you are importing the React component (named export) and not the module object. When using dynamic(), return the component (e.g., m.DialogOpener).
|
|
120
|
+
|
|
121
|
+
- Error: Directory import '@mui/material/Button' is not supported resolving ES modules
|
|
122
|
+
- This comes from Node’s ESM resolver during SSR. Use dynamic import with ssr: false or import the CJS build: `amp-workflow-ui/dist/index.cjs.js`.
|
|
123
|
+
|
|
124
|
+
## License
|
|
125
|
+
|
|
126
|
+
MIT
|
|
127
|
+
|
|
128
|
+
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var React2 = require('react');
|
|
4
4
|
var jsxRuntime = require('react/jsx-runtime');
|
|
5
5
|
var Dialog = require('@mui/material/Dialog');
|
|
6
6
|
var useMediaQuery = require('@mui/material/useMediaQuery');
|
|
@@ -17,7 +17,7 @@ var KeyboardArrowDownIcon = require('@mui/icons-material/KeyboardArrowDown');
|
|
|
17
17
|
|
|
18
18
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
19
19
|
|
|
20
|
-
var
|
|
20
|
+
var React2__default = /*#__PURE__*/_interopDefault(React2);
|
|
21
21
|
var Dialog__default = /*#__PURE__*/_interopDefault(Dialog);
|
|
22
22
|
var useMediaQuery__default = /*#__PURE__*/_interopDefault(useMediaQuery);
|
|
23
23
|
var DialogActions6__default = /*#__PURE__*/_interopDefault(DialogActions6);
|
|
@@ -28,7 +28,7 @@ var CloseIcon__default = /*#__PURE__*/_interopDefault(CloseIcon);
|
|
|
28
28
|
var KeyboardArrowDownIcon__default = /*#__PURE__*/_interopDefault(KeyboardArrowDownIcon);
|
|
29
29
|
|
|
30
30
|
// src/context.tsx
|
|
31
|
-
var WorkflowContext =
|
|
31
|
+
var WorkflowContext = React2.createContext(null);
|
|
32
32
|
function WorkflowProvider({
|
|
33
33
|
value,
|
|
34
34
|
children
|
|
@@ -36,7 +36,7 @@ function WorkflowProvider({
|
|
|
36
36
|
return /* @__PURE__ */ jsxRuntime.jsx(WorkflowContext.Provider, { value, children });
|
|
37
37
|
}
|
|
38
38
|
function useWorkflowContext() {
|
|
39
|
-
const ctx =
|
|
39
|
+
const ctx = React2.useContext(WorkflowContext);
|
|
40
40
|
if (!ctx) {
|
|
41
41
|
throw new Error("useWorkflowContext must be used within WorkflowProvider");
|
|
42
42
|
}
|
|
@@ -437,7 +437,7 @@ function WorkflowRequestCard({
|
|
|
437
437
|
] }),
|
|
438
438
|
(_r = requestDetails == null ? void 0 : requestDetails.levels) == null ? void 0 : _r.map((_, idx) => {
|
|
439
439
|
const level = idx + 1;
|
|
440
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
440
|
+
return /* @__PURE__ */ jsxRuntime.jsx(React2__default.default.Fragment, { children: userLevel == "L" + level ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
441
441
|
/* @__PURE__ */ jsxRuntime.jsx(material.Chip, { label: "L" + level, className: "step-chip-current" }),
|
|
442
442
|
(requestDetails == null ? void 0 : requestDetails.levels.length) !== level && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "step-line step-line-inactive" })
|
|
443
443
|
] }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
@@ -653,14 +653,14 @@ function SendBackDialog({
|
|
|
653
653
|
onSuccess
|
|
654
654
|
}) {
|
|
655
655
|
const { userInfo, api } = useWorkflowContext();
|
|
656
|
-
const [comment, setComment] =
|
|
657
|
-
const [selectedFile, setSelectedFile] =
|
|
658
|
-
const [fileName, setFileName] =
|
|
659
|
-
const [error, setError] =
|
|
660
|
-
const [loading, setLoading] =
|
|
661
|
-
const [fileLoading, setFileLoading] =
|
|
662
|
-
const fileInputRef =
|
|
663
|
-
const [snackbar, setSnackbar] =
|
|
656
|
+
const [comment, setComment] = React2.useState("");
|
|
657
|
+
const [selectedFile, setSelectedFile] = React2.useState(null);
|
|
658
|
+
const [fileName, setFileName] = React2.useState("");
|
|
659
|
+
const [error, setError] = React2.useState({});
|
|
660
|
+
const [loading, setLoading] = React2.useState(false);
|
|
661
|
+
const [fileLoading, setFileLoading] = React2.useState(false);
|
|
662
|
+
const fileInputRef = React2.useRef(null);
|
|
663
|
+
const [snackbar, setSnackbar] = React2.useState({
|
|
664
664
|
open: false,
|
|
665
665
|
message: "",
|
|
666
666
|
severity: "success"
|
|
@@ -909,10 +909,10 @@ function ApproveDialog({
|
|
|
909
909
|
const { userInfo, api } = useWorkflowContext();
|
|
910
910
|
const theme = styles.useTheme();
|
|
911
911
|
useMediaQuery__default.default(theme.breakpoints.down("lg"));
|
|
912
|
-
const [comment, setComment] =
|
|
913
|
-
const [error, setError] =
|
|
914
|
-
const [loading, setLoading] =
|
|
915
|
-
const [snackbar, setSnackbar] =
|
|
912
|
+
const [comment, setComment] = React2.useState("");
|
|
913
|
+
const [error, setError] = React2.useState({});
|
|
914
|
+
const [loading, setLoading] = React2.useState(false);
|
|
915
|
+
const [snackbar, setSnackbar] = React2.useState({
|
|
916
916
|
open: false,
|
|
917
917
|
message: "",
|
|
918
918
|
severity: "success"
|
|
@@ -1089,18 +1089,18 @@ function RejectDialog({
|
|
|
1089
1089
|
}
|
|
1090
1090
|
);
|
|
1091
1091
|
};
|
|
1092
|
-
const [rejectReasons, setRejectReasons] =
|
|
1093
|
-
const [comment, setComment] =
|
|
1094
|
-
const [error, setError] =
|
|
1095
|
-
const [statusApplicableList, setStatusApplicableList] =
|
|
1096
|
-
const [loading, setLoading] =
|
|
1097
|
-
const [snackbar, setSnackbar] =
|
|
1092
|
+
const [rejectReasons, setRejectReasons] = React2.useState("");
|
|
1093
|
+
const [comment, setComment] = React2.useState("");
|
|
1094
|
+
const [error, setError] = React2.useState({ reason: "", comment: "" });
|
|
1095
|
+
const [statusApplicableList, setStatusApplicableList] = React2.useState([]);
|
|
1096
|
+
const [loading, setLoading] = React2.useState(false);
|
|
1097
|
+
const [snackbar, setSnackbar] = React2.useState({
|
|
1098
1098
|
open: false,
|
|
1099
1099
|
message: "",
|
|
1100
1100
|
severity: "success"
|
|
1101
1101
|
});
|
|
1102
1102
|
const handleCloseSnackbar = () => setSnackbar((prev) => ({ ...prev, open: false }));
|
|
1103
|
-
|
|
1103
|
+
React2.useEffect(() => {
|
|
1104
1104
|
(async () => {
|
|
1105
1105
|
var _a;
|
|
1106
1106
|
try {
|
|
@@ -1306,10 +1306,10 @@ function OnHoldDialog({
|
|
|
1306
1306
|
const { userInfo, api } = useWorkflowContext();
|
|
1307
1307
|
const theme = styles.useTheme();
|
|
1308
1308
|
useMediaQuery__default.default(theme.breakpoints.down("lg"));
|
|
1309
|
-
const [comment, setComment] =
|
|
1310
|
-
const [error, setError] =
|
|
1311
|
-
const [loading, setLoading] =
|
|
1312
|
-
const [snackbar, setSnackbar] =
|
|
1309
|
+
const [comment, setComment] = React2.useState("");
|
|
1310
|
+
const [error, setError] = React2.useState({ comment: "" });
|
|
1311
|
+
const [loading, setLoading] = React2.useState(false);
|
|
1312
|
+
const [snackbar, setSnackbar] = React2.useState({
|
|
1313
1313
|
open: false,
|
|
1314
1314
|
message: "",
|
|
1315
1315
|
severity: "success"
|
|
@@ -1458,8 +1458,8 @@ function OnHoldDialog({
|
|
|
1458
1458
|
}
|
|
1459
1459
|
var OnHoldDialog_default = OnHoldDialog;
|
|
1460
1460
|
var useDebounce = (value, delay) => {
|
|
1461
|
-
const [debouncedValue, setDebouncedValue] =
|
|
1462
|
-
|
|
1461
|
+
const [debouncedValue, setDebouncedValue] = React2.useState(value);
|
|
1462
|
+
React2.useEffect(() => {
|
|
1463
1463
|
const timeoutId = setTimeout(() => {
|
|
1464
1464
|
setDebouncedValue(value);
|
|
1465
1465
|
}, delay);
|
|
@@ -1553,15 +1553,15 @@ function FilterModal({
|
|
|
1553
1553
|
onApply
|
|
1554
1554
|
}) {
|
|
1555
1555
|
const { api } = useWorkflowContext();
|
|
1556
|
-
const [approvalType, setApprovalType] =
|
|
1556
|
+
const [approvalType, setApprovalType] = React2.useState(
|
|
1557
1557
|
(initialFilters == null ? void 0 : initialFilters.approvalType) || ""
|
|
1558
1558
|
);
|
|
1559
|
-
const [approvalStatus, setApprovalStatus] =
|
|
1559
|
+
const [approvalStatus, setApprovalStatus] = React2.useState(
|
|
1560
1560
|
(initialFilters == null ? void 0 : initialFilters.approvalStatus) || ""
|
|
1561
1561
|
);
|
|
1562
|
-
const [sortBy, setSortBy] =
|
|
1563
|
-
const [approvalTypeOptions, setApprovalTypeOptions] =
|
|
1564
|
-
|
|
1562
|
+
const [sortBy, setSortBy] = React2.useState((initialFilters == null ? void 0 : initialFilters.sortBy) || "");
|
|
1563
|
+
const [approvalTypeOptions, setApprovalTypeOptions] = React2.useState([]);
|
|
1564
|
+
React2.useEffect(() => {
|
|
1565
1565
|
api.get({ url: "/workflow/activities?page=1&size=1000", serviceURL: "api" }).then((res) => {
|
|
1566
1566
|
var _a;
|
|
1567
1567
|
console.log("\u{1F680} ~ FilterModal ~ res:", res);
|
|
@@ -1570,7 +1570,7 @@ function FilterModal({
|
|
|
1570
1570
|
console.error("Failed to fetch approval types:", err);
|
|
1571
1571
|
});
|
|
1572
1572
|
}, [api]);
|
|
1573
|
-
|
|
1573
|
+
React2.useEffect(() => {
|
|
1574
1574
|
if (open) {
|
|
1575
1575
|
setApprovalType((initialFilters == null ? void 0 : initialFilters.approvalType) || "");
|
|
1576
1576
|
setApprovalStatus((initialFilters == null ? void 0 : initialFilters.approvalStatus) || "");
|
|
@@ -1795,22 +1795,23 @@ function ApprovalWorkflow({
|
|
|
1795
1795
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s;
|
|
1796
1796
|
material.useTheme();
|
|
1797
1797
|
const { api, urlBuilder, loadingComponent, ENV_VARIABLES } = useWorkflowContext();
|
|
1798
|
-
const [selectedOption, setSelectedOption] =
|
|
1798
|
+
const [selectedOption, setSelectedOption] = React2.useState(
|
|
1799
1799
|
selectedWorkflowsList.length ? "selected" : "Assign To Me"
|
|
1800
1800
|
);
|
|
1801
1801
|
console.log("\u{1F680} ~ ApprovalWorkflow ~ selectedOption:", selectedOption);
|
|
1802
|
-
const [expandedId, setExpandedId] =
|
|
1803
|
-
const [sendDialog, setSendDialog] =
|
|
1804
|
-
const [approveTarget, setApproveTarget] =
|
|
1805
|
-
const [rejectTarget, setRejectTarget] =
|
|
1806
|
-
const [onHoldTarget, setOnHoldTarget] =
|
|
1807
|
-
const [expandedDetails, setExpandedDetails] =
|
|
1802
|
+
const [expandedId, setExpandedId] = React2.useState(null);
|
|
1803
|
+
const [sendDialog, setSendDialog] = React2.useState(null);
|
|
1804
|
+
const [approveTarget, setApproveTarget] = React2.useState(null);
|
|
1805
|
+
const [rejectTarget, setRejectTarget] = React2.useState(null);
|
|
1806
|
+
const [onHoldTarget, setOnHoldTarget] = React2.useState(null);
|
|
1807
|
+
const [expandedDetails, setExpandedDetails] = React2.useState([]);
|
|
1808
1808
|
console.log("\u{1F680} ~ ApprovalWorkflow ~ expandedDetails:", expandedDetails);
|
|
1809
|
-
const [descriptionView, setDescriptionView] =
|
|
1810
|
-
const [urlConfig, setUrlConfig] =
|
|
1811
|
-
const [viewMoreDetails, setViewMoreDetails] =
|
|
1812
|
-
const [isViewMoreOpen, setIsViewMoreOpen] =
|
|
1813
|
-
const [isFilterOpen, setIsFilterOpen] =
|
|
1809
|
+
const [descriptionView, setDescriptionView] = React2.useState(null);
|
|
1810
|
+
const [urlConfig, setUrlConfig] = React2.useState({});
|
|
1811
|
+
const [viewMoreDetails, setViewMoreDetails] = React2.useState(null);
|
|
1812
|
+
const [isViewMoreOpen, setIsViewMoreOpen] = React2.useState(false);
|
|
1813
|
+
const [isFilterOpen, setIsFilterOpen] = React2.useState(false);
|
|
1814
|
+
console.log("\u{1F680} ~ PIPELINE TEST");
|
|
1814
1815
|
const handleOpenViewMore = (details) => {
|
|
1815
1816
|
setViewMoreDetails(details);
|
|
1816
1817
|
setIsViewMoreOpen(true);
|
|
@@ -1819,7 +1820,7 @@ function ApprovalWorkflow({
|
|
|
1819
1820
|
setIsViewMoreOpen(false);
|
|
1820
1821
|
setViewMoreDetails(null);
|
|
1821
1822
|
};
|
|
1822
|
-
const [tabs, setTabs] =
|
|
1823
|
+
const [tabs, setTabs] = React2.useState({
|
|
1823
1824
|
"Assign To Me": {
|
|
1824
1825
|
data: [],
|
|
1825
1826
|
page: 1,
|
|
@@ -1858,13 +1859,13 @@ function ApprovalWorkflow({
|
|
|
1858
1859
|
}
|
|
1859
1860
|
});
|
|
1860
1861
|
console.log("\u{1F680} ~ ApprovalWorkflow ~ tabs set:", tabs);
|
|
1861
|
-
const [searchText, setSearchText] =
|
|
1862
|
+
const [searchText, setSearchText] = React2.useState("");
|
|
1862
1863
|
const debouncedSearchTerm = useDebounce_default(searchText, 500);
|
|
1863
|
-
|
|
1864
|
+
React2.useEffect(() => {
|
|
1864
1865
|
var _a2;
|
|
1865
1866
|
setSearchText(((_a2 = tabs[selectedOption]) == null ? void 0 : _a2.search) || "");
|
|
1866
1867
|
}, [selectedOption]);
|
|
1867
|
-
|
|
1868
|
+
React2.useEffect(() => {
|
|
1868
1869
|
var _a2, _b2;
|
|
1869
1870
|
if (debouncedSearchTerm !== tabs[selectedOption].search && ((_a2 = tabs[selectedOption]) == null ? void 0 : _a2.initialized)) {
|
|
1870
1871
|
setTabs((prev) => ({
|
|
@@ -1886,14 +1887,14 @@ function ApprovalWorkflow({
|
|
|
1886
1887
|
);
|
|
1887
1888
|
}
|
|
1888
1889
|
}, [debouncedSearchTerm]);
|
|
1889
|
-
const handleClearSearch =
|
|
1890
|
+
const handleClearSearch = React2.useCallback(() => {
|
|
1890
1891
|
setSearchText("");
|
|
1891
1892
|
}, []);
|
|
1892
|
-
const handleSearchChange =
|
|
1893
|
+
const handleSearchChange = React2.useCallback((value) => {
|
|
1893
1894
|
setSearchText(value);
|
|
1894
1895
|
}, []);
|
|
1895
|
-
const observer =
|
|
1896
|
-
const lastCardRef =
|
|
1896
|
+
const observer = React2.useRef(null);
|
|
1897
|
+
const lastCardRef = React2.useCallback(
|
|
1897
1898
|
(node) => {
|
|
1898
1899
|
const currentTab = tabs[selectedOption];
|
|
1899
1900
|
if ((currentTab == null ? void 0 : currentTab.loading) || !(currentTab == null ? void 0 : currentTab.hasMore)) return;
|
|
@@ -1913,6 +1914,24 @@ function ApprovalWorkflow({
|
|
|
1913
1914
|
},
|
|
1914
1915
|
[tabs, selectedOption]
|
|
1915
1916
|
);
|
|
1917
|
+
const scrollRef = React2.useRef(null);
|
|
1918
|
+
React2.useEffect(() => {
|
|
1919
|
+
const handleKeyDown = (e) => {
|
|
1920
|
+
var _a2, _b2, _c2, _d2;
|
|
1921
|
+
if (((_a2 = document.activeElement) == null ? void 0 : _a2.tagName) === "INPUT" || ((_b2 = document.activeElement) == null ? void 0 : _b2.tagName) === "TEXTAREA") {
|
|
1922
|
+
return;
|
|
1923
|
+
}
|
|
1924
|
+
if (e.key === "ArrowUp") {
|
|
1925
|
+
e.preventDefault();
|
|
1926
|
+
(_c2 = scrollRef.current) == null ? void 0 : _c2.scrollBy({ top: -100, behavior: "smooth" });
|
|
1927
|
+
} else if (e.key === "ArrowDown") {
|
|
1928
|
+
e.preventDefault();
|
|
1929
|
+
(_d2 = scrollRef.current) == null ? void 0 : _d2.scrollBy({ top: 100, behavior: "smooth" });
|
|
1930
|
+
}
|
|
1931
|
+
};
|
|
1932
|
+
window.addEventListener("keydown", handleKeyDown);
|
|
1933
|
+
return () => window.removeEventListener("keydown", handleKeyDown);
|
|
1934
|
+
}, []);
|
|
1916
1935
|
const handleSendBack = (workflowLogId) => {
|
|
1917
1936
|
setSendDialog(workflowLogId);
|
|
1918
1937
|
};
|
|
@@ -1945,7 +1964,7 @@ function ApprovalWorkflow({
|
|
|
1945
1964
|
return acc;
|
|
1946
1965
|
}, {});
|
|
1947
1966
|
};
|
|
1948
|
-
|
|
1967
|
+
React2.useEffect(() => {
|
|
1949
1968
|
api.get({
|
|
1950
1969
|
url: `/workflow/url-config`,
|
|
1951
1970
|
serviceURL: "api"
|
|
@@ -1953,7 +1972,7 @@ function ApprovalWorkflow({
|
|
|
1953
1972
|
setUrlConfig(formatDataUrlConfig(res == null ? void 0 : res.data));
|
|
1954
1973
|
});
|
|
1955
1974
|
}, []);
|
|
1956
|
-
const fetchData =
|
|
1975
|
+
const fetchData = React2.useCallback(
|
|
1957
1976
|
(tab, page, search, filtersOverride) => {
|
|
1958
1977
|
var _a2, _b2, _c2;
|
|
1959
1978
|
console.log("[DEBUG-FETCH-DATA] \u{1F3AF} fetchData called with:", {
|
|
@@ -2183,7 +2202,7 @@ function ApprovalWorkflow({
|
|
|
2183
2202
|
serviceURL: "api"
|
|
2184
2203
|
}).then((res) => setExpandedDetails(res == null ? void 0 : res.data));
|
|
2185
2204
|
};
|
|
2186
|
-
|
|
2205
|
+
React2.useEffect(() => {
|
|
2187
2206
|
var _a2;
|
|
2188
2207
|
console.log("[DEBUG-INIT] \u{1F680} Initial useEffect triggered");
|
|
2189
2208
|
console.log("[DEBUG-INIT] userInfo:", userInfo);
|
|
@@ -2207,13 +2226,13 @@ function ApprovalWorkflow({
|
|
|
2207
2226
|
console.log("[DEBUG-INIT] \u274C No userInfo.id, skipping initial fetch");
|
|
2208
2227
|
}
|
|
2209
2228
|
}, [userInfo]);
|
|
2210
|
-
|
|
2229
|
+
React2.useEffect(() => {
|
|
2211
2230
|
const tabState = tabs[selectedOption];
|
|
2212
2231
|
if ((tabState == null ? void 0 : tabState.page) > 1) {
|
|
2213
2232
|
fetchData(selectedOption, tabState.page, tabState.search);
|
|
2214
2233
|
}
|
|
2215
2234
|
}, [(_d = tabs[selectedOption]) == null ? void 0 : _d.page]);
|
|
2216
|
-
|
|
2235
|
+
React2.useEffect(() => {
|
|
2217
2236
|
var _a2;
|
|
2218
2237
|
if (Object.keys(urlConfig).length > 0 && userInfo && tabs && tabs["Assign To Me"] && !tabs["Assign To Me"].initialized) {
|
|
2219
2238
|
fetchData("Assign To Me", 1, ((_a2 = tabs["Assign To Me"]) == null ? void 0 : _a2.search) || "");
|
|
@@ -2391,6 +2410,7 @@ function ApprovalWorkflow({
|
|
|
2391
2410
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
2392
2411
|
system.Box,
|
|
2393
2412
|
{
|
|
2413
|
+
ref: scrollRef,
|
|
2394
2414
|
className: "fixedModal hide-scrollbar",
|
|
2395
2415
|
sx: {
|
|
2396
2416
|
overflowY: "auto",
|
|
@@ -2620,7 +2640,7 @@ function DialogOpener({
|
|
|
2620
2640
|
}) {
|
|
2621
2641
|
const theme = material.useTheme();
|
|
2622
2642
|
useMediaQuery__default.default(theme.breakpoints.down("lg"));
|
|
2623
|
-
const [screenWidth, setScreenWidth] =
|
|
2643
|
+
const [screenWidth, setScreenWidth] = React2.useState(
|
|
2624
2644
|
typeof window !== "undefined" ? window.innerWidth : 0
|
|
2625
2645
|
);
|
|
2626
2646
|
console.log("Dialog opener props", {
|
|
@@ -2629,7 +2649,7 @@ function DialogOpener({
|
|
|
2629
2649
|
userInfoData,
|
|
2630
2650
|
selectedWorkflowsList
|
|
2631
2651
|
});
|
|
2632
|
-
|
|
2652
|
+
React2.useEffect(() => {
|
|
2633
2653
|
const updateScreenWidth = () => setScreenWidth(window.innerWidth);
|
|
2634
2654
|
window.addEventListener("resize", updateScreenWidth);
|
|
2635
2655
|
return () => window.removeEventListener("resize", updateScreenWidth);
|
|
@@ -2734,7 +2754,7 @@ function ApprovalWorkflow2(props) {
|
|
|
2734
2754
|
ENV_VARIABLES,
|
|
2735
2755
|
...rest
|
|
2736
2756
|
} = props;
|
|
2737
|
-
console.log("\u{1F680} ~
|
|
2757
|
+
console.log("\u{1F680} ~ PIPELINE TEST");
|
|
2738
2758
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2739
2759
|
WorkflowProvider,
|
|
2740
2760
|
{
|