import React, { useState } from 'react';
import {
Grid,
Paper,
Typography,
Box,
Card,
CardContent,
Button,
Chip,
TextField,
List,
ListItem,
ListItemText,
ListItemIcon,
Divider,
Alert,
Stepper,
Step,
StepLabel,
StepContent,
Accordion,
AccordionSummary,
AccordionDetails,
} from '@mui/material';
import {
Build,
Search,
Timeline,
CheckCircle,
Cancel,
ExpandMore,
Add,
} from '@mui/icons-material';
const analysisMethods = [
{
id: '5why',
name: '5 Whys Analysis',
description: 'Ask "why" five times to drill down to the root cause',
icon: ,
},
{
id: 'fishbone',
name: 'Fishbone Diagram',
description: 'Categorize potential causes into main categories',
icon: ,
},
{
id: 'pareto',
name: 'Pareto Analysis',
description: 'Identify the 20% of causes that create 80% of problems',
icon: ,
},
{
id: 'fault-tree',
name: 'Fault Tree Analysis',
description: 'Systematic approach to identify all possible causes',
icon: ,
},
];
const currentAnalysis = {
problemId: 'PRB001',
title: 'Recurring Email Server Outages',
status: 'In Progress',
method: '5why',
findings: [
{
id: 1,
question: 'Why did the email server go down?',
answer: 'The server ran out of disk space',
evidence: 'Disk usage logs show 100% utilization',
verified: true,
},
{
id: 2,
question: 'Why did the server run out of disk space?',
answer: 'Log files were not being rotated properly',
evidence: 'Log rotation script failed due to permission issues',
verified: true,
},
{
id: 3,
question: 'Why did the log rotation script fail?',
answer: 'The script was running with incorrect permissions',
evidence: 'Script was running as root but needed mail user permissions',
verified: true,
},
{
id: 4,
question: 'Why was the script running with incorrect permissions?',
answer: 'The deployment process did not set proper ownership',
evidence: 'Deployment documentation missing permission setup steps',
verified: true,
},
{
id: 5,
question: 'Why was the deployment process missing permission setup?',
answer: 'No formal deployment checklist or validation process',
evidence: 'Deployment was done manually without following procedures',
verified: true,
},
],
rootCause: 'Lack of formal deployment procedures and validation processes',
recommendations: [
'Implement formal deployment checklist',
'Add automated permission validation',
'Create deployment approval process',
'Implement monitoring for disk usage',
],
};
const RootCauseAnalysis: React.FC = () => {
const [selectedMethod, setSelectedMethod] = useState('5why');
const [newFinding, setNewFinding] = useState({
question: '',
answer: '',
evidence: '',
});
const [showAddForm, setShowAddForm] = useState(false);
const handleAddFinding = () => {
console.log('Adding finding:', newFinding);
setNewFinding({ question: '', answer: '', evidence: '' });
setShowAddForm(false);
};
const getMethodIcon = (methodId: any) => {
const method = analysisMethods.find(m => m.id === methodId);
return method ? method.icon : ;
};
return (
Root Cause Analysis
Systematic investigation to identify the underlying cause of problems
{/* Problem Information */}
Problem Information
Problem ID: {currentAnalysis.problemId}
Title: {currentAnalysis.title}
Status:
Method:
{getMethodIcon(currentAnalysis.method)}
{analysisMethods.find(m => m.id === currentAnalysis.method)?.name}
Analysis Methods
{analysisMethods.map((method) => (
setSelectedMethod(method.id)}
>
{method.icon}
{method.name}
{method.description}
))}
{/* Analysis Content */}
{selectedMethod === '5why' && (
5 Whys Analysis
{currentAnalysis.findings.map((finding, index) => (
Why #{index + 1}
{finding.question}
Answer: {finding.answer}
Evidence: {finding.evidence}
: }
label={finding.verified ? 'Verified' : 'Unverified'}
size="small"
color={finding.verified ? 'success' : 'error'}
/>
))}
{showAddForm && (
Add New Finding
setNewFinding(prev => ({ ...prev, question: e.target.value }))}
placeholder="Why did this happen?"
/>
setNewFinding(prev => ({ ...prev, answer: e.target.value }))}
placeholder="The answer to the question"
/>
setNewFinding(prev => ({ ...prev, evidence: e.target.value }))}
placeholder="Supporting evidence or data"
/>
)}
{!showAddForm && (
}
onClick={() => setShowAddForm(true)}
sx={{ mt: 2 }}
>
Add Finding
)}
)}
{/* Root Cause Summary */}
Root Cause Summary
Identified Root Cause:
{currentAnalysis.rootCause}
Recommendations
{currentAnalysis.recommendations.map((recommendation, index) => (
))}
{/* Action Items */}
Action Items
}>
Implement Deployment Checklist
Create a comprehensive deployment checklist that includes permission validation,
disk space checks, and service health verification.
}>
Add Disk Usage Monitoring
Implement automated monitoring for disk usage with alerts when usage exceeds 80%.
);
}
export default RootCauseAnalysis;