Skip to content

Commit 1aaa496

Browse files
committed
Add latest updated risk
Signed-off-by: Bryan Frimin <bryan@getprobo.com>
1 parent 9024f00 commit 1aaa496

File tree

1 file changed

+39
-22
lines changed

1 file changed

+39
-22
lines changed

apps/console/src/pages/organizations/risks/ShowRiskView.tsx

Lines changed: 39 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ const calculateRiskLevel = (score: number): string => {
217217

218218
// Helper function to get color for risk level that matches the matrix colors
219219
const getRiskLevelColor = (
220-
level: string,
220+
level: string
221221
): { backgroundColor: string; color: string } => {
222222
switch (level) {
223223
case "High":
@@ -349,7 +349,7 @@ function ShowRiskViewContent({
349349
}) {
350350
const data = usePreloadedQuery<ShowRiskViewQuery>(
351351
showRiskViewQuery,
352-
queryRef,
352+
queryRef
353353
);
354354
const { toast } = useToast();
355355
const environment = useRelayEnvironment();
@@ -359,14 +359,14 @@ function ShowRiskViewContent({
359359
const risk = data.node;
360360
const severity = getRiskSeverity(
361361
risk.inherentLikelihood!,
362-
risk.inherentImpact!,
362+
risk.inherentImpact!
363363
);
364364

365365
// Fix typing for measures
366366
const measures = risk.measures?.edges?.map((edge) => edge.node) || [];
367367
const residualSeverity = getRiskSeverity(
368368
risk.residualLikelihood!,
369-
risk.residualImpact!,
369+
risk.residualImpact!
370370
);
371371

372372
// Fix typing for policies
@@ -405,21 +405,21 @@ function ShowRiskViewContent({
405405
// Setup mutation hooks
406406
const [createRiskMeasureMapping] =
407407
useMutation<ShowRiskViewCreateRiskMeasureMappingMutation>(
408-
createRiskMeasureMappingMutation,
408+
createRiskMeasureMappingMutation
409409
);
410410
const [deleteRiskMeasureMapping] =
411411
useMutation<ShowRiskViewDeleteRiskMeasureMappingMutation>(
412-
deleteRiskMeasureMappingMutation,
412+
deleteRiskMeasureMappingMutation
413413
);
414414

415415
// Setup policy mutation hooks
416416
const [createRiskPolicyMapping] =
417417
useMutation<ShowRiskViewCreateRiskPolicyMappingMutation>(
418-
createRiskPolicyMappingMutation,
418+
createRiskPolicyMappingMutation
419419
);
420420
const [deleteRiskPolicyMapping] =
421421
useMutation<ShowRiskViewDeleteRiskPolicyMappingMutation>(
422-
deleteRiskPolicyMappingMutation,
422+
deleteRiskPolicyMappingMutation
423423
);
424424

425425
// Clear filters when dialog closes
@@ -453,7 +453,7 @@ function ShowRiskViewContent({
453453
organizationMeasuresQuery,
454454
{
455455
organizationId,
456-
},
456+
}
457457
).subscribe({
458458
next: (data) => {
459459
setOrganizationMeasuresData(data);
@@ -483,7 +483,7 @@ function ShowRiskViewContent({
483483
organizationPoliciesQuery,
484484
{
485485
organizationId,
486-
},
486+
}
487487
).subscribe({
488488
next: (data) => {
489489
setOrganizationPoliciesData(data);
@@ -505,7 +505,7 @@ function ShowRiskViewContent({
505505
const getMeasures = useCallback(() => {
506506
if (!organizationMeasuresData?.organization?.measures?.edges) return [];
507507
return organizationMeasuresData.organization.measures.edges.map(
508-
(edge) => edge.node,
508+
(edge) => edge.node
509509
);
510510
}, [organizationMeasuresData]);
511511

@@ -550,7 +550,7 @@ function ShowRiskViewContent({
550550
const getPolicies = useCallback(() => {
551551
if (!organizationPoliciesData?.organization?.policies?.edges) return [];
552552
return organizationPoliciesData.organization.policies.edges.map(
553-
(edge) => edge.node,
553+
(edge) => edge.node
554554
);
555555
}, [organizationPoliciesData]);
556556

@@ -573,7 +573,7 @@ function ShowRiskViewContent({
573573
NonNullable<
574574
ShowRiskViewOrganizationMeasuresQuery$data["organization"]
575575
>["measures"]
576-
>["edges"][0]["node"],
576+
>["edges"][0]["node"]
577577
) => {
578578
if (!risk.id) return;
579579

@@ -635,7 +635,7 @@ function ShowRiskViewContent({
635635
},
636636
});
637637
},
638-
[risk.id, createRiskMeasureMapping, toast, environment, loadQuery],
638+
[risk.id, createRiskMeasureMapping, toast, environment, loadQuery]
639639
);
640640

641641
// Handle unlinking a measure from this risk
@@ -645,7 +645,7 @@ function ShowRiskViewContent({
645645
NonNullable<
646646
ShowRiskViewOrganizationMeasuresQuery$data["organization"]
647647
>["measures"]
648-
>["edges"][0]["node"],
648+
>["edges"][0]["node"]
649649
) => {
650650
if (!risk.id) return;
651651

@@ -707,7 +707,7 @@ function ShowRiskViewContent({
707707
},
708708
});
709709
},
710-
[risk.id, deleteRiskMeasureMapping, toast, environment, loadQuery],
710+
[risk.id, deleteRiskMeasureMapping, toast, environment, loadQuery]
711711
);
712712

713713
// Handle linking a policy to this risk
@@ -717,7 +717,7 @@ function ShowRiskViewContent({
717717
NonNullable<
718718
ShowRiskViewOrganizationPoliciesQuery$data["organization"]
719719
>["policies"]
720-
>["edges"][0]["node"],
720+
>["edges"][0]["node"]
721721
) => {
722722
if (!risk.id) return;
723723

@@ -779,7 +779,7 @@ function ShowRiskViewContent({
779779
},
780780
});
781781
},
782-
[risk.id, createRiskPolicyMapping, toast, environment, loadQuery],
782+
[risk.id, createRiskPolicyMapping, toast, environment, loadQuery]
783783
);
784784

785785
// Handle unlinking a policy from this risk
@@ -789,7 +789,7 @@ function ShowRiskViewContent({
789789
NonNullable<
790790
ShowRiskViewOrganizationPoliciesQuery$data["organization"]
791791
>["policies"]
792-
>["edges"][0]["node"],
792+
>["edges"][0]["node"]
793793
) => {
794794
if (!risk.id) return;
795795

@@ -851,7 +851,7 @@ function ShowRiskViewContent({
851851
},
852852
});
853853
},
854-
[risk.id, deleteRiskPolicyMapping, toast, environment, loadQuery],
854+
[risk.id, deleteRiskPolicyMapping, toast, environment, loadQuery]
855855
);
856856

857857
return (
@@ -919,6 +919,23 @@ function ShowRiskViewContent({
919919
</p>
920920
</div>
921921
</div>
922+
923+
<div className="flex items-center">
924+
<div>
925+
<p className="text-xs text-slate-500 uppercase">
926+
Last Updated
927+
</p>
928+
<p className="text-base font-medium mt-1">
929+
{risk.updatedAt
930+
? new Date(risk.updatedAt).toLocaleDateString("en-US", {
931+
year: "numeric",
932+
month: "long",
933+
day: "numeric",
934+
})
935+
: "N/A"}
936+
</p>
937+
</div>
938+
</div>
922939
</div>
923940

924941
{/* Risk Assessment */}
@@ -1263,7 +1280,7 @@ function ShowRiskViewContent({
12631280
{filteredMeasures().map((measure) => {
12641281
// For each render, recalculate linked status directly against the current risk data
12651282
const isLinked = risk.measures?.edges?.some(
1266-
(edge) => edge.node.id === measure.id,
1283+
(edge) => edge.node.id === measure.id
12671284
);
12681285
const isLinking = linkingMeasures[measure.id] || false;
12691286
const isUnlinking =
@@ -1365,7 +1382,7 @@ function ShowRiskViewContent({
13651382
{filteredPolicies().map((policy) => {
13661383
// For each render, recalculate linked status directly against the current risk data
13671384
const isLinked = policies.some(
1368-
(riskPolicy) => riskPolicy.id === policy.id,
1385+
(riskPolicy) => riskPolicy.id === policy.id
13691386
);
13701387
const isLinking = linkingPolicies[policy.id] || false;
13711388
const isUnlinking = unlinkingPolicies[policy.id] || false;

0 commit comments

Comments
 (0)