@finos/legend-application-marketplace 0.1.55 → 0.1.57

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 (74) hide show
  1. package/lib/__lib__/LegendMarketplaceAppEvent.d.ts +1 -0
  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/__lib__/LegendMarketplaceNavigation.d.ts +9 -2
  6. package/lib/__lib__/LegendMarketplaceNavigation.d.ts.map +1 -1
  7. package/lib/__lib__/LegendMarketplaceNavigation.js +7 -1
  8. package/lib/__lib__/LegendMarketplaceNavigation.js.map +1 -1
  9. package/lib/__lib__/LegendMarketplaceTelemetryHelper.d.ts +11 -1
  10. package/lib/__lib__/LegendMarketplaceTelemetryHelper.d.ts.map +1 -1
  11. package/lib/__lib__/LegendMarketplaceTelemetryHelper.js +57 -3
  12. package/lib/__lib__/LegendMarketplaceTelemetryHelper.js.map +1 -1
  13. package/lib/application/LegendMarketplaceWebApplication.d.ts.map +1 -1
  14. package/lib/application/LegendMarketplaceWebApplication.js +4 -1
  15. package/lib/application/LegendMarketplaceWebApplication.js.map +1 -1
  16. package/lib/components/Header/LegendMarketplaceIconToolbar.d.ts.map +1 -1
  17. package/lib/components/Header/LegendMarketplaceIconToolbar.js +11 -2
  18. package/lib/components/Header/LegendMarketplaceIconToolbar.js.map +1 -1
  19. package/lib/components/SearchBar/LegendMarketplaceSearchBar.d.ts.map +1 -1
  20. package/lib/components/SearchBar/LegendMarketplaceSearchBar.js +4 -0
  21. package/lib/components/SearchBar/LegendMarketplaceSearchBar.js.map +1 -1
  22. package/lib/index.css +2 -2
  23. package/lib/index.css.map +1 -1
  24. package/lib/package.json +1 -1
  25. package/lib/pages/Lakehouse/MarketplaceLakehouseHome.d.ts.map +1 -1
  26. package/lib/pages/Lakehouse/MarketplaceLakehouseHome.js +5 -19
  27. package/lib/pages/Lakehouse/MarketplaceLakehouseHome.js.map +1 -1
  28. package/lib/pages/Lakehouse/admin/LakehouseAdminContractsDashboard.js +2 -2
  29. package/lib/pages/Lakehouse/admin/LakehouseAdminContractsDashboard.js.map +1 -1
  30. package/lib/pages/Lakehouse/entitlements/EntitlementsClosedContractsDashboard.d.ts.map +1 -1
  31. package/lib/pages/Lakehouse/entitlements/EntitlementsClosedContractsDashboard.js +38 -132
  32. package/lib/pages/Lakehouse/entitlements/EntitlementsClosedContractsDashboard.js.map +1 -1
  33. package/lib/pages/Lakehouse/entitlements/EntitlementsPendingContractsDashboard.d.ts.map +1 -1
  34. package/lib/pages/Lakehouse/entitlements/EntitlementsPendingContractsDashboard.js +36 -160
  35. package/lib/pages/Lakehouse/entitlements/EntitlementsPendingContractsDashboard.js.map +1 -1
  36. package/lib/pages/Lakehouse/entitlements/EntitlementsPendingTasksDashboard.d.ts.map +1 -1
  37. package/lib/pages/Lakehouse/entitlements/EntitlementsPendingTasksDashboard.js +60 -40
  38. package/lib/pages/Lakehouse/entitlements/EntitlementsPendingTasksDashboard.js.map +1 -1
  39. package/lib/pages/Lakehouse/entitlements/LakehouseDataContract.d.ts +17 -0
  40. package/lib/pages/Lakehouse/entitlements/LakehouseDataContract.d.ts.map +1 -0
  41. package/lib/pages/Lakehouse/entitlements/LakehouseDataContract.js +124 -0
  42. package/lib/pages/Lakehouse/entitlements/LakehouseDataContract.js.map +1 -0
  43. package/lib/stores/lakehouse/LegendMarketplaceProductViewerStore.js +2 -2
  44. package/lib/stores/lakehouse/LegendMarketplaceProductViewerStore.js.map +1 -1
  45. package/lib/stores/lakehouse/entitlements/EntitlementsDashboardState.d.ts +22 -11
  46. package/lib/stores/lakehouse/entitlements/EntitlementsDashboardState.d.ts.map +1 -1
  47. package/lib/stores/lakehouse/entitlements/EntitlementsDashboardState.js +145 -74
  48. package/lib/stores/lakehouse/entitlements/EntitlementsDashboardState.js.map +1 -1
  49. package/lib/stores/orders/OrderHelpers.d.ts +1 -1
  50. package/lib/stores/orders/OrderHelpers.d.ts.map +1 -1
  51. package/lib/stores/orders/OrderHelpers.js +7 -6
  52. package/lib/stores/orders/OrderHelpers.js.map +1 -1
  53. package/lib/utils/EntitlementsUtils.d.ts +20 -0
  54. package/lib/utils/EntitlementsUtils.d.ts.map +1 -0
  55. package/lib/utils/EntitlementsUtils.js +107 -0
  56. package/lib/utils/EntitlementsUtils.js.map +1 -0
  57. package/package.json +10 -10
  58. package/src/__lib__/LegendMarketplaceAppEvent.ts +1 -0
  59. package/src/__lib__/LegendMarketplaceNavigation.ts +19 -3
  60. package/src/__lib__/LegendMarketplaceTelemetryHelper.ts +80 -4
  61. package/src/application/LegendMarketplaceWebApplication.tsx +15 -0
  62. package/src/components/Header/LegendMarketplaceIconToolbar.tsx +29 -0
  63. package/src/components/SearchBar/LegendMarketplaceSearchBar.tsx +7 -0
  64. package/src/pages/Lakehouse/MarketplaceLakehouseHome.tsx +4 -54
  65. package/src/pages/Lakehouse/admin/LakehouseAdminContractsDashboard.tsx +3 -3
  66. package/src/pages/Lakehouse/entitlements/EntitlementsClosedContractsDashboard.tsx +91 -244
  67. package/src/pages/Lakehouse/entitlements/EntitlementsPendingContractsDashboard.tsx +91 -298
  68. package/src/pages/Lakehouse/entitlements/EntitlementsPendingTasksDashboard.tsx +87 -52
  69. package/src/pages/Lakehouse/entitlements/LakehouseDataContract.tsx +284 -0
  70. package/src/stores/lakehouse/LegendMarketplaceProductViewerStore.ts +3 -3
  71. package/src/stores/lakehouse/entitlements/EntitlementsDashboardState.ts +234 -109
  72. package/src/stores/orders/OrderHelpers.ts +8 -7
  73. package/src/utils/EntitlementsUtils.tsx +207 -0
  74. package/tsconfig.json +2 -0
