@finos/legend-application-marketplace 0.1.51 → 0.1.53

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.
Files changed (64) hide show
  1. package/lib/__lib__/LegendMarketplaceAppEvent.d.ts +2 -1
  2. package/lib/__lib__/LegendMarketplaceAppEvent.d.ts.map +1 -1
  3. package/lib/__lib__/LegendMarketplaceAppEvent.js +1 -0
  4. package/lib/__lib__/LegendMarketplaceAppEvent.js.map +1 -1
  5. package/lib/components/AddToCart/RecommendedAddOnsModal.d.ts.map +1 -1
  6. package/lib/components/AddToCart/RecommendedAddOnsModal.js +32 -6
  7. package/lib/components/AddToCart/RecommendedAddOnsModal.js.map +1 -1
  8. package/lib/components/AddToCart/RecommendedItemsCard.d.ts +0 -1
  9. package/lib/components/AddToCart/RecommendedItemsCard.d.ts.map +1 -1
  10. package/lib/components/AddToCart/RecommendedItemsCard.js +12 -17
  11. package/lib/components/AddToCart/RecommendedItemsCard.js.map +1 -1
  12. package/lib/components/Header/LegendMarketplaceAppInfo.d.ts.map +1 -1
  13. package/lib/components/Header/LegendMarketplaceAppInfo.js +55 -12
  14. package/lib/components/Header/LegendMarketplaceAppInfo.js.map +1 -1
  15. package/lib/components/ProviderCard/LegendMarketplaceTerminalCard.d.ts.map +1 -1
  16. package/lib/components/ProviderCard/LegendMarketplaceTerminalCard.js +2 -2
  17. package/lib/components/ProviderCard/LegendMarketplaceTerminalCard.js.map +1 -1
  18. package/lib/components/orders/CancelOrderDialog.d.ts +27 -0
  19. package/lib/components/orders/CancelOrderDialog.d.ts.map +1 -0
  20. package/lib/components/orders/CancelOrderDialog.js +52 -0
  21. package/lib/components/orders/CancelOrderDialog.js.map +1 -0
  22. package/lib/components/orders/ProgressTracker.d.ts +23 -0
  23. package/lib/components/orders/ProgressTracker.d.ts.map +1 -0
  24. package/lib/components/orders/ProgressTracker.js +116 -0
  25. package/lib/components/orders/ProgressTracker.js.map +1 -0
  26. package/lib/index.css +2 -2
  27. package/lib/index.css.map +1 -1
  28. package/lib/package.json +1 -1
  29. package/lib/pages/Profile/LegendMarketplaceYourOrders.d.ts.map +1 -1
  30. package/lib/pages/Profile/LegendMarketplaceYourOrders.js +43 -36
  31. package/lib/pages/Profile/LegendMarketplaceYourOrders.js.map +1 -1
  32. package/lib/pages/TerminalsAddons/LegendMarketplaceTerminalsAddons.d.ts.map +1 -1
  33. package/lib/pages/TerminalsAddons/LegendMarketplaceTerminalsAddons.js +42 -18
  34. package/lib/pages/TerminalsAddons/LegendMarketplaceTerminalsAddons.js.map +1 -1
  35. package/lib/stores/LegendMarketPlaceVendorDataStore.d.ts +10 -4
  36. package/lib/stores/LegendMarketPlaceVendorDataStore.d.ts.map +1 -1
  37. package/lib/stores/LegendMarketPlaceVendorDataStore.js +82 -49
  38. package/lib/stores/LegendMarketPlaceVendorDataStore.js.map +1 -1
  39. package/lib/stores/cart/CartStore.d.ts.map +1 -1
  40. package/lib/stores/cart/CartStore.js +2 -1
  41. package/lib/stores/cart/CartStore.js.map +1 -1
  42. package/lib/stores/orders/OrderHelpers.d.ts +49 -0
  43. package/lib/stores/orders/OrderHelpers.d.ts.map +1 -0
  44. package/lib/stores/orders/OrderHelpers.js +134 -0
  45. package/lib/stores/orders/OrderHelpers.js.map +1 -0
  46. package/lib/stores/orders/OrderStore.d.ts +2 -0
  47. package/lib/stores/orders/OrderStore.d.ts.map +1 -1
  48. package/lib/stores/orders/OrderStore.js +31 -0
  49. package/lib/stores/orders/OrderStore.js.map +1 -1
  50. package/package.json +13 -13
  51. package/src/__lib__/LegendMarketplaceAppEvent.ts +1 -0
  52. package/src/components/AddToCart/RecommendedAddOnsModal.tsx +145 -17
  53. package/src/components/AddToCart/RecommendedItemsCard.tsx +32 -62
  54. package/src/components/Header/LegendMarketplaceAppInfo.tsx +104 -53
  55. package/src/components/ProviderCard/LegendMarketplaceTerminalCard.tsx +18 -2
  56. package/src/components/orders/CancelOrderDialog.tsx +157 -0
  57. package/src/components/orders/ProgressTracker.tsx +266 -0
  58. package/src/pages/Profile/LegendMarketplaceYourOrders.tsx +227 -230
  59. package/src/pages/TerminalsAddons/LegendMarketplaceTerminalsAddons.tsx +140 -17
  60. package/src/stores/LegendMarketPlaceVendorDataStore.tsx +114 -84
  61. package/src/stores/cart/CartStore.ts +2 -1
  62. package/src/stores/orders/OrderHelpers.ts +167 -0
  63. package/src/stores/orders/OrderStore.ts +51 -0
  64. package/tsconfig.json +3 -0
