@@ -9,6 +9,9 @@ import { useTeamFilter } from './TeamFilterContext';
9
9
// Import reusable tooltip utilities
10
10
import { createSafeId } from './utils/tooltipUtils' ;
11
11
12
+ import PoorPerformanceCard from './cards/PoorPerformanceCard/PoorPerformanceCard' ;
13
+
14
+
12
15
// Import individual card components
13
16
import StatsSummaryCard from './cards/StatsSummaryCard/StatsSummaryCard' ;
14
17
import HRPredictionCard from './cards/HRPredictionCard/HRPredictionCard' ;
@@ -129,6 +132,9 @@ function Dashboard({ playerData, teamData, gameData, currentDate }) {
129
132
fridayHitLeaders : [ ]
130
133
} ) ;
131
134
135
+ const [ poorPerformancePredictions , setPoorPerformancePredictions ] = useState ( [ ] ) ;
136
+ const [ poorPerformanceLoading , setPoorPerformanceLoading ] = useState ( true ) ;
137
+
132
138
// Simple effect to populate slot machine data from existing sources
133
139
useEffect ( ( ) => {
134
140
const populateSlotMachineData = ( ) => {
@@ -179,6 +185,55 @@ function Dashboard({ playerData, teamData, gameData, currentDate }) {
179
185
loadStadiumData ( ) ;
180
186
} , [ currentDate ] ) ;
181
187
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
+
182
237
// Filter player data based on team selection
183
238
const filteredPlayerData = useMemo ( ( ) => {
184
239
if ( ! isFiltering ) return playerData ;
@@ -1259,12 +1314,12 @@ const noFilteredData = isFiltering &&
1259
1314
/>
1260
1315
1261
1316
{ /* 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
+
1268
1323
1269
1324
{ /* Team Last Result Cards */ }
1270
1325
< TeamComingOffWinCard
0 commit comments