@@ -17,6 +17,7 @@
17
17
  import {
18
18
  ActionState,
19
19
  assertErrorThrown,
20
+ guaranteeNonNullable,
20
21
  isNonNullable,
21
22
  type GeneratorFn,
22
23
  type PlainObject,
@@ -24,34 +25,82 @@ import {
24
25
  import { deserialize } from 'serializr';
25
26
  import {
26
27
  type V1_ContractUserEventRecord,
28
+ type V1_DataContract,
29
+ type V1_EnrichedUserApprovalStatus,
27
30
  type V1_LiteDataContract,
28
- type V1_LiteDataContractsResponse,
29
31
  type V1_LiteDataContractWithUserStatus,
30
32
  type V1_PendingTasksResponse,
31
33
  type V1_TaskStatus,
32
34
  type V1_TaskStatusChangeResponse,
33
- type V1_UserPendingContractsRecord,
34
- type V1_UserPendingContractsResponse,
35
- V1_liteDataContractsResponseModelSchemaToContracts,
35
+ V1_dataContractsResponseModelSchema,
36
36
  V1_liteDataContractWithUserStatusModelSchema,
37
37
  V1_pendingTasksResponseModelSchema,
38
38
  V1_TaskStatusChangeResponseModelSchema,
39
+ V1_transformDataContractToLiteDatacontract,
39
40
  } from '@finos/legend-graph';
40
- import { makeObservable, flow, observable, action, flowResult } from 'mobx';
41
+ import {
42
+ makeObservable,
43
+ flow,
44
+ observable,
45
+ flowResult,
46
+ action,
47
+ computed,
48
+ } from 'mobx';
41
49
  import {
42
50
  TEST_USER,
43
- TEST_USER2,
44
51
  type LakehouseEntitlementsStore,
45
52
  } from './LakehouseEntitlementsStore.js';
46
53
 
54
+ export class ContractCreatedByUserDetails {
55
+ readonly contractResultLite: V1_LiteDataContract;
56
+ assignees: Set<string> = new Set();
57
+ members: Map<string, V1_EnrichedUserApprovalStatus> = new Map();
58
+
59
+ constructor(contract: V1_LiteDataContract) {
60
+ this.contractResultLite = contract;
61
+
62
+ makeObservable(this, {
63
+ assignees: observable,
64
+ members: observable,
65
+ sortedAssigneeIds: computed,
66
+ sortedMemberIds: computed,
67
+ addAssignees: action,
68
+ addMember: action,
69
+ });
70
+ }
71
+
72
+ get sortedAssigneeIds(): string[] {
73
+ return Array.from(this.assignees).toSorted();
74
+ }
75
+
76
+ get sortedMemberIds(): string[] {
77
+ return Array.from(this.members.keys()).toSorted();
78
+ }
79
+
80
+ addAssignees(assignees: string[]): void {
81
+ assignees.forEach((assignee) => this.assignees.add(assignee));
82
+ }
83
+
84
+ addMember(id: string, status: V1_EnrichedUserApprovalStatus): void {
85
+ this.members.set(id, status);
86
+ }
87
+ }
88
+
47
89
  export class EntitlementsDashboardState {
48
90
  readonly lakehouseEntitlementsStore: LakehouseEntitlementsStore;
49
91
  pendingTasks: V1_ContractUserEventRecord[] | undefined;
50
- pendingContracts: V1_UserPendingContractsRecord[] | undefined;
51
- allContracts: V1_LiteDataContract[] | undefined;
52
- myContracts: V1_LiteDataContractWithUserStatus[] | undefined;
92
+ pendingTaskContractMap: Map<string, V1_LiteDataContract> = new Map();
93
+ allContractsForUser: V1_LiteDataContractWithUserStatus[] | undefined;
94
+ // The contracts createdBy user API returns an entry for each task, not just for each contract.
95
+ // To consolidate this information, we store a map of contract ID to the contract details + the
96
+ // consolidated user information from the tasks.
97
+ allContractsCreatedByUserMap: Map<string, ContractCreatedByUserDetails> =
98
+ new Map();
53
99
 
54
100
  readonly initializationState = ActionState.create();
101
+ readonly fetchingPendingTasksState = ActionState.create();
102
+ readonly fetchingContractsForUserState = ActionState.create();
103
+ readonly fetchingContractsByUserState = ActionState.create();
55
104
  readonly changingState = ActionState.create();
56
105
 
57
106
  constructor(state: LakehouseEntitlementsStore) {
@@ -59,38 +108,52 @@ export class EntitlementsDashboardState {
59
108
 
60
109
  makeObservable(this, {
61
110
  pendingTasks: observable,
62
- pendingContracts: observable,
63
- allContracts: observable,
64
- myContracts: observable,
65
- setPendingTasks: action,
66
- setPendingContracts: action,
67
- setAllContracts: action,
68
- setMyContracts: action,
111
+ allContractsForUser: observable,
112
+ allContractsCreatedByUserMap: observable,
113
+ pendingTaskContractMap: observable,
114
+ pendingTaskContracts: computed,
115
+ allContractsCreatedByUser: computed,
116
+ init: flow,
69
117
  approve: flow,
70
- fetchPendingContracts: flow,
118
+ deny: flow,
71
119
  fetchPendingTasks: flow,
72
- fetchAllContracts: flow,
73
- fetchMyContracts: flow,
120
+ fetchPendingTaskContracts: flow,
121
+ fetchContractsForUser: flow,
122
+ fetchContractsCreatedByUser: flow,
74
123
  updateContract: flow,
75
- init: flow,
76
- deny: flow,
77
124
  });
78
125
  }
79
126
 
127
+ get pendingTaskContracts(): V1_LiteDataContract[] {
128
+ return Array.from(this.pendingTaskContractMap.values());
129
+ }
130
+
131
+ get allContractsCreatedByUser(): ContractCreatedByUserDetails[] {
132
+ return Array.from(this.allContractsCreatedByUserMap.values());
133
+ }
134
+
80
135
  *init(token: string | undefined): GeneratorFn<void> {
81
136
  this.initializationState.inProgress();
82
137
  try {
83
138
  yield Promise.all([
84
- flowResult(this.fetchPendingTasks(token)).catch(
139
+ (async () => {
140
+ this.fetchingPendingTasksState.inProgress();
141
+ try {
142
+ await flowResult(this.fetchPendingTasks(token));
143
+ await flowResult(this.fetchPendingTaskContracts(token));
144
+ } catch (error) {
145
+ assertErrorThrown(error);
146
+ this.lakehouseEntitlementsStore.applicationStore.alertUnhandledError(
147
+ error,
148
+ );
149
+ } finally {
150
+ this.fetchingPendingTasksState.complete();
151
+ }
152
+ })(),
153
+ flowResult(this.fetchContractsForUser(token)).catch(
85
154
  this.lakehouseEntitlementsStore.applicationStore.alertUnhandledError,
86
155
  ),
87
- flowResult(this.fetchPendingContracts(token)).catch(
88
- this.lakehouseEntitlementsStore.applicationStore.alertUnhandledError,
89
- ),
90
- flowResult(this.fetchAllContracts(token)).catch(
91
- this.lakehouseEntitlementsStore.applicationStore.alertUnhandledError,
92
- ),
93
- flowResult(this.fetchMyContracts(token)).catch(
156
+ flowResult(this.fetchContractsCreatedByUser(token)).catch(
94
157
  this.lakehouseEntitlementsStore.applicationStore.alertUnhandledError,
95
158
  ),
96
159
  ]);
@@ -104,33 +167,16 @@ export class EntitlementsDashboardState {
104
167
  }
105
168
  }
106
169
 
107
- *fetchPendingContracts(token: string | undefined): GeneratorFn<void> {
108
- try {
109
- this.setPendingContracts(undefined);
110
- const pendingContracts =
111
- (yield this.lakehouseEntitlementsStore.lakehouseContractServerClient.getPendingContracts(
112
- TEST_USER2,
113
- token,
114
- )) as V1_UserPendingContractsResponse;
115
- this.setPendingContracts(pendingContracts.records ?? []);
116
- } catch (error) {
117
- assertErrorThrown(error);
118
- this.lakehouseEntitlementsStore.applicationStore.notificationService.notifyError(
119
- `Error fetching pending contracts: ${error.message}`,
120
- );
121
- }
122
- }
123
-
124
170
  *fetchPendingTasks(token: string | undefined): GeneratorFn<void> {
125
171
  try {
126
- this.setPendingTasks(undefined);
172
+ this.pendingTasks = undefined;
127
173
  const rawTasks =
128
174
  (yield this.lakehouseEntitlementsStore.lakehouseContractServerClient.getPendingTasks(
129
175
  TEST_USER,
130
176
  token,
131
177
  )) as PlainObject<V1_PendingTasksResponse>;
132
178
  const tasks = deserialize(V1_pendingTasksResponseModelSchema, rawTasks);
133
- this.setPendingTasks([...tasks.dataOwner, ...tasks.privilegeManager]);
179
+ this.pendingTasks = [...tasks.dataOwner, ...tasks.privilegeManager];
134
180
  } catch (error) {
135
181
  assertErrorThrown(error);
136
182
  this.lakehouseEntitlementsStore.applicationStore.notificationService.notifyError(
@@ -139,31 +185,74 @@ export class EntitlementsDashboardState {
139
185
  }
140
186
  }
141
187
 
142
- *fetchAllContracts(token: string | undefined): GeneratorFn<void> {
188
+ *fetchPendingTaskContracts(token: string | undefined): GeneratorFn<void> {
189
+ const pendingTaskContractIds = Array.from(
190
+ new Set(this.pendingTasks?.map((t) => t.dataContractId) ?? []),
191
+ );
192
+ const pendingTaskContracts = (
193
+ (yield Promise.all(
194
+ pendingTaskContractIds.map(async (contractId) => {
195
+ const rawContractResponse =
196
+ await this.lakehouseEntitlementsStore.lakehouseContractServerClient.getDataContract(
197
+ contractId,
198
+ false,
199
+ token,
200
+ );
201
+ const contractResponse = deserialize(
202
+ V1_dataContractsResponseModelSchema(
203
+ this.lakehouseEntitlementsStore.applicationStore.pluginManager.getPureProtocolProcessorPlugins(),
204
+ ),
205
+ rawContractResponse,
206
+ );
207
+ return contractResponse.dataContracts?.[0]?.dataContract;
208
+ }),
209
+ )) as (V1_DataContract | undefined)[]
210
+ )
211
+ .filter(isNonNullable)
212
+ .map(V1_transformDataContractToLiteDatacontract);
213
+ pendingTaskContractIds.forEach((contractId) => {
214
+ const contract = pendingTaskContracts.find((c) => c.guid === contractId);
215
+ if (contract) {
216
+ this.pendingTaskContractMap.set(contractId, contract);
217
+ }
218
+ });
219
+ }
220
+
221
+ *fetchContractsForUser(token: string | undefined): GeneratorFn<void> {
222
+ this.fetchingContractsForUserState.inProgress();
143
223
  try {
144
- this.setAllContracts(undefined);
224
+ this.allContractsForUser = undefined;
145
225
  const rawContracts =
146
- (yield this.lakehouseEntitlementsStore.lakehouseContractServerClient.getLiteDataContracts(
226
+ (yield this.lakehouseEntitlementsStore.lakehouseContractServerClient.getContractsForUser(
227
+ this.lakehouseEntitlementsStore.applicationStore.identityService
228
+ .currentUser,
147
229
  token,
148
- )) as PlainObject<V1_LiteDataContractsResponse>;
149
- const contracts = V1_liteDataContractsResponseModelSchemaToContracts(
150
- rawContracts,
151
- this.lakehouseEntitlementsStore.applicationStore.pluginManager.getPureProtocolProcessorPlugins(),
230
+ )) as PlainObject<V1_LiteDataContractWithUserStatus>[];
231
+ const contracts = rawContracts.map((rawContract) =>
232
+ deserialize(
233
+ V1_liteDataContractWithUserStatusModelSchema(
234
+ this.lakehouseEntitlementsStore.applicationStore.pluginManager.getPureProtocolProcessorPlugins(),
235
+ ),
236
+ rawContract,
237
+ ),
152
238
  );
153
- this.setAllContracts([...contracts]);
239
+ this.allContractsForUser = [...contracts];
154
240
  } catch (error) {
155
241
  assertErrorThrown(error);
156
242
  this.lakehouseEntitlementsStore.applicationStore.notificationService.notifyError(
157
- `Error fetching all data contracts: ${error.message}`,
243
+ `Error fetching data contracts for user: ${error.message}`,
158
244
  );
245
+ } finally {
246
+ this.fetchingContractsForUserState.complete();
159
247
  }
160
248
  }
161
249
 
162
- *fetchMyContracts(token: string | undefined): GeneratorFn<void> {
250
+ *fetchContractsCreatedByUser(token: string | undefined): GeneratorFn<void> {
251
+ this.fetchingContractsByUserState.inProgress();
163
252
  try {
164
- this.setMyContracts(undefined);
253
+ this.allContractsCreatedByUserMap = new Map();
165
254
  const rawContracts =
166
- (yield this.lakehouseEntitlementsStore.lakehouseContractServerClient.getContractsForUser(
255
+ (yield this.lakehouseEntitlementsStore.lakehouseContractServerClient.getContractsCreatedByUser(
167
256
  this.lakehouseEntitlementsStore.applicationStore.identityService
168
257
  .currentUser,
169
258
  token,
@@ -176,73 +265,109 @@ export class EntitlementsDashboardState {
176
265
  rawContract,
177
266
  ),
178
267
  );
179
- this.setMyContracts([...contracts]);
268
+ contracts.forEach((contract) => {
269
+ if (
270
+ !this.allContractsCreatedByUserMap.has(
271
+ contract.contractResultLite.guid,
272
+ )
273
+ ) {
274
+ this.allContractsCreatedByUserMap.set(
275
+ contract.contractResultLite.guid,
276
+ new ContractCreatedByUserDetails(contract.contractResultLite),
277
+ );
278
+ }
279
+ const entry = guaranteeNonNullable(
280
+ this.allContractsCreatedByUserMap.get(
281
+ contract.contractResultLite.guid,
282
+ ),
283
+ );
284
+ entry.addAssignees(contract.pendingTaskWithAssignees?.assignees ?? []);
285
+ entry.addMember(contract.user, contract.status);
286
+ });
180
287
  } catch (error) {
181
288
  assertErrorThrown(error);
182
289
  this.lakehouseEntitlementsStore.applicationStore.notificationService.notifyError(
183
- `Error fetching all data contracts: ${error.message}`,
290
+ `Error fetching data contracts created by user: ${error.message}`,
184
291
  );
292
+ } finally {
293
+ this.fetchingContractsByUserState.complete();
185
294
  }
186
295
  }
187
296
 
188
- setPendingTasks(val: V1_ContractUserEventRecord[] | undefined): void {
189
- this.pendingTasks = val;
190
- }
191
-
192
- setPendingContracts(val: V1_UserPendingContractsRecord[] | undefined): void {
193
- this.pendingContracts = val;
194
- }
195
-
196
- setAllContracts(val: V1_LiteDataContract[] | undefined): void {
197
- this.allContracts = val;
198
- }
199
-
200
- setMyContracts(val: V1_LiteDataContractWithUserStatus[] | undefined): void {
201
- this.myContracts = val;
202
- }
203
-
204
297
  *updateContract(
205
298
  contractId: string,
206
299
  token: string | undefined,
207
300
  ): GeneratorFn<void> {
208
- const [newPendingContracts, newAllContracts] = (yield Promise.all([
209
- (async () =>
210
- (
211
- await this.lakehouseEntitlementsStore.lakehouseContractServerClient.getPendingContracts(
212
- TEST_USER2,
301
+ const [newUserContracts, newCreatedByUserContracts] = (yield Promise.all([
302
+ (async () => {
303
+ const rawContracts =
304
+ await this.lakehouseEntitlementsStore.lakehouseContractServerClient.getContractsForUser(
305
+ this.lakehouseEntitlementsStore.applicationStore.identityService
306
+ .currentUser,
213
307
  token,
214
- )
215
- ).records ?? [])(),
308
+ );
309
+ return rawContracts.map((rawContract) =>
310
+ deserialize(
311
+ V1_liteDataContractWithUserStatusModelSchema(
312
+ this.lakehouseEntitlementsStore.applicationStore.pluginManager.getPureProtocolProcessorPlugins(),
313
+ ),
314
+ rawContract,
315
+ ),
316
+ );
317
+ })(),
216
318
  (async () => {
217
319
  const rawContracts =
218
- await this.lakehouseEntitlementsStore.lakehouseContractServerClient.getLiteDataContracts(
320
+ await this.lakehouseEntitlementsStore.lakehouseContractServerClient.getContractsCreatedByUser(
321
+ this.lakehouseEntitlementsStore.applicationStore.identityService
322
+ .currentUser,
219
323
  token,
220
324
  );
221
- return V1_liteDataContractsResponseModelSchemaToContracts(
222
- rawContracts,
223
- this.lakehouseEntitlementsStore.applicationStore.pluginManager.getPureProtocolProcessorPlugins(),
325
+ return rawContracts.map((rawContract) =>
326
+ deserialize(
327
+ V1_liteDataContractWithUserStatusModelSchema(
328
+ this.lakehouseEntitlementsStore.applicationStore.pluginManager.getPureProtocolProcessorPlugins(),
329
+ ),
330
+ rawContract,
331
+ ),
224
332
  );
225
333
  })(),
226
- ])) as [V1_UserPendingContractsRecord[], V1_LiteDataContract[]];
334
+ ])) as [
335
+ V1_LiteDataContractWithUserStatus[],
336
+ V1_LiteDataContractWithUserStatus[],
337
+ ];
227
338
 
228
- this.setPendingContracts(
229
- this.pendingContracts
230
- ?.map((contract) =>
231
- contract.contractId === contractId
232
- ? newPendingContracts.find((c) => c.contractId === contractId)
233
- : contract,
234
- )
235
- .filter(isNonNullable),
236
- );
237
- this.setAllContracts(
238
- this.allContracts
239
- ?.map((contract) =>
240
- contract.guid === contractId
241
- ? newAllContracts.find((c) => c.guid === contractId)
242
- : contract,
243
- )
244
- .filter(isNonNullable),
339
+ // Update the contract for the user
340
+ this.allContractsForUser = this.allContractsForUser
341
+ ?.map((contract) =>
342
+ contract.contractResultLite.guid === contractId
343
+ ? newUserContracts.find(
344
+ (c) => c.contractResultLite.guid === contractId,
345
+ )
346
+ : contract,
347
+ )
348
+ .filter(isNonNullable);
349
+
350
+ // Update the contract + all related data for contract created by the user
351
+ this.allContractsCreatedByUserMap.delete(contractId);
352
+ const updatedCreatedByUserContracts = newCreatedByUserContracts.filter(
353
+ (c) => c.contractResultLite.guid === contractId,
245
354
  );
355
+
356
+ updatedCreatedByUserContracts.forEach((contract) => {
357
+ if (
358
+ !this.allContractsCreatedByUserMap.has(contract.contractResultLite.guid)
359
+ ) {
360
+ this.allContractsCreatedByUserMap.set(
361
+ contract.contractResultLite.guid,
362
+ new ContractCreatedByUserDetails(contract.contractResultLite),
363
+ );
364
+ }
365
+ const entry = guaranteeNonNullable(
366
+ this.allContractsCreatedByUserMap.get(contract.contractResultLite.guid),
367
+ );
368
+ entry.addAssignees(contract.pendingTaskWithAssignees?.assignees ?? []);
369
+ entry.addMember(contract.user, contract.status);
370
+ });
246
371
  }
247
372
 
248
373
  *approve(
@@ -267,7 +392,7 @@ export class EntitlementsDashboardState {
267
392
  );
268
393
  }
269
394
  task.status = change.status;
270
- this.setPendingTasks([...(this.pendingTasks ?? [])]);
395
+ this.pendingTasks = [...(this.pendingTasks ?? [])];
271
396
  this.lakehouseEntitlementsStore.applicationStore.notificationService.notifySuccess(
272
397
  `Task has been Approved`,
273
398
  );
@@ -305,7 +430,7 @@ export class EntitlementsDashboardState {
305
430
  );
306
431
  }
307
432
  task.status = change.status;
308
- this.setPendingTasks([...(this.pendingTasks ?? [])]);
433
+ this.pendingTasks = [...(this.pendingTasks ?? [])];
309
434
  this.lakehouseEntitlementsStore.applicationStore.notificationService.notifySuccess(
310
435
  `Task has been denied`,
311
436
  );
@@ -146,13 +146,14 @@ export const isStageRejected = (
146
146
  return false;
147
147
  };
148
148
 
149
- export const formatOrderDate = (dateString: string): string => {
150
- const date = new Date(dateString);
151
- return date.toLocaleDateString('en-US', {
152
- year: 'numeric',
153
- month: 'short',
154
- day: 'numeric',
155
- });
149
+ export const formatOrderDate = (dateString?: string): string | undefined => {
150
+ return dateString
151
+ ? new Date(dateString).toLocaleDateString('en-US', {
152
+ year: 'numeric',
153
+ month: 'short',
154
+ day: 'numeric',
155
+ })
156
+ : undefined;
156
157
  };
157
158
 
158
159
  export const formatTimestamp = (timestamp: string): string => {