@@ -0,0 +1,157 @@
1
+ /**
2
+ * Copyright (c) 2025-present, Goldman Sachs
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ import React, { useState } from 'react';
18
+ import { observer } from 'mobx-react-lite';
19
+ import { flowResult } from 'mobx';
20
+ import {
21
+ Dialog,
22
+ DialogTitle,
23
+ DialogContent,
24
+ DialogActions,
25
+ Button,
26
+ TextField,
27
+ Typography,
28
+ Box,
29
+ CircularProgress,
30
+ } from '@mui/material';
31
+ import { WarningIcon } from '@finos/legend-art';
32
+ import type { TerminalProductOrder } from '@finos/legend-server-marketplace';
33
+ import type { OrdersStore } from '../../stores/orders/OrderStore.js';
34
+ import { getProcessInstanceId } from '../../stores/orders/OrderHelpers.js';
35
+
36
+ interface CancelOrderDialogProps {
37
+ open: boolean;
38
+ onClose: () => void;
39
+ order: TerminalProductOrder;
40
+ orderStore: OrdersStore;
41
+ }
42
+
43
+ export const CancelOrderDialog: React.FC<CancelOrderDialogProps> = observer(
44
+ ({ open, onClose, order, orderStore }) => {
45
+ const [cancellationReason, setCancellationReason] = useState('');
46
+
47
+ const isLoading = orderStore.cancelOrderState.isInProgress;
48
+ const trimmedReason = cancellationReason.trim();
49
+ const isReasonValid = trimmedReason.length > 0;
50
+
51
+ const handleClose = (): void => {
52
+ if (!isLoading) {
53
+ setCancellationReason('');
54
+ onClose();
55
+ }
56
+ };
57
+
58
+ const handleConfirm = async (): Promise<void> => {
59
+ if (!isReasonValid) {
60
+ return;
61
+ }
62
+
63
+ const processInstanceId = getProcessInstanceId(order);
64
+ if (!processInstanceId) {
65
+ return;
66
+ }
67
+
68
+ const success = await flowResult(
69
+ orderStore.cancelOrder(
70
+ order.order_id,
71
+ processInstanceId,
72
+ trimmedReason,
73
+ ),
74
+ );
75
+ if (success) {
76
+ handleClose();
77
+ }
78
+ };
79
+
80
+ return (
81
+ <Dialog
82
+ open={open}
83
+ onClose={handleClose}
84
+ maxWidth="sm"
85
+ fullWidth={true}
86
+ className="legend-marketplace-cancel-order-dialog"
87
+ >
88
+ <DialogTitle>
89
+ <Box className="legend-marketplace-cancel-order-dialog__title">
90
+ <WarningIcon className="legend-marketplace-cancel-order-dialog__warning-icon" />
91
+ <Typography variant="h6">Cancel Order</Typography>
92
+ </Box>
93
+ </DialogTitle>
94
+
95
+ <DialogContent>
96
+ <Box className="legend-marketplace-cancel-order-dialog__content">
97
+ <Typography className="legend-marketplace-cancel-order-dialog__message">
98
+ Are you sure you want to cancel this order?
99
+ </Typography>
100
+
101
+ <Box className="legend-marketplace-cancel-order-dialog__order-info">
102
+ <Typography variant="body2">
103
+ <strong>Order ID:</strong> {order.order_id}
104
+ </Typography>
105
+ <Typography variant="body2">
106
+ <strong>Vendor:</strong> {order.vendor_name}
107
+ </Typography>
108
+ <Typography variant="body2">
109
+ <strong>Order Type:</strong> {order.order_type}
110
+ </Typography>
111
+ </Box>
112
+
113
+ <TextField
114
+ autoFocus={true}
115
+ margin="dense"
116
+ label="Cancellation Reason"
117
+ placeholder="Please provide a reason for canceling this order..."
118
+ fullWidth={true}
119
+ multiline={true}
120
+ rows={4}
121
+ value={cancellationReason}
122
+ onChange={(e) => setCancellationReason(e.target.value)}
123
+ disabled={isLoading}
124
+ required={true}
125
+ helperText="Required: Please explain why you are canceling this order"
126
+ error={cancellationReason.length > 0 && !isReasonValid}
127
+ className="legend-marketplace-cancel-order-dialog__text-field"
128
+ />
129
+ </Box>
130
+ </DialogContent>
131
+
132
+ <DialogActions className="legend-marketplace-cancel-order-dialog__actions">
133
+ <Button
134
+ onClick={handleClose}
135
+ disabled={isLoading}
136
+ variant="text"
137
+ color="inherit"
138
+ >
139
+ Cancel
140
+ </Button>
141
+ <Button
142
+ onClick={() => {
143
+ // eslint-disable-next-line no-void
144
+ void handleConfirm();
145
+ }}
146
+ disabled={isLoading || !isReasonValid}
147
+ variant="contained"
148
+ color="error"
149
+ startIcon={isLoading ? <CircularProgress size={16} /> : undefined}
150
+ >
151
+ {isLoading ? 'Canceling...' : 'Confirm Cancellation'}
152
+ </Button>
153
+ </DialogActions>
154
+ </Dialog>
155
+ );
156
+ },
157
+ );
@@ -0,0 +1,266 @@
1
+ /**
2
+ * Copyright (c) 2025-present, Goldman Sachs
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ import React from 'react';
18
+ import { observer } from 'mobx-react-lite';
19
+ import {
20
+ Box,
21
+ Typography,
22
+ Stepper,
23
+ Step,
24
+ StepLabel,
25
+ StepConnector,
26
+ stepConnectorClasses,
27
+ } from '@mui/material';
28
+ import { styled } from '@mui/material/styles';
29
+ import {
30
+ CheckCircleIcon,
31
+ CircleIcon,
32
+ TimesCircleIcon,
33
+ } from '@finos/legend-art';
34
+ import type { TerminalProductOrder } from '@finos/legend-server-marketplace';
35
+ import {
36
+ getWorkflowSteps,
37
+ STAGE_MAP,
38
+ isStageCompleted,
39
+ isStageRejected,
40
+ formatTimestamp,
41
+ WorkflowStage,
42
+ WorkflowStatus,
43
+ WorkflowCurrentStage,
44
+ } from '../../stores/orders/OrderHelpers.js';
45
+
46
+ interface ProgressTrackerProps {
47
+ order: TerminalProductOrder;
48
+ }
49
+
50
+ const CustomConnector = styled(StepConnector)(({ theme }) => ({
51
+ [`&.${stepConnectorClasses.alternativeLabel}`]: {
52
+ top: 10,
53
+ left: 'calc(-50% + 16px)',
54
+ right: 'calc(50% + 16px)',
55
+ },
56
+ [`&.${stepConnectorClasses.active}`]: {
57
+ [`& .${stepConnectorClasses.line}`]: {
58
+ borderColor: theme.palette.primary.main,
59
+ },
60
+ },
61
+ [`&.${stepConnectorClasses.completed}`]: {
62
+ [`& .${stepConnectorClasses.line}`]: {
63
+ borderColor: theme.palette.primary.main,
64
+ },
65
+ },
66
+ [`& .${stepConnectorClasses.line}`]: {
67
+ borderColor: theme.palette.grey[400],
68
+ borderTopWidth: 2,
69
+ borderRadius: 1,
70
+ },
71
+ }));
72
+
73
+ const StepIconComponent = (props: {
74
+ active: boolean;
75
+ completed: boolean;
76
+ rejected?: boolean;
77
+ }): React.ReactElement => {
78
+ const { active, completed, rejected } = props;
79
+
80
+ if (rejected) {
81
+ return (
82
+ <TimesCircleIcon className="legend-marketplace-progress-tracker__step-icon--rejected" />
83
+ );
84
+ }
85
+ if (completed) {
86
+ return (
87
+ <CheckCircleIcon className="legend-marketplace-progress-tracker__step-icon--completed" />
88
+ );
89
+ }
90
+ if (active) {
91
+ return (
92
+ <CircleIcon className="legend-marketplace-progress-tracker__step-icon--active" />
93
+ );
94
+ }
95
+ return (
96
+ <CircleIcon className="legend-marketplace-progress-tracker__step-icon--pending" />
97
+ );
98
+ };
99
+
100
+ export const ProgressTracker: React.FC<ProgressTrackerProps> = observer(
101
+ ({ order }) => {
102
+ const steps = getWorkflowSteps(order);
103
+ const currentStageName = order.workflow_details?.current_stage
104
+ ? STAGE_MAP[order.workflow_details.current_stage as WorkflowCurrentStage]
105
+ : WorkflowStage.ORDER_PLACED;
106
+
107
+ const currentStageIndex = steps.indexOf(currentStageName);
108
+ const activeStepIndex = currentStageIndex >= 0 ? currentStageIndex : 0;
109
+
110
+ const getFinalStepIndex = (): number => {
111
+ if (!order.workflow_details) {
112
+ return 0;
113
+ }
114
+
115
+ for (let i = steps.length - 1; i >= 0; i--) {
116
+ if (
117
+ isStageRejected(order, steps[i] ?? WorkflowStage.ORDER_PLACED) &&
118
+ isStageCompleted(order, steps[i] ?? WorkflowStage.ORDER_PLACED)
119
+ ) {
120
+ return i;
121
+ }
122
+ }
123
+
124
+ for (let i = steps.length - 1; i >= 0; i--) {
125
+ if (isStageCompleted(order, steps[i] ?? WorkflowStage.ORDER_PLACED)) {
126
+ return i;
127
+ }
128
+ }
129
+
130
+ if (
131
+ order.workflow_details.rpm_ticket_id &&
132
+ order.workflow_details.current_stage === WorkflowCurrentStage.RPM
133
+ ) {
134
+ return steps.indexOf(WorkflowStage.PENDING_FULFILLMENT);
135
+ }
136
+
137
+ return activeStepIndex;
138
+ };
139
+
140
+ const isClosedOrder =
141
+ order.workflow_details?.workflow_status.toString() ===
142
+ WorkflowStatus.COMPLETED;
143
+ const finalStepIndex = isClosedOrder
144
+ ? getFinalStepIndex()
145
+ : activeStepIndex;
146
+
147
+ return (
148
+ <Box className="legend-marketplace-progress-tracker">
149
+ <Stepper
150
+ alternativeLabel={true}
151
+ activeStep={finalStepIndex}
152
+ connector={<CustomConnector />}
153
+ >
154
+ {steps.map((label, index) => {
155
+ const isCompleted = isClosedOrder
156
+ ? index <= finalStepIndex
157
+ : index < activeStepIndex;
158
+ const isActive = !isClosedOrder && index === activeStepIndex;
159
+ const stageCompleted = isStageCompleted(order, label);
160
+ const rejected = isStageRejected(order, label);
161
+
162
+ return (
163
+ <Step key={label} completed={isCompleted && !rejected}>
164
+ <StepLabel
165
+ StepIconComponent={() =>
166
+ StepIconComponent({
167
+ active: isActive,
168
+ completed: isCompleted && !rejected,
169
+ rejected: rejected && isCompleted,
170
+ })
171
+ }
172
+ >
173
+ <Typography className="legend-marketplace-progress-tracker__step-label">
174
+ {label}
175
+ </Typography>
176
+
177
+ {label === WorkflowStage.MANAGER_APPROVAL &&
178
+ isCompleted &&
179
+ stageCompleted &&
180
+ order.workflow_details &&
181
+ !isActive && (
182
+ <Box className="legend-marketplace-progress-tracker__step-details">
183
+ {order.workflow_details.manager_actioned_by && (
184
+ <Typography className="legend-marketplace-progress-tracker__step-detail">
185
+ <strong>Actioned by:</strong>{' '}
186
+ {order.workflow_details.manager_actioned_by}
187
+ </Typography>
188
+ )}
189
+ {order.workflow_details.manager_actioned_timestamp && (
190
+ <Typography className="legend-marketplace-progress-tracker__step-detail">
191
+ <strong>Date:</strong>{' '}
192
+ {formatTimestamp(
193
+ order.workflow_details.manager_actioned_timestamp,
194
+ )}
195
+ </Typography>
196
+ )}
197
+ {order.workflow_details.manager_action && (
198
+ <Typography className="legend-marketplace-progress-tracker__step-detail">
199
+ <strong>Action:</strong>{' '}
200
+ {order.workflow_details.manager_action}
201
+ </Typography>
202
+ )}
203
+ {order.workflow_details.manager_comment && (
204
+ <Typography className="legend-marketplace-progress-tracker__step-detail">
205
+ <strong>Comments:</strong>{' '}
206
+ {order.workflow_details.manager_comment}
207
+ </Typography>
208
+ )}
209
+ </Box>
210
+ )}
211
+
212
+ {label === WorkflowStage.BUSINESS_ANALYST_APPROVAL &&
213
+ isCompleted &&
214
+ stageCompleted &&
215
+ order.workflow_details &&
216
+ !isActive && (
217
+ <Box className="legend-marketplace-progress-tracker__step-details">
218
+ {order.workflow_details.bbg_approval_actioned_by && (
219
+ <Typography className="legend-marketplace-progress-tracker__step-detail">
220
+ <strong>Actioned by:</strong>{' '}
221
+ {order.workflow_details.bbg_approval_actioned_by}
222
+ </Typography>
223
+ )}
224
+ {order.workflow_details
225
+ .bbg_approval_actioned_timestamp && (
226
+ <Typography className="legend-marketplace-progress-tracker__step-detail">
227
+ <strong>Date:</strong>{' '}
228
+ {formatTimestamp(
229
+ order.workflow_details
230
+ .bbg_approval_actioned_timestamp,
231
+ )}
232
+ </Typography>
233
+ )}
234
+ {order.workflow_details.bbg_approval_action && (
235
+ <Typography className="legend-marketplace-progress-tracker__step-detail">
236
+ <strong>Action:</strong>{' '}
237
+ {order.workflow_details.bbg_approval_action}
238
+ </Typography>
239
+ )}
240
+ {order.workflow_details.bbg_approval_comment && (
241
+ <Typography className="legend-marketplace-progress-tracker__step-detail">
242
+ <strong>Comments:</strong>{' '}
243
+ {order.workflow_details.bbg_approval_comment}
244
+ </Typography>
245
+ )}
246
+ </Box>
247
+ )}
248
+
249
+ {label === WorkflowStage.PENDING_FULFILLMENT &&
250
+ order.workflow_details?.rpm_ticket_id && (
251
+ <Box className="legend-marketplace-progress-tracker__step-details">
252
+ <Typography className="legend-marketplace-progress-tracker__step-detail">
253
+ <strong>RPM Ticket:</strong>{' '}
254
+ {order.workflow_details.rpm_ticket_id}
255
+ </Typography>
256
+ </Box>
257
+ )}
258
+ </StepLabel>
259
+ </Step>
260
+ );
261
+ })}
262
+ </Stepper>
263
+ </Box>
264
+ );
265
+ },
266
+ );