Add coderabbit suggestions
Signed-off-by: Antoine Bouchardy <antoine@getprobo.com> Signed-off-by: Bryan Frimin <bryan@getprobo.com>
This commit is contained in:
committed by
Bryan Frimin
parent
c7f49c7802
commit
d830f2c689
@@ -72,7 +72,7 @@
|
|||||||
{
|
{
|
||||||
"category": "Cybersecurity",
|
"category": "Cybersecurity",
|
||||||
"name": "Third-party vendor breach compromising startup data",
|
"name": "Third-party vendor breach compromising startup data",
|
||||||
"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."
|
"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."
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"category": "Cybersecurity",
|
"category": "Cybersecurity",
|
||||||
@@ -122,7 +122,7 @@
|
|||||||
{
|
{
|
||||||
"category": "Cybersecurity",
|
"category": "Cybersecurity",
|
||||||
"name": "Account hijacking of social media platforms",
|
"name": "Account hijacking of social media platforms",
|
||||||
"description": "If attackers hijack your startup’s social media accounts, they could post harmful content or engage in fraudulent activities, damaging the brand."
|
"description": "If attackers hijack your startup's social media accounts, they could post harmful content or engage in fraudulent activities, damaging the brand."
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"category": "Cybersecurity",
|
"category": "Cybersecurity",
|
||||||
@@ -187,7 +187,7 @@
|
|||||||
{
|
{
|
||||||
"category": "Human capital",
|
"category": "Human capital",
|
||||||
"name": "Poor hiring fit leads to culture break",
|
"name": "Poor hiring fit leads to culture break",
|
||||||
"description": "Recruiting individuals who do not align with the startup’s values or pace cause conflict and reduce cohesion."
|
"description": "Recruiting individuals who do not align with the startup's values or pace cause conflict and reduce cohesion."
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"category": "Human capital",
|
"category": "Human capital",
|
||||||
@@ -296,7 +296,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"category": "Strategic",
|
"category": "Strategic",
|
||||||
"name": "Operational instability due to parnership",
|
"name": "Operational instability due to partnership",
|
||||||
"description": "Unreliable or misaligned partners may cause delivery delays, service breakdowns, or reputational damage."
|
"description": "Unreliable or misaligned partners may cause delivery delays, service breakdowns, or reputational damage."
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { useState, useEffect } from "react";
|
import { useState, useEffect, useMemo } from "react";
|
||||||
import { useNavigate, useParams } from "react-router";
|
import { useNavigate, useParams } from "react-router";
|
||||||
import {
|
import {
|
||||||
ConnectionHandler,
|
ConnectionHandler,
|
||||||
@@ -105,31 +105,26 @@ function NewRiskForm({
|
|||||||
|
|
||||||
const [createRisk, isInFlight] = useMutation(createRiskMutation);
|
const [createRisk, isInFlight] = useMutation(createRiskMutation);
|
||||||
|
|
||||||
// Get unique categories from risk templates
|
const categories = useMemo(
|
||||||
const categories = Array.from(new Set(riskTemplates.map(template => template.category)));
|
() => Array.from(new Set(riskTemplates.map(t => t.category))),
|
||||||
|
[riskTemplates],
|
||||||
|
);
|
||||||
|
|
||||||
// Filter risks by selected category
|
const filteredRisks = useMemo(
|
||||||
const filteredRisks = riskTemplates.filter(template =>
|
() =>
|
||||||
!selectedCategory || template.category === selectedCategory
|
riskTemplates
|
||||||
).map(template => ({
|
.map((t, idx) => ({ ...t, originalIndex: idx }))
|
||||||
...template,
|
.filter(t => !selectedCategory || t.category === selectedCategory),
|
||||||
originalIndex: riskTemplates.findIndex(t => t.name === template.name && t.description === template.description)
|
[riskTemplates, selectedCategory],
|
||||||
}));
|
);
|
||||||
|
|
||||||
// Handle category selection
|
// Handle category selection
|
||||||
const selectCategory = (category: string) => {
|
const selectCategory = (category: string) => {
|
||||||
setSelectedCategory(category);
|
setSelectedCategory(prev => {
|
||||||
// Only reset template if we're changing categories
|
if (prev !== category) setSelectedTemplate("");
|
||||||
if (selectedCategory !== category) {
|
return category;
|
||||||
setSelectedTemplate("");
|
});
|
||||||
}
|
// If focus management is required, attach a ref to <SelectTrigger> instead.
|
||||||
// Focus on the risk dropdown after a short delay to ensure it's rendered
|
|
||||||
setTimeout(() => {
|
|
||||||
const selectTrigger = document.getElementById('template');
|
|
||||||
if (selectTrigger) {
|
|
||||||
selectTrigger.focus();
|
|
||||||
}
|
|
||||||
}, 0);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -176,6 +171,7 @@ function NewRiskForm({
|
|||||||
setName(template.name);
|
setName(template.name);
|
||||||
setDescription(template.description);
|
setDescription(template.description);
|
||||||
setTreatment("MITIGATED");
|
setTreatment("MITIGATED");
|
||||||
|
setSelectedCategory(template.category);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user