@golstats/gsc-timeline-reports 1.0.7 → 1.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -101,19 +101,46 @@ const scrollContainer = ref(null)
101
101
 
102
102
  // --- NUEVO: Datos dummy para modo default ---
103
103
  const dummyEvents = [
104
+ // Primer tiempo (0-45)
104
105
  {
105
- minute: 16,
106
+ minute: 5,
106
107
  match_lapse: 1,
107
108
  event: [
108
109
  {
109
- minute: 16,
110
- minuteLabel: '16',
110
+ minute: 5,
111
+ minuteLabel: '5',
112
+ icon: 'icon-yellow-card',
113
+ team: 'visitante',
114
+ match_lapse: 1,
115
+ },
116
+ ],
117
+ },
118
+ {
119
+ minute: 12,
120
+ match_lapse: 1,
121
+ event: [
122
+ {
123
+ minute: 12,
124
+ minuteLabel: '12',
111
125
  icon: 'icon-goal',
112
126
  team: 'local',
113
127
  match_lapse: 1,
114
128
  },
115
129
  ],
116
130
  },
131
+ {
132
+ minute: 18,
133
+ match_lapse: 1,
134
+ event: [
135
+ {
136
+ minute: 18,
137
+ minuteLabel: '18',
138
+ icon: 'icon-yellow-card',
139
+ team: 'local',
140
+ match_lapse: 1,
141
+ },
142
+ ],
143
+ },
117
144
  {
118
145
  minute: 25,
119
146
  match_lapse: 1,
@@ -127,19 +154,73 @@ const dummyEvents = [
127
154
  },
128
155
  ],
129
156
  },
157
+ {
158
+ minute: 32,
159
+ match_lapse: 1,
160
+ event: [
161
+ {
162
+ minute: 32,
163
+ minuteLabel: '32',
164
+ icon: 'icon-goal',
165
+ team: 'visitante',
166
+ match_lapse: 1,
167
+ },
168
+ ],
169
+ },
170
+ {
171
+ minute: 38,
172
+ match_lapse: 1,
173
+ event: [
174
+ {
175
+ minute: 38,
176
+ minuteLabel: '38',
177
+ icon: 'icon-change',
178
+ team: 'local',
179
+ match_lapse: 1,
180
+ },
181
+ ],
182
+ },
183
+ {
184
+ minute: 42,
185
+ match_lapse: 1,
186
+ event: [
187
+ {
188
+ minute: 42,
189
+ minuteLabel: '42',
190
+ icon: 'icon-yellow-card',
191
+ team: 'visitante',
192
+ match_lapse: 1,
193
+ },
194
+ ],
195
+ },
196
+ // Medio tiempo (45)
130
197
  {
131
198
  minute: 45,
132
199
  match_lapse: 1,
133
200
  event: [
134
201
  {
135
202
  minute: 45,
136
- minuteLabel: '45',
203
+ minuteLabel: 'MT',
137
204
  icon: 'icon-change',
138
205
  team: 'local',
139
206
  match_lapse: 1,
140
207
  },
141
208
  ],
142
209
  },
210
+ // Segundo tiempo (45-90)
211
+ {
212
+ minute: 48,
213
+ match_lapse: 2,
214
+ event: [
215
+ {
216
+ minute: 48,
217
+ minuteLabel: '48',
218
+ icon: 'icon-yellow-card',
219
+ team: 'local',
220
+ match_lapse: 2,
221
+ },
222
+ ],
223
+ },
143
224
  {
144
225
  minute: 55,
145
226
  match_lapse: 2,
@@ -153,13 +234,78 @@ const dummyEvents = [
153
234
  },
154
235
  ],
155
236
  },
