Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 | 4x 30x 20x 5x 5x 4x 30x 20x 5x 5x 4x 30x 20x 5x 5x 4x 30x 30x 30x 30x 30x 2x | import React from "react";
import type { BusinessImpactSectionProps, CIAComponentColor } from "../../types/componentPropExports";
/**
* Get explicit background color classes to avoid dynamic Tailwind class generation
* @param color - Color name (blue, green, orange)
* @returns Explicit className string for background colors
*/
const getBackgroundColorClasses = (color: CIAComponentColor): string => {
switch (color) {
case "blue":
return "bg-blue-100 dark:bg-blue-900 border-blue-200 dark:border-blue-800";
case "green":
return "bg-green-100 dark:bg-green-900 border-green-200 dark:border-green-800";
case "orange":
return "bg-orange-100 dark:bg-orange-900 border-orange-200 dark:border-orange-800";
default: {
// Exhaustive check - TypeScript will error if new colors are added
const exhaustiveCheck: never = color;
throw new Error(`Unsupported color: ${String(exhaustiveCheck)}`);
}
}
};
/**
* Get explicit text color classes to avoid dynamic Tailwind class generation
* @param color - Color name (blue, green, orange)
* @returns Explicit className string for text colors
*/
const getTextColorClasses = (color: CIAComponentColor): string => {
switch (color) {
case "blue":
return "text-blue-700 dark:text-blue-300";
case "green":
return "text-green-700 dark:text-green-300";
case "orange":
return "text-orange-700 dark:text-orange-300";
default: {
// Exhaustive check - TypeScript will error if new colors are added
const exhaustiveCheck: never = color;
throw new Error(`Unsupported color: ${String(exhaustiveCheck)}`);
}
}
};
/**
* Get explicit badge color classes for rounded-full badges
* This provides complete styling for small badges including dark mode support
* @param color - Color name (blue, green, orange)
* @returns Explicit className string for badge styling
*/
const getBadgeColorClasses = (color: CIAComponentColor): string => {
switch (color) {
case "blue":
return "bg-blue-50 text-blue-700 dark:bg-blue-900 dark:bg-opacity-50 dark:text-blue-300";
case "green":
return "bg-green-50 text-green-700 dark:bg-green-900 dark:bg-opacity-50 dark:text-green-300";
case "orange":
return "bg-orange-50 text-orange-700 dark:bg-orange-900 dark:bg-opacity-50 dark:text-orange-300";
default: {
// Exhaustive check - TypeScript will error if new colors are added
const exhaustiveCheck: never = color;
throw new Error(`Unsupported color: ${String(exhaustiveCheck)}`);
}
}
};
/**
* Reusable component for displaying business impact information
* Used by various CIA impact widgets to provide consistent UI
*/
const BusinessImpactSection: React.FC<BusinessImpactSectionProps> = ({
impact,
color,
testId = "business-impact-section",
}) => {
// Extract risk level from the impact financial or operational data
// Using the risk level in the UI
const riskLevelForDisplay =
impact.financial?.riskLevel || impact.operational?.riskLevel || "Unknown";
// Get explicit color classes for this color scheme
const bgClasses = getBackgroundColorClasses(color);
const textClasses = getTextColorClasses(color);
const badgeClasses = getBadgeColorClasses(color);
return (
<div
className="bg-gray-50 dark:bg-gray-800 p-4 rounded-lg border shadow-sm security-card"
data-testid={testId}
>
<h4 className="text-md font-medium mb-3 flex items-center">
<span className="mr-2">💼</span>
Business Impact
<span className="ml-2 text-sm text-gray-500">
Risk: {riskLevelForDisplay}
</span>
</h4>
<p
className="text-gray-600 dark:text-gray-300 mb-4"
data-testid={`${testId}-summary`}
>
{impact.summary || "No business impact data available"}
</p>
<div className="grid grid-cols-1 md:grid-cols-2 gap-3">
{/* Financial Impact */}
{impact.financial && (
<div
className={`p-2 rounded-md bg-opacity-10 dark:bg-opacity-20 border ${bgClasses}`}
>
<div className="flex items-center mb-2">
<span className="mr-2">💰</span>
<span className={`font-medium ${textClasses}`}>
Financial Impact
</span>
</div>
<p className="text-xs text-gray-700 dark:text-gray-300">
{impact.financial.description ||
"No financial impact information available"}
</p>
{impact.financial.annualRevenueLoss && (
<p className="text-xs text-gray-700 dark:text-gray-300 mt-1">
<span className="font-medium">Annual Revenue Loss: </span>
{impact.financial.annualRevenueLoss}
</p>
)}
</div>
)}
{/* Operational Impact */}
{impact.operational && (
<div
className={`p-2 rounded-md bg-opacity-10 dark:bg-opacity-20 border ${bgClasses}`}
>
<div className="flex items-center mb-2">
<span className="mr-2">⚙️</span>
<span className={`font-medium ${textClasses}`}>
Operational Impact
</span>
</div>
<p className="text-xs text-gray-700 dark:text-gray-300">
{impact.operational.description ||
"No operational impact information available"}
</p>
{impact.operational.meanTimeToRecover && (
<p className="text-xs text-gray-700 dark:text-gray-300 mt-1">
<span className="font-medium">Mean Time to Recover: </span>
{impact.operational.meanTimeToRecover}
</p>
)}
</div>
)}
{/* Reputational Impact */}
{impact.reputational && (
<div
className={`p-2 rounded-md bg-opacity-10 dark:bg-opacity-20 border ${bgClasses}`}
>
<div className="flex items-center mb-2">
<span className="mr-2">🏆</span>
<span className={`font-medium ${textClasses}`}>
Reputational Impact
</span>
</div>
<p className="text-xs text-gray-700 dark:text-gray-300">
{impact.reputational.description ||
"No reputational impact information available"}
</p>
{impact.reputational.reputationalImpact && (
<p className="text-xs text-gray-700 dark:text-gray-300 mt-1">
{impact.reputational.reputationalImpact}
</p>
)}
</div>
)}
{/* Strategic Impact */}
{impact.strategic && (
<div
className={`p-2 rounded-md bg-opacity-10 dark:bg-opacity-20 border ${bgClasses}`}
>
<div className="flex items-center mb-2">
<span className="mr-2">🎯</span>
<span className={`font-medium ${textClasses}`}>
Strategic Impact
</span>
</div>
<p className="text-xs text-gray-700 dark:text-gray-300">
{impact.strategic.description ||
"No strategic impact information available"}
</p>
{impact.strategic.competitiveAdvantage && (
<p className="text-xs text-gray-700 dark:text-gray-300 mt-1">
<span className="font-medium">Competitive Advantage: </span>
{impact.strategic.competitiveAdvantage}
</p>
)}
</div>
)}
{/* Regulatory Impact */}
{impact.regulatory && (
<div
className={`p-2 rounded-md bg-opacity-10 dark:bg-opacity-20 border ${bgClasses}`}
>
<div className="flex items-center mb-2">
<span className="mr-2">📜</span>
<span className={`font-medium ${textClasses}`}>
Regulatory Impact
</span>
</div>
<p className="text-xs text-gray-700 dark:text-gray-300">
{impact.regulatory.description ||
"No regulatory impact information available"}
</p>
{impact.regulatory.complianceImpact && (
<p className="text-xs text-gray-700 dark:text-gray-300 mt-1">
{impact.regulatory.complianceImpact}
</p>
)}
{impact.regulatory.complianceViolations &&
impact.regulatory.complianceViolations.length > 0 && (
<div className="mt-1">
<span className="text-xs font-medium text-gray-700 dark:text-gray-300">
Potential Violations:{" "}
</span>
<div className="flex flex-wrap gap-1 mt-1">
{impact.regulatory.complianceViolations.map(
(violation, index) => (
<span
key={index}
className={`px-2 py-0.5 text-xs rounded-full ${badgeClasses}`}
>
{violation}
</span>
)
)}
</div>
</div>
)}
</div>
)}
</div>
</div>
);
};
export default BusinessImpactSection;
|