Skip to content

Commit 317f784

Browse files
abouchardygearnode
authored andcommitted
Add coderabbit suggestions
Signed-off-by: Antoine Bouchardy <antoine@getprobo.com>
1 parent 9a03059 commit 317f784

File tree

2 files changed

+22
-26
lines changed

2 files changed

+22
-26
lines changed

apps/console/public/data/risks/risks.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@
7272
{
7373
"category": "Cybersecurity",
7474
"name": "Third-party vendor breach compromising startup data",
75-
"description": "If a third-party vendor with access to your systems is breached, your sensitive data may be exposed due to poor security on the vendors side."
75+
"description": "If a third-party vendor with access to your systems is breached, your sensitive data may be exposed due to poor security on the vendor's side."
7676
},
7777
{
7878
"category": "Cybersecurity",
@@ -122,7 +122,7 @@
122122
{
123123
"category": "Cybersecurity",
124124
"name": "Account hijacking of social media platforms",
125-
"description": "If attackers hijack your startups social media accounts, they could post harmful content or engage in fraudulent activities, damaging the brand."
125+
"description": "If attackers hijack your startup's social media accounts, they could post harmful content or engage in fraudulent activities, damaging the brand."
126126
},
127127
{
128128
"category": "Cybersecurity",
@@ -187,7 +187,7 @@
187187
{
188188
"category": "Human capital",
189189
"name": "Poor hiring fit leads to culture break",
190-
"description": "Recruiting individuals who do not align with the startups values or pace cause conflict and reduce cohesion."
190+
"description": "Recruiting individuals who do not align with the startup's values or pace cause conflict and reduce cohesion."
191191
},
192192
{
193193
"category": "Human capital",
@@ -296,7 +296,7 @@
296296
},
297297
{
298298
"category": "Strategic",
299-
"name": "Operational instability due to parnership",
299+
"name": "Operational instability due to partnership",
300300
"description": "Unreliable or misaligned partners may cause delivery delays, service breakdowns, or reputational damage."
301301
},
302302
{

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

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { useState, useEffect } from "react";
1+
import { useState, useEffect, useMemo } from "react";
22
import { useNavigate, useParams } from "react-router";
33
import {
44
ConnectionHandler,
@@ -105,31 +105,26 @@ function NewRiskForm({
105105

106106
const [createRisk, isInFlight] = useMutation(createRiskMutation);
107107

108-
// Get unique categories from risk templates
109-
const categories = Array.from(new Set(riskTemplates.map(template => template.category)));
108+
const categories = useMemo(
109+
() => Array.from(new Set(riskTemplates.map(t => t.category))),
110+
[riskTemplates],
111+
);
110112

111-
// Filter risks by selected category
112-
const filteredRisks = riskTemplates.filter(template =>
113-
!selectedCategory || template.category === selectedCategory
114-
).map(template => ({
115-
...template,
116-
originalIndex: riskTemplates.findIndex(t => t.name === template.name && t.description === template.description)
117-
}));
113+
const filteredRisks = useMemo(
114+
() =>
115+
riskTemplates
116+
.map((t, idx) => ({ ...t, originalIndex: idx }))
117+
.filter(t => !selectedCategory || t.category === selectedCategory),
118+
[riskTemplates, selectedCategory],
119+
);
118120

119121
// Handle category selection
120122
const selectCategory = (category: string) => {
121-
setSelectedCategory(category);
122-
// Only reset template if we're changing categories
123-
if (selectedCategory !== category) {
124-
setSelectedTemplate("");
125-
}
126-
// Focus on the risk dropdown after a short delay to ensure it's rendered
127-
setTimeout(() => {
128-
const selectTrigger = document.getElementById('template');
129-
if (selectTrigger) {
130-
selectTrigger.focus();
131-
}
132-
}, 0);
123+
setSelectedCategory(prev => {
124+
if (prev !== category) setSelectedTemplate("");
125+
return category;
126+
});
127+
// If focus management is required, attach a ref to <SelectTrigger> instead.
133128
};
134129

135130
useEffect(() => {
@@ -176,6 +171,7 @@ function NewRiskForm({
176171
setName(template.name);
177172
setDescription(template.description);
178173
setTreatment("MITIGATED");
174+
setSelectedCategory(template.category);
179175
}
180176
};
181177

0 commit comments

Comments
 (0)