237
+ {
238
+ minute: 62,
239
+ match_lapse: 2,
240
+ event: [
241
+ {
242
+ minute: 62,
243
+ minuteLabel: '62',
244
+ icon: 'icon-change',
245
+ team: 'visitante',
246
+ match_lapse: 2,
247
+ },
248
+ ],
249
+ },
250
+ {
251
+ minute: 68,
252
+ match_lapse: 2,
253
+ event: [
254
+ {
255
+ minute: 68,
256
+ minuteLabel: '68',
257
+ icon: 'icon-yellow-card',
258
+ team: 'visitante',
259
+ match_lapse: 2,
260
+ },
261
+ ],
262
+ },
263
+ {
264
+ minute: 75,
265
+ match_lapse: 2,
266
+ event: [
267
+ {
268
+ minute: 75,
269
+ minuteLabel: '75',
270
+ icon: 'icon-goal',
271
+ team: 'local',
272
+ match_lapse: 2,
273
+ },
274
+ ],
275
+ },
276
+ {
277
+ minute: 82,
278
+ match_lapse: 2,
279
+ event: [
280
+ {
281
+ minute: 82,
282
+ minuteLabel: '82',
283
+ icon: 'icon-red-card',
284
+ team: 'local',
285
+ match_lapse: 2,
286
+ },
287
+ ],
288
+ },
289
+ {
290
+ minute: 87,
291
+ match_lapse: 2,
292
+ event: [
293
+ {
294
+ minute: 87,
295
+ minuteLabel: '87',
296
+ icon: 'icon-yellow-card',
297
+ team: 'visitante',
298
+ match_lapse: 2,
299
+ },
300
+ ],
301
+ },
156
302
  {
157
303
  minute: 90,
158
304
  match_lapse: 2,
159
305
  event: [
160
306
  {
161
307
  minute: 90,
162
- minuteLabel: '80',
308
+ minuteLabel: '90',
163
309
  icon: 'icon-goal',
164
310
  team: 'local',
165
311
  match_lapse: 2,
@@ -213,18 +359,47 @@ function calculateMaxMinute() {
213
359
  // Función para obtener los datos del partido
214
360
  async function fetchGameData() {
215
361
  if (props.isDefault) {
216
- // Si es default, usar los eventos dummy
217
- timelineMinutes.value = dummyEvents
218
- events.value = dummyEvents.map((minute) => minute.event)
362
+ // Si es default, usar los eventos dummy pero filtrarlos según las props
363
+ const filteredDummyEvents = dummyEvents
364
+ .map((minute) => {
365
+ if (!minute.event) return minute
366
+
367
+ // Filtrar eventos según las props
368
+ const filteredEvents = minute.event.filter((event) => {
369
+ // Crear un objeto temporal con la estructura que espera shouldShowEvent
370
+ const tempEvent = {
371
+ event_type_id: getEventTypeFromIcon(event.icon),
372
+ category_id: getCategoryFromIcon(event.icon),
373
+ minute: event.minute,
374
+ match_lapse: event.match_lapse,
375
+ team_id: event.team === 'local' ? props.homeTeam : props.awayTeam,
376
+ comments: '',
377
+ }
378
+
379
+ return shouldShowEvent(tempEvent)
380
+ })
381
+
382
+ return {
383
+ ...minute,
384
+ event: filteredEvents.length > 0 ? filteredEvents : null,
385
+ }
386
+ })
387
+ .filter((minute) => minute.event !== null) // Solo incluir minutos que tengan eventos
388
+
389
+ timelineMinutes.value = filteredDummyEvents
390
+ events.value = filteredDummyEvents.map((minute) => minute.event)
391
+
219
392
  // Ajustar valores para los handlers y el rango
220
- minStart.value = dummyEvents[0].minute
221
- minEnd.value = dummyEvents[dummyEvents.length - 1].minute
222
- startTime.value = dummyEvents[0].match_lapse.toString()
223
- endTime.value = dummyEvents[dummyEvents.length - 1].match_lapse.toString()
224
- leftHandlePosition.value = 0
225
- rightHandlePosition.value = dummyEvents.length - 1
226
- secondHalfEndMinute.value = dummyEvents[dummyEvents.length - 1].minute
227
- minTotal.value = dummyEvents[dummyEvents.length - 1].minute
393
+ if (filteredDummyEvents.length > 0) {
394
+ minStart.value = filteredDummyEvents[0].minute
395
+ minEnd.value = filteredDummyEvents[filteredDummyEvents.length - 1].minute
396
+ startTime.value = filteredDummyEvents[0].match_lapse.toString()
397
+ endTime.value = filteredDummyEvents[filteredDummyEvents.length - 1].match_lapse.toString()
398
+ leftHandlePosition.value = 0
399
+ rightHandlePosition.value = filteredDummyEvents.length - 1
400
+ secondHalfEndMinute.value = filteredDummyEvents[filteredDummyEvents.length - 1].minute
401
+ minTotal.value = filteredDummyEvents[filteredDummyEvents.length - 1].minute
402
+ }
228
403
  updateRangeWidth()
229
404
  return
230
405
  }
@@ -270,6 +445,7 @@ async function fetchGameData() {
270
445
  (e.category_id === 9 ||
271
446
  e.category_id === 3 ||
272
447
  e.event_type_id === 1 ||
448
+ e.event_type_id === 2 ||
273
449
  e.category_id === 10 ||
274
450
  e.category_id === 13 ||
275
451
  (e.event_type_id === 6 &&
@@ -280,7 +456,12 @@ async function fetchGameData() {
280
456
  events.push({
281
457
  minute: event.minute,
282
458
  minuteLabel: event.event_type_id === 6 ? 'MT' : event.minute.toString(),
283
- icon: getEventIcon(event.event_type_id === 1 ? event.event_type_id : event.category_id),
459
+ icon: getEventIcon(
460
+ event.event_type_id === 1 || event.event_type_id === 2
461
+ ? event.event_type_id
462
+ : event.category_id,
463
+ event,
464
+ ),
284
465
  team:
285
466
  event.team_id === props.homeTeam
286
467
  ? event.category_id === 13
@@ -310,6 +491,7 @@ async function fetchGameData() {
310
491
  (e.category_id === 9 ||
311
492
  e.category_id === 3 ||
312
493
  e.event_type_id === 1 ||
494
+ e.event_type_id === 2 ||
313
495
  e.category_id === 10 ||
314
496
  e.category_id === 13),
315
497
  )
@@ -318,7 +500,12 @@ async function fetchGameData() {
318
500
  events.push({
319
501
  minute: event.minute,
320
502
  minuteLabel: event.event_type_id === 6 ? 'MT' : event.minute.toString(),
321
- icon: getEventIcon(event.event_type_id === 1 ? event.event_type_id : event.category_id),
503
+ icon: getEventIcon(
504
+ event.event_type_id === 1 || event.event_type_id === 2
505
+ ? event.event_type_id
506
+ : event.category_id,
507
+ event,
508
+ ),
322
509
  team:
323
510
  event.team_id === props.homeTeam
324
511
  ? event.category_id === 13
@@ -388,16 +575,53 @@ async function fetchGameData() {
388
575
  }
389
576
  }
390
577
 
578
+ // Función para obtener el tipo de evento desde el ícono (para datos dummy)
579
+ function getEventTypeFromIcon(icon) {
580
+ const iconToEventType = {
581
+ 'icon-goal': 1,
582
+ 'icon-yellow-card': 2,
583
+ 'icon-red-card': 9,
584
+ 'icon-change': 10,
585
+ }
586
+ return iconToEventType[icon] || 1
587
+ }
588
+
589
+ // Función para obtener la categoría desde el ícono (para datos dummy)
590
+ function getCategoryFromIcon(icon) {
591
+ const iconToCategory = {
592
+ 'icon-goal': 3,
593
+ 'icon-yellow-card': 9,
594
+ 'icon-red-card': 9,
595
+ 'icon-change': 10,
596
+ }
597
+ return iconToCategory[icon] || 3
598
+ }
599
+
391
600
  // Función para determinar el icono según el tipo de evento
392
- function getEventIcon(eventTypeId) {
601
+ function getEventIcon(eventTypeId, event) {
393
602
  const iconMap = {
394
603
  3: 'icon-goal',
395
604
  1: 'icon-goal',
396
605
  13: 'icon-goal',
606
+ 2: 'icon-yellow-card',
397
607
  10: 'icon-change',
398
- 9: 'icon-red-card',
399
608
  // Agregar más mapeos según sea necesario
400
609
  }
610
+
611
+ // Para event_type_id === 2, siempre es tarjeta amarilla
612
+ if (eventTypeId === 2) {
613
+ return 'icon-yellow-card'
614
+ }
615
+
616
+ // Para category_id 9, diferenciar entre amarilla y roja basado en comentarios
617
+ if (eventTypeId === 9) {
618
+ if (event && event.comments && event.comments.includes('roja')) {
619
+ return 'icon-red-card'
620
+ } else {
621
+ return 'icon-yellow-card'
622
+ }
623
+ }
624
+
401
625
  return iconMap[eventTypeId] || '' // Por defecto retorna icon-goal
402
626
  }
403
627
 
@@ -420,8 +644,8 @@ function shouldShowEvent(event) {
420
644
  return true
421
645
  }
422
646
 
423
- // Tarjetas amarillas: category_id === 9 (pero no rojas)
424
- if (event.category_id === 9 && !event.comments?.includes('roja')) {
647
+ // Tarjetas amarillas: event_type_id === 2 o category_id === 9 (pero no rojas)
648
+ if (event.event_type_id === 2 || (event.category_id === 9 && !event.comments?.includes('roja'))) {
425
649
  if (!props.yellowCards) {
426
650
  console.log('Filtrando tarjeta amarilla:', event)
427
651
  return false