@golstats/gsc-reports 1.0.79 → 1.0.81

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@golstats/gsc-reports",
3
- "version": "1.0.79",
3
+ "version": "1.0.81",
4
4
  "main": "dist/gsc-reports.umd.js",
5
5
  "module": "dist/gsc-reports.es.js",
6
6
  "exports": {
@@ -47,7 +47,7 @@
47
47
  },
48
48
  "dependencies": {
49
49
  "@golstats/gsc-checkbox": "^1.0.13",
50
- "@golstats/gsc-template-report-maker": "^1.0.112",
50
+ "@golstats/gsc-template-report-maker": "^1.0.115",
51
51
  "axios": "^1.10.0",
52
52
  "gridstack": "^12.1.1",
53
53
  "tiny-emitter": "^2.1.0",
@@ -215,6 +215,11 @@ const props = defineProps({
215
215
  required: false,
216
216
  default: null,
217
217
  },
218
+ gameId: {
219
+ type: [String, Number],
220
+ required: false,
221
+ default: null,
222
+ },
218
223
  })
219
224
 
220
225
  const emit = defineEmits(['update:modelValue'])
@@ -326,9 +331,9 @@ watch(
326
331
  { deep: true },
327
332
  )
328
333
 
329
- // Recargar fortalezas cuando cambien seasonId, teamId o token
334
+ // Recargar fortalezas cuando cambien seasonId, teamId, gameId o token
330
335
  watch(
331
- () => [props.seasonId, props.teamId, props.token],
336
+ () => [props.seasonId, props.teamId, props.gameId, props.token],
332
337
  () => {
333
338
  fetchFortalezas()
334
339
  },
@@ -366,7 +371,10 @@ async function fetchFortalezas() {
366
371
  error.value = null
367
372
 
368
373
  try {
369
- const url = `https://5c9xc3gwh2.execute-api.us-east-2.amazonaws.com/prod/strengths/seasons/${props.seasonId}/teams/${props.teamId}`
374
+ // Construir la URL: si hay gameId, usar la ruta con pregames, si no, usar la ruta sin pregames
375
+
376
+ const url = `https://5c9xc3gwh2.execute-api.us-east-2.amazonaws.com/prod/strengths/seasons/${props.seasonId}/pregames/${props.gameId}/teams/${props.teamId}`
377
+
370
378
  const response = await fetch(url, {
371
379
  method: 'GET',
372
380
  headers: {
@@ -381,17 +389,20 @@ async function fetchFortalezas() {
381
389
 
382
390
  const data = await response.json()
383
391
  console.log('data: ', data)
392
+ console.log('nUEVO NUEVO dataaaaaa: ----------->', data)
384
393
 
385
394
  // Guardar los datos originales del API
386
395
  fortalezasRawData.value = data.strengths || []
387
396
 
397
+ console.log('nUEVO NUEVO dataaaaaa:5555555555 ----------->', data.strengths)
398
+
388
399
  // Mapear los datos del API al formato esperado por el componente
389
400
  fortalezasData.value = data.strengths.map((item) => ({
390
401
  id: item.categories,
391
402
  name: item.name,
392
403
  value: item.total,
393
404
  category:
394
- item.category_type == 1 ? 'Ofensiva' : item.category_type == 2 ? 'Posesion' : 'Defensiva',
405
+ item.category_type == 1 ? 'Ofensiva' : item.category_type == 2 ? 'Defensiva' : 'Posesion',
395
406
  ranking: `#${item.league_ranking} en la liga`,
396
407
  color: getCategoryColor(item.category_type || 'General'),
397
408
  }))
@@ -95,9 +95,10 @@
95
95
  key="fortalezas-equipo"
96
96
  v-model="selectedFortalezasEquipo"
97
97
  team-initials="AME"
98
- :season-id="1772"
98
+ :season-id="props.partido?.season_id"
99
99
  :team-id="props.partido?.local || props.partido?.home_team"
100
100
  :rival-team-id="props.partido?.visita || props.partido?.visiting_team"
101
+ :game-id="props.partido?.game_id || props.partido?.id"
101
102
  :token="props.token"
102
103
  title="Fortalezas a favor de mi equipo"
103
104
  :total-fortalezas="fortalezasCounts.equipo"
@@ -112,9 +113,10 @@
112
113
  key="fortalezas-rival"
113
114
  v-model="selectedFortalezasRival"
114
115
  team-initials="RIV"
115
- :season-id="1772"
116
+ :season-id="props.partido?.season_id"
116
117
  :team-id="props.partido?.visita || props.partido?.visiting_team"
117
118
  :rival-team-id="props.partido?.local || props.partido?.home_team"
119
+ :game-id="props.partido?.game_id || props.partido?.id"
118
120
  :token="props.token"
119
121
  title="Fortalezas a favor del rival"
120
122
  :total-fortalezas="fortalezasCounts.rival"
@@ -266,7 +268,10 @@ function tieneComponenteFortalezas() {
266
268
  if (page.components && Array.isArray(page.components)) {
267
269
  // Buscar si existe algún componente con name === 'Fortalezas' o id === 15
268
270
  const tieneFortalezas = page.components.some(
269
- (component) => component.name === 'Fortalezas' || component.id === 15,
271
+ (component) =>
272
+ component.title === 'Fortalezas' ||
273
+ component.id === 15 ||
274
+ component.componentName === 'GSCStrengths',
270
275
  )
271
276
  if (tieneFortalezas) {
272
277
  return true
@@ -333,7 +338,11 @@ function contarFortalezas() {
333
338
  }
334
339
  }
335
340
  }
336
-
341
+ console.log('CONTADOR FINAL DE FORTALEZAS: ', {
342
+ equipo: countEquipo,
343
+ rival: countRival,
344
+ total: countEquipo + countRival,
345
+ })
337
346
  return {
338
347
  equipo: countEquipo,
339
348
  rival: countRival,
@@ -672,21 +681,35 @@ function buildStrengthsPayload() {
672
681
 
673
682
  // Verificar si la página tiene components
674
683
  if (page.components && Array.isArray(page.components)) {
675
- // Buscar componentes Fortalezas
684
+ // Buscar componentes Fortalezas - usar la misma condición que en contarFortalezas
676
685
  page.components.forEach((component, componentIndex) => {
677
- if (component.name === 'Fortalezas' || component.id === 15) {
686
+ const esComponenteFortalezas =
687
+ component.componentName === 'GSCStrengths' ||
688
+ component.id === 15 ||
689
+ component.name === 'Fortalezas' ||
690
+ component.title === 'Fortalezas'
691
+
692
+ if (esComponenteFortalezas) {
678
693
  const componentNumber = componentIndex + 1 // Los índices de componente empiezan en 1
679
- console.log(`\n--- Componente ${componentNumber} (Fortalezas) ---`)
694
+ console.log(
695
+ `\n--- Componente ${componentNumber} (Fortalezas) en página ${pageNumber} ---`,
696
+ )
680
697
  console.log('Component:', component)
698
+ console.log('Component properties:', {
699
+ name: component.name,
700
+ title: component.title,
701
+ componentName: component.componentName,
702
+ id: component.id,
703
+ })
681
704
  console.log('dynamicFilters:', component.dynamicFilters)
682
705
 
683
706
  // Verificar dynamicFilters para determinar tipo y cantidad
684
707
  if (component.dynamicFilters && Array.isArray(component.dynamicFilters)) {
685
- const teamType = component.dynamicFilters[0] // 1 = equipo, 2 = rival
708
+ const teamType = component.dynamicFilters[0] // 1 = equipo, 2 = rival, 3 = dinámico
686
709
  const cantidadRequerida = component.dynamicFilters[1] || 0 // Cantidad de fortalezas necesarias
687
710
 
688
711
  console.log(
689
- `Tipo: ${teamType === 1 ? 'Equipo' : 'Rival'}, Cantidad requerida: ${cantidadRequerida}`,
712
+ `Tipo: ${teamType === 1 ? 'Equipo' : teamType === 2 ? 'Rival' : 'Dinámico (3)'}, Cantidad requerida: ${cantidadRequerida}`,
690
713
  )
691
714
 
692
715
  // Obtener las fortalezas según el tipo
@@ -738,6 +761,51 @@ function buildStrengthsPayload() {
738
761
  }
739
762
  indexRival += cantidadRequerida
740
763
  teamId = props.partido?.visita || props.partido?.visiting_team
764
+ } else if (teamType === 3) {
765
+ // Tipo dinámico: depende de filterMultiple.isHomeTeam
766
+ if (component.filterMultiple && component.filterMultiple.isHomeTeam) {
767
+ // Es equipo
768
+ fortalezasOrdenadas = fortalezasEquipoOrdenadas
769
+ console.log(
770
+ `Dinámico (Equipo): Total ordenadas=${fortalezasOrdenadas.length}, index=${indexEquipo}, cantidad requerida=${cantidadRequerida}`,
771
+ )
772
+ if (fortalezasOrdenadas.length > indexEquipo) {
773
+ fortalezasAsignar = fortalezasOrdenadas.slice(
774
+ indexEquipo,
775
+ indexEquipo + cantidadRequerida,
776
+ )
777
+ console.log(
778
+ `Index equipo: ${indexEquipo}, tomando ${fortalezasAsignar.length} fortalezas de ${fortalezasOrdenadas.length} disponibles`,
779
+ )
780
+ } else {
781
+ console.warn(
782
+ `No hay suficientes fortalezas de equipo. Disponibles: ${fortalezasOrdenadas.length}, Necesarias desde índice: ${indexEquipo}`,
783
+ )
784
+ }
785
+ indexEquipo += cantidadRequerida
786
+ teamId = props.partido?.local || props.partido?.home_team || props.team
787
+ } else {
788
+ // Es rival
789
+ fortalezasOrdenadas = fortalezasRivalOrdenadas
790
+ console.log(
791
+ `Dinámico (Rival): Total ordenadas=${fortalezasOrdenadas.length}, index=${indexRival}, cantidad requerida=${cantidadRequerida}`,
792
+ )
793
+ if (fortalezasOrdenadas.length > indexRival) {
794
+ fortalezasAsignar = fortalezasOrdenadas.slice(
795
+ indexRival,
796
+ indexRival + cantidadRequerida,
797
+ )
798
+ console.log(
799
+ `Index rival: ${indexRival}, tomando ${fortalezasAsignar.length} fortalezas de ${fortalezasOrdenadas.length} disponibles`,
800
+ )
801
+ } else {
802
+ console.warn(
803
+ `No hay suficientes fortalezas de rival. Disponibles: ${fortalezasOrdenadas.length}, Necesarias desde índice: ${indexRival}`,
804
+ )
805
+ }
806
+ indexRival += cantidadRequerida
807
+ teamId = props.partido?.visita || props.partido?.visiting_team
808
+ }
741
809
  }
742
810
 
743
811
  console.log('fortalezasAsignar:', fortalezasAsignar)
@@ -770,15 +838,29 @@ function buildStrengthsPayload() {
770
838
  team_contribution: strength.team_contribution || 0,
771
839
  })
772
840
  })
773
- console.log(`✓ Agregadas ${fortalezasAsignar.length} fortalezas al payload`)
841
+ console.log(
842
+ `✓ Agregadas ${fortalezasAsignar.length} fortalezas al payload para componente ${componentNumber} en página ${pageNumber}`,
843
+ )
844
+ console.log(
845
+ `Payload actual para página ${pageNumber}:`,
846
+ JSON.stringify(payload[pageNumber], null, 2),
847
+ )
774
848
  } else {
775
- console.warn('No hay fortalezas para asignar a este componente')
849
+ console.warn(
850
+ `⚠️ No hay fortalezas para asignar al componente ${componentNumber} en página ${pageNumber}. IndexEquipo: ${indexEquipo}, IndexRival: ${indexRival}`,
851
+ )
776
852
  }
777
853
  } else {
778
- console.warn('Componente no tiene dynamicFilters válido')
854
+ console.warn(
855
+ `⚠️ Componente ${componentIndex + 1} en página ${pageNumber} no tiene dynamicFilters válido`,
856
+ )
857
+ console.warn('Component:', component)
779
858
  }
780
859
  }
781
860
  })
861
+ console.log(
862
+ `\n✓ Página ${pageNumber} procesada. Componentes de Fortalezas encontrados y procesados.`,
863
+ )
782
864
  }
783
865
  })
784
866