import React, { useState, useEffect } from 'react'; import Papa from 'papaparse'; // Simplified version without complex styling const EmployeeProfilePlatform = () => { const [employeeData, setEmployeeData] = useState([]); const [loading, setLoading] = useState(true); const [searchTerm, setSearchTerm] = useState(''); const [selectedEmployee, setSelectedEmployee] = useState(null); const [filteredEmployees, setFilteredEmployees] = useState([]); // Brand colors const colors = { orange: "#FA8200", midnightBlue: "#0A1E3C", turquoise: "#00AFB9" }; useEffect(() => { const fetchData = async () => { try { const response = await window.fs.readFile('Employee profile 2025.csv'); const text = new TextDecoder('cp1252').decode(response); Papa.parse(text, { header: true, dynamicTyping: true, skipEmptyLines: true, complete: (results) => { setEmployeeData(results.data); setLoading(false); } }); } catch (error) { console.error('Error reading file:', error); setLoading(false); } }; fetchData(); }, []); useEffect(() => { if (searchTerm.trim() === '') { setFilteredEmployees([]); return; } const searchLower = searchTerm.toLowerCase(); const filtered = employeeData.filter(emp => { const nameMatch = emp['Employee(s)'] && String(emp['Employee(s)']).toLowerCase().includes(searchLower); const idMatch = emp['Personnel no.'] && String(emp['Personnel no.']).includes(searchTerm); return nameMatch || idMatch; }).slice(0, 5); setFilteredEmployees(filtered); }, [searchTerm, employeeData]); const handleEmployeeSelect = (employee) => { setSelectedEmployee(employee); setSearchTerm(employee['Employee(s)']); setFilteredEmployees([]); }; const analyzePerformanceTrend = (employee) => { if (!employee) return { trend: 'Unknown', consistent: false, latestRating: 0 }; const perf2021 = employee['2021 perfromance ']; const perf2022 = employee['2022 perfromance ']; const perf2023 = employee['2023 perfromance ']; const perfRatings = { 'Exceptional': 5, 'Exceed Target': 4, 'Achieved Target': 3, 'Need Improvement': 2, 'Low Performance': 1, 'Unrated': 0, '#N/A': 0 }; const ratings = [ perf2021 ? (perfRatings[perf2021] || 0) : null, perf2022 ? (perfRatings[perf2022] || 0) : null, perf2023 ? (perfRatings[perf2023] || 0) : null ].filter(r => r !== null); let trend = "Stable"; let direction = 0; if (ratings.length >= 2) { const lastIdx = ratings.length - 1; if (ratings[lastIdx] > ratings[lastIdx - 1]) { trend = "Improving"; direction = 1; } else if (ratings[lastIdx] < ratings[lastIdx - 1]) { trend = "Declining"; direction = -1; } } let consistent = true; if (ratings.length >= 3) { if (direction === 1) { consistent = ratings[1] >= ratings[0] && ratings[2] >= ratings[1]; } else if (direction === -1) { consistent = ratings[1] <= ratings[0] && ratings[2] <= ratings[1]; } else { consistent = ratings[0] === ratings[1] && ratings[1] === ratings[2]; } } return { trend, consistent, hasData: ratings.length > 0, ratings, latestRating: ratings.length > 0 ? ratings[ratings.length - 1] : 0 }; }; const getEmployeePotential = (employee) => { if (!employee) return { category: 'Unknown', description: 'Insufficient data' }; const nineBox = employee['9 box matrix']; const performanceTrend = analyzePerformanceTrend(employee); const isSuccessor = employee['Successor'] && employee['Successor'].toUpperCase() === 'YES'; const highPotentialBoxes = ['Hi-Potential', 'Hi-Lead', 'Hi-Professional', 'High-Grow']; const mediumPotentialBoxes = ['Promising', 'Safe Hand']; const lowPotentialBoxes = ['Dilemma', 'Shortfall', 'Casting Error']; let category = 'Needs Assessment'; let description = ''; if (highPotentialBoxes.includes(nineBox) && performanceTrend.latestRating >= 4) { category = 'High Potential'; description = `Exceptional performer consistently exceeding targets${isSuccessor ? ' and identified as a successor' : ''}. Recommended for leadership development programs and increased responsibilities.`; } else if (highPotentialBoxes.includes(nineBox) && performanceTrend.latestRating === 3) { category = 'Emerging Talent'; description = 'Demonstrates high potential with solid performance. Focus on challenging assignments to accelerate growth.'; } else if (mediumPotentialBoxes.includes(nineBox) && performanceTrend.trend === 'Improving') { category = 'Growing Talent'; description = 'Shows consistent improvement and solid potential. Provide targeted development opportunities.'; } else if (mediumPotentialBoxes.includes(nineBox) && performanceTrend.latestRating >= 3) { category = 'Solid Performer'; description = 'Reliable performer with moderate potential. Focus on maintaining strengths while developing in key areas.'; } else if (lowPotentialBoxes.includes(nineBox) || performanceTrend.latestRating <= 2) { category = 'Needs Development'; description = 'Requires focused intervention and performance improvement plan. Consider skills assessment and targeted coaching.'; } else if (nineBox === 'Unrated' || nineBox === '#N/A') { category = 'Needs Assessment'; description = 'Insufficient data for accurate assessment. Recommend completing 9-box evaluation.'; } return { category, description }; }; const getDevelopmentRecommendations = (employee) => { if (!employee) return []; const potential = getEmployeePotential(employee); const recommendations = []; if (potential.category === 'High Potential') { recommendations.push('Leadership development program'); recommendations.push('Executive mentoring'); recommendations.push('Strategic project assignments'); } else if (potential.category === 'Emerging Talent') { recommendations.push('Advanced skill development'); recommendations.push('Increased project responsibility'); recommendations.push('Mentoring program participation'); } else if (potential.category === 'Growing Talent') { recommendations.push('Targeted skill development'); recommendations.push('Stretch assignments'); recommendations.push('Regular feedback sessions'); } else if (potential.category === 'Solid Performer') { recommendations.push('Maintain current performance'); recommendations.push('Knowledge sharing opportunities'); recommendations.push('Process improvement projects'); } else if (potential.category === 'Needs Development') { recommendations.push('Performance improvement plan'); recommendations.push('Regular coaching sessions'); recommendations.push('Core skill training'); } else { recommendations.push('Complete 9-box evaluation'); recommendations.push('Performance review'); recommendations.push('Career aspiration discussion'); } return recommendations.slice(0, 3); }; if (loading) { return (
{selectedEmployee['Positions']}
{getEmployeePotential(selectedEmployee).description}
{getEmployeePotential(selectedEmployee).category === 'High Potential' ? 'Leadership capability and consistent high performance' : 'Core technical competencies and reliability'}
{getEmployeePotential(selectedEmployee).category === 'High Potential' ? 'Strategic thinking and broader organizational impact' : 'Performance consistency and technical skill enhancement'}
Search for an employee by name or ID to view their profile