@truedat/dd 8.2.3 → 8.3.0
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/package.json +3 -3
- package/src/api.js +2 -0
- package/src/components/GrantRequestCartResult.js +132 -0
- package/src/components/GrantRoutes.js +5 -16
- package/src/components/StructureGrantCart.js +11 -6
- package/src/components/StructureGrantCartCheckout.js +357 -40
- package/src/components/StructureGrantCartInformation.js +6 -0
- package/src/components/StructureGrantCartUserSelector.js +23 -8
- package/src/components/__tests__/GrantRequestCartResult.spec.js +79 -0
- package/src/components/__tests__/StructureGrantCartCheckout.spec.js +110 -8
- package/src/components/__tests__/__snapshots__/GrantRequestCartResult.spec.js.snap +179 -0
- package/src/components/__tests__/__snapshots__/StructureGrantCartCheckout.spec.js.snap +294 -1
- package/src/hooks/useCheckoutGrantRequest.js +16 -0
- package/src/hooks/useGrantRequestGroupsByIds.js +22 -0
- package/src/hooks/useSystems.js +27 -0
- package/src/hooks/useTemplatesByIds.js +66 -0
- package/src/reducers/__tests__/grantRequestsCart.spec.js +70 -3
- package/src/reducers/grantRequestsCart.js +35 -1
- package/src/reducers/structureRedirect.js +11 -1
- package/src/routines.js +7 -0
- package/src/sagas/index.js +0 -3
- package/src/styles/grantCartUserSelector.less +3 -0
- package/src/sagas/operateGrantRequestCart.js +0 -26
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@truedat/dd",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.3.0",
|
|
4
4
|
"description": "Truedat Web Data Dictionary",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"module": "src/index.js",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"@testing-library/jest-dom": "^6.6.3",
|
|
49
49
|
"@testing-library/react": "^16.3.0",
|
|
50
50
|
"@testing-library/user-event": "^14.6.1",
|
|
51
|
-
"@truedat/test": "8.
|
|
51
|
+
"@truedat/test": "8.3.0",
|
|
52
52
|
"identity-obj-proxy": "^3.0.0",
|
|
53
53
|
"jest": "^29.7.0",
|
|
54
54
|
"redux-saga-test-plan": "^4.0.6"
|
|
@@ -83,5 +83,5 @@
|
|
|
83
83
|
"svg-pan-zoom": "^3.6.2",
|
|
84
84
|
"swr": "^2.3.3"
|
|
85
85
|
},
|
|
86
|
-
"gitHead": "
|
|
86
|
+
"gitHead": "d1abe685a3ae0cd2999e7bb62d3c0fd56522095f"
|
|
87
87
|
}
|
package/src/api.js
CHANGED
|
@@ -17,6 +17,7 @@ const API_GRANT_REQUEST = "/api/grant_requests/:id";
|
|
|
17
17
|
const API_GRANT_REQUEST_APPROVALS = "/api/grant_requests/:id/approvals";
|
|
18
18
|
const API_GRANT_REQUEST_STATUS = "/api/grant_requests/:id/status";
|
|
19
19
|
const API_GRANT_REQUEST_GROUP = "/api/grant_request_groups";
|
|
20
|
+
const API_GRANT_REQUEST_GROUPS_BULK = "/api/grant_request_groups/bulk";
|
|
20
21
|
const API_GRANT_REQUESTS = "/api/grant_requests";
|
|
21
22
|
const API_GRANT_REQUEST_BULK_APPROVAL = "/api/grant_requests/bulk_approval";
|
|
22
23
|
const API_GRANT_REQUESTS_SEARCH = "/api/grant_requests/search";
|
|
@@ -77,6 +78,7 @@ export {
|
|
|
77
78
|
API_GRANT_REQUEST_APPROVALS,
|
|
78
79
|
API_GRANT_REQUEST_STATUS,
|
|
79
80
|
API_GRANT_REQUEST_GROUP,
|
|
81
|
+
API_GRANT_REQUEST_GROUPS_BULK,
|
|
80
82
|
API_GRANT_REQUESTS,
|
|
81
83
|
API_GRANT_REQUESTS_SEARCH,
|
|
82
84
|
API_GRANT_REQUESTS_FILTERS_SEARCH,
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import _ from "lodash/fp";
|
|
2
|
+
import { useIntl, FormattedMessage } from "react-intl";
|
|
3
|
+
import { Link, useParams } from "react-router";
|
|
4
|
+
import { Message, List, Header, Segment, Button, Loader } from "semantic-ui-react";
|
|
5
|
+
import { linkTo } from "@truedat/core/routes";
|
|
6
|
+
import { MY_GRANT_REQUESTS } from "@truedat/core/routes";
|
|
7
|
+
import { useGrantRequestGroupsByIds } from "../hooks/useGrantRequestGroupsByIds";
|
|
8
|
+
|
|
9
|
+
const parseIdsFromPath = (idsParam) => {
|
|
10
|
+
if (!idsParam || typeof idsParam !== "string") return [];
|
|
11
|
+
return idsParam
|
|
12
|
+
.split("-")
|
|
13
|
+
.map((s) => parseInt(s.trim(), 10))
|
|
14
|
+
.filter((n) => !Number.isNaN(n));
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const getStructuresFromGroup = (group) => {
|
|
18
|
+
const requests = group._embedded?.requests ?? [];
|
|
19
|
+
const byId = new Map();
|
|
20
|
+
requests.forEach((req) => {
|
|
21
|
+
const ds = req._embedded?.data_structure;
|
|
22
|
+
if (ds?.id != null && !byId.has(ds.id)) byId.set(ds.id, ds);
|
|
23
|
+
});
|
|
24
|
+
return Array.from(byId.values());
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export const GrantRequestCartResult = () => {
|
|
28
|
+
const { ids: idsParam } = useParams();
|
|
29
|
+
const ids = parseIdsFromPath(idsParam);
|
|
30
|
+
const { groups, isLoading, error } = useGrantRequestGroupsByIds(ids);
|
|
31
|
+
const { formatMessage } = useIntl();
|
|
32
|
+
|
|
33
|
+
if (isLoading) {
|
|
34
|
+
return (
|
|
35
|
+
<Segment>
|
|
36
|
+
<Loader active inline="centered" />
|
|
37
|
+
</Segment>
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
if (_.isEmpty(ids) || _.isEmpty(groups)) {
|
|
42
|
+
return (
|
|
43
|
+
<Segment>
|
|
44
|
+
<Message info>
|
|
45
|
+
<Message.Header>
|
|
46
|
+
<FormattedMessage id="grantRequest.cart.result.empty" />
|
|
47
|
+
</Message.Header>
|
|
48
|
+
<Button as={Link} to={MY_GRANT_REQUESTS}>
|
|
49
|
+
<FormattedMessage id="grantRequest.cart.result.viewMyRequests" />
|
|
50
|
+
</Button>
|
|
51
|
+
</Message>
|
|
52
|
+
</Segment>
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
if (error) {
|
|
57
|
+
return (
|
|
58
|
+
<Segment>
|
|
59
|
+
<Message negative>
|
|
60
|
+
<Message.Header>
|
|
61
|
+
<FormattedMessage id="grantRequest.cart.result.error" defaultMessage="Error loading results" />
|
|
62
|
+
</Message.Header>
|
|
63
|
+
<Button as={Link} to={MY_GRANT_REQUESTS}>
|
|
64
|
+
<FormattedMessage id="grantRequest.cart.result.viewMyRequests" />
|
|
65
|
+
</Button>
|
|
66
|
+
</Message>
|
|
67
|
+
</Segment>
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return (
|
|
72
|
+
<Segment>
|
|
73
|
+
<Header as="h2">
|
|
74
|
+
<FormattedMessage id="grantRequest.cart.result.header" />
|
|
75
|
+
</Header>
|
|
76
|
+
<Message positive>
|
|
77
|
+
<Message.Header>
|
|
78
|
+
<FormattedMessage
|
|
79
|
+
id="grantRequest.cart.result.success"
|
|
80
|
+
values={{ count: groups.length }}
|
|
81
|
+
/>
|
|
82
|
+
</Message.Header>
|
|
83
|
+
</Message>
|
|
84
|
+
<List divided relaxed>
|
|
85
|
+
{groups.map((group) => {
|
|
86
|
+
const name =
|
|
87
|
+
group.type ||
|
|
88
|
+
formatMessage(
|
|
89
|
+
{ id: "grantRequest.cart.result.itemDefault" },
|
|
90
|
+
{ id: group.id }
|
|
91
|
+
);
|
|
92
|
+
const href = linkTo.GRANT_REQUEST_GROUP({ id: group.id });
|
|
93
|
+
const structures = getStructuresFromGroup(group);
|
|
94
|
+
return (
|
|
95
|
+
<List.Item key={group.id}>
|
|
96
|
+
<List.Content>
|
|
97
|
+
<List.Header as={Link} to={href}>
|
|
98
|
+
{name}
|
|
99
|
+
</List.Header>
|
|
100
|
+
<List.Description>
|
|
101
|
+
{structures.length > 0 && (
|
|
102
|
+
<>
|
|
103
|
+
<FormattedMessage
|
|
104
|
+
id="grantRequest.cart.result.structuresRequested"
|
|
105
|
+
defaultMessage="Structures requested"
|
|
106
|
+
/>
|
|
107
|
+
{": "}
|
|
108
|
+
<ul style={{ marginTop: "0.25em", marginBottom: 0 }}>
|
|
109
|
+
{structures.map((ds) => (
|
|
110
|
+
<li key={ds.id}>
|
|
111
|
+
<Link to={linkTo.STRUCTURE({ id: ds.id })}>
|
|
112
|
+
{ds.name ?? ds.external_id ?? ds.id}
|
|
113
|
+
</Link>
|
|
114
|
+
</li>
|
|
115
|
+
))}
|
|
116
|
+
</ul>
|
|
117
|
+
</>
|
|
118
|
+
)}
|
|
119
|
+
</List.Description>
|
|
120
|
+
</List.Content>
|
|
121
|
+
</List.Item>
|
|
122
|
+
);
|
|
123
|
+
})}
|
|
124
|
+
</List>
|
|
125
|
+
<Button as={Link} to={MY_GRANT_REQUESTS} primary>
|
|
126
|
+
<FormattedMessage id="grantRequest.cart.result.viewMyRequests" />
|
|
127
|
+
</Button>
|
|
128
|
+
</Segment>
|
|
129
|
+
);
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
export default GrantRequestCartResult;
|
|
@@ -4,22 +4,6 @@ import { Route, Routes } from "react-router";
|
|
|
4
4
|
import { useParams } from "react-router";
|
|
5
5
|
import PropTypes from "prop-types";
|
|
6
6
|
import { lazy } from "react";
|
|
7
|
-
import {
|
|
8
|
-
GRANT_APPROVAL_RULE,
|
|
9
|
-
GRANT_APPROVAL_RULE_EDIT,
|
|
10
|
-
GRANT_APPROVAL_RULE_NEW,
|
|
11
|
-
GRANT_REQUEST,
|
|
12
|
-
GRANT_REQUEST_GROUP,
|
|
13
|
-
GRANT_REQUESTS,
|
|
14
|
-
GRANT_REQUESTS_APPROVALS_RESULT,
|
|
15
|
-
GRANTS_REQUESTS_CHECKOUT,
|
|
16
|
-
GRANTS,
|
|
17
|
-
GRANT,
|
|
18
|
-
GRANT_APPROVAL_RULES,
|
|
19
|
-
MY_GRANT_REQUESTS,
|
|
20
|
-
MY_GRANTS,
|
|
21
|
-
STRUCTURES_GRANT_REQUEST,
|
|
22
|
-
} from "@truedat/core/routes";
|
|
23
7
|
|
|
24
8
|
import { SearchContextProvider } from "@truedat/core/search/SearchContext";
|
|
25
9
|
|
|
@@ -41,6 +25,7 @@ import GrantRequestApprovalResults from "./GrantRequestApprovalResults";
|
|
|
41
25
|
import Grants from "./Grants";
|
|
42
26
|
import MyGrantRequests from "./MyGrantRequests";
|
|
43
27
|
import StructureGrantCartCheckout from "./StructureGrantCartCheckout";
|
|
28
|
+
import GrantRequestCartResult from "./GrantRequestCartResult";
|
|
44
29
|
import StructuresGrantRequestView from "./StructuresGrantRequestView";
|
|
45
30
|
|
|
46
31
|
const TemplatesLoader = lazy(
|
|
@@ -73,6 +58,10 @@ export const GrantRoutes = ({ grantRequestLoaded }) => {
|
|
|
73
58
|
path="/grantsRequests/checkout"
|
|
74
59
|
element={<StructureGrantCartCheckout />}
|
|
75
60
|
/>
|
|
61
|
+
<Route
|
|
62
|
+
path="/grantsRequests/result/:ids?"
|
|
63
|
+
element={<GrantRequestCartResult />}
|
|
64
|
+
/>
|
|
76
65
|
<Route path="/grants/:id" element={<GrantView />} />
|
|
77
66
|
<Route
|
|
78
67
|
path="/grants"
|
|
@@ -41,17 +41,20 @@ export const StructureGrantCart = ({
|
|
|
41
41
|
updateGrantRequestFilter,
|
|
42
42
|
typeOperators,
|
|
43
43
|
allowEmptyCart,
|
|
44
|
+
structureRequestGroups,
|
|
44
45
|
}) => {
|
|
45
46
|
const { formatMessage } = useIntl();
|
|
46
47
|
const navigate = useNavigate();
|
|
47
48
|
const inCartCheckout = useLocation().pathname == GRANTS_REQUESTS_CHECKOUT;
|
|
48
49
|
const [openedStructureFilter, setOpenedStructureFilter] = useState();
|
|
49
|
-
const structures = _.
|
|
50
|
+
const structures = _.isArray(structureRequestGroups)
|
|
51
|
+
? structureRequestGroups
|
|
52
|
+
: _.pathOr([], "structures")(grantRequestsCart);
|
|
50
53
|
|
|
51
54
|
useEffect(() => {
|
|
52
55
|
if (_.isEmpty(structures) && !allowEmptyCart)
|
|
53
56
|
navigate(STRUCTURES_GRANT_REQUEST);
|
|
54
|
-
}, [
|
|
57
|
+
}, [navigate, structures, allowEmptyCart]);
|
|
55
58
|
|
|
56
59
|
const removeRequest = (structure) => () =>
|
|
57
60
|
removeGrantRequestFromCart(structure);
|
|
@@ -60,9 +63,9 @@ export const StructureGrantCart = ({
|
|
|
60
63
|
|
|
61
64
|
const setRowValue =
|
|
62
65
|
(structureId) =>
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
+
({ index, value }) => {
|
|
67
|
+
updateGrantRequestFilter({ index, value, structureId });
|
|
68
|
+
};
|
|
66
69
|
|
|
67
70
|
return (
|
|
68
71
|
<div className="ui segment structure-grant-cart">
|
|
@@ -76,7 +79,7 @@ export const StructureGrantCart = ({
|
|
|
76
79
|
key={`${s.id}`}
|
|
77
80
|
content={s.external_id}
|
|
78
81
|
trigger={
|
|
79
|
-
<Segment color={s
|
|
82
|
+
<Segment color={s?.id === structure?.id ? "blue" : null}>
|
|
80
83
|
<List.Item>
|
|
81
84
|
<List.Content>
|
|
82
85
|
<Grid verticalAlign="middle" columns="2">
|
|
@@ -129,6 +132,7 @@ export const StructureGrantCart = ({
|
|
|
129
132
|
))}
|
|
130
133
|
</List.List>
|
|
131
134
|
{!inCartCheckout &&
|
|
135
|
+
!structureRequestGroups &&
|
|
132
136
|
(_.isEmpty(grantRequestsCart?.structures) ? (
|
|
133
137
|
<p>
|
|
134
138
|
<FormattedMessage id={`structure.grant.cart.empty`} />
|
|
@@ -152,6 +156,7 @@ StructureGrantCart.propTypes = {
|
|
|
152
156
|
removeGrantRequestFromCart: PropTypes.func,
|
|
153
157
|
updateGrantRequestFilter: PropTypes.func,
|
|
154
158
|
allowEmptyCart: PropTypes.bool,
|
|
159
|
+
structureRequestGroups: PropTypes.array,
|
|
155
160
|
};
|
|
156
161
|
|
|
157
162
|
export const StructureGrantCartLoader = (props) => {
|