Skip to content

Commit ce4f4f1

Browse files
authored
Merge pull request #99 from futurepr0n/multi-hit-card
additional performance stuff and pinhead
2 parents 308473a + 25b38bf commit ce4f4f1

File tree

8 files changed

+2881
-302
lines changed

8 files changed

+2881
-302
lines changed

src/components/Dashboard.js

Lines changed: 61 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ import { useTeamFilter } from './TeamFilterContext';
99
// Import reusable tooltip utilities
1010
import { createSafeId } from './utils/tooltipUtils';
1111

12+
import PoorPerformanceCard from './cards/PoorPerformanceCard/PoorPerformanceCard';
13+
14+
1215
// Import individual card components
1316
import StatsSummaryCard from './cards/StatsSummaryCard/StatsSummaryCard';
1417
import HRPredictionCard from './cards/HRPredictionCard/HRPredictionCard';
@@ -129,6 +132,9 @@ function Dashboard({ playerData, teamData, gameData, currentDate }) {
129132
fridayHitLeaders: []
130133
});
131134

135+
const [poorPerformancePredictions, setPoorPerformancePredictions] = useState([]);
136+
const [poorPerformanceLoading, setPoorPerformanceLoading] = useState(true);
137+
132138
// Simple effect to populate slot machine data from existing sources
133139
useEffect(() => {
134140
const populateSlotMachineData = () => {
@@ -179,6 +185,55 @@ function Dashboard({ playerData, teamData, gameData, currentDate }) {
179185
loadStadiumData();
180186
}, [currentDate]);
181187

188+
189+
useEffect(() => {
190+
const loadPoorPerformancePredictions = async () => {
191+
try {
192+
setPoorPerformanceLoading(true);
193+
194+
// Format date for file name (matching your HR prediction pattern)
195+
const year = currentDate.getFullYear();
196+
const month = String(currentDate.getMonth() + 1).padStart(2, '0');
197+
const day = String(currentDate.getDate()).padStart(2, '0');
198+
const dateStr = `${year}-${month}-${day}`;
199+
200+
// Try to load the specific date file first
201+
let response = await fetch(`/data/predictions/poor_performance_predictions_${dateStr}.json`);
202+
203+
// If not found, try to load the latest predictions
204+
if (!response.ok) {
205+
response = await fetch('/data/predictions/poor_performance_predictions_latest.json');
206+
}
207+
208+
if (!response.ok) {
209+
console.warn('No poor performance predictions found');
210+
setPoorPerformancePredictions([]);
211+
} else {
212+
const data = await response.json();
213+
let predictions = data.predictions || [];
214+
215+
// Apply team filtering if needed (matching your HR prediction logic)
216+
if (isFiltering) {
217+
predictions = predictions.filter(player =>
218+
shouldIncludePlayer(player.team)
219+
);
220+
}
221+
222+
setPoorPerformancePredictions(predictions);
223+
console.log(`Loaded ${predictions.length} poor performance predictions`);
224+
}
225+
} catch (error) {
226+
console.error('Error loading poor performance predictions:', error);
227+
setPoorPerformancePredictions([]);
228+
} finally {
229+
setPoorPerformanceLoading(false);
230+
}
231+
};
232+
233+
loadPoorPerformancePredictions();
234+
}, [currentDate, isFiltering, shouldIncludePlayer]); // Same dependencies as your HR predictions
235+
236+
182237
// Filter player data based on team selection
183238
const filteredPlayerData = useMemo(() => {
184239
if (!isFiltering) return playerData;
@@ -1259,12 +1314,12 @@ const noFilteredData = isFiltering &&
12591314
/>
12601315

12611316
{/* Under-Performing Players Card */}
1262-
<PerformanceCard
1263-
performingPlayers={topPerformers.underPerforming}
1264-
isLoading={!playerPerformance}
1265-
type="under"
1266-
teams={teamData}
1267-
/>
1317+
<PoorPerformanceCard
1318+
poorPerformancePredictions={poorPerformancePredictions}
1319+
isLoading={poorPerformanceLoading}
1320+
teams={teamData}
1321+
/>
1322+
12681323

12691324
{/* Team Last Result Cards */}
12701325
<TeamComingOffWinCard

0 commit comments

Comments
 (0)