@@ -2,54 +2,16 @@ import { useState, useEffect } from 'react';
2
2
import React from 'react' ;
3
3
import PropTypes from 'prop-types' ;
4
4
import { NPOBackend } from '../../utils/auth_utils' ;
5
- import { Select } from '@chakra-ui/react' ;
5
+ import { Box , Select } from '@chakra-ui/react' ;
6
6
import './StatTable.css' ;
7
7
8
8
const StatTable = ( { season, allSeasons } ) => {
9
9
const [ stats , setStats ] = useState ( [ ] ) ;
10
- // const currSeason = season.split(' ')[0];
11
- // const currYear = season.split(' ')[1];
12
- // const [selectedSeason, setSelectedSeason] = useState(currSeason.toLowerCase());
13
- // const [selectedYear, setSelectedYear] = useState(currYear);
14
- // const [allSeasons, setAllSeasons] = useState([]);
15
- const [ selectedSeason , setSelectedSeason ] = useState ( '' ) ;
16
- // const uniqueSeasons = Array.from(new Set(allSeasons.map(season => season.split(' ')[0])));
17
- // const uniqueYears = Array.from(new Set(allSeasons.map(seasonYear => seasonYear.split(' ')[1])));
18
- // const toast = useToast();
19
-
20
- console . log ( season , allSeasons ) ;
21
-
22
- // useEffect(() => {
23
- // const renderTable = async () => {
24
- // const { data } = await NPOBackend.get('/published-schedule/all-seasons');
25
- // if (data.indexOf(curSeason) == -1) {
26
- // data.unshift(curSeason);
27
- // }
28
-
29
- // setSelectedSeason(curSeason);
30
-
31
- // const seasonOrder = ['Fall', 'Summer', 'Spring'];
32
- // data.sort((a, b) => {
33
- // // Compare years first
34
- // if (a.split(' ')[1] !== b.split(' ')[1]) {
35
- // return b.split(' ')[1] - a.split(' ')[1];
36
- // } else {
37
- // return seasonOrder.indexOf(a.split(' ')[0]) - seasonOrder.indexOf(b.split(' ')[0]);
38
- // }
39
- // });
40
-
41
- // setAllSeasons(data);
42
-
43
- // };
44
- // renderTable();
45
- // }, [curSeason]);
10
+ const [ selectedSeason , setSelectedSeason ] = useState ( season ) ;
46
11
47
12
useEffect ( ( ) => {
48
13
const fetchStats = async ( ) => {
49
14
try {
50
- if ( ! selectedSeason ) {
51
- setSelectedSeason ( season ) ;
52
- }
53
15
const curSeason = selectedSeason . split ( ' ' ) [ 0 ] ;
54
16
const curYear = selectedSeason . split ( ' ' ) [ 1 ] ;
55
17
const response = await NPOBackend . get ( `/published-schedule/stats?season=${ curSeason . toLowerCase ( ) } &year=${ curYear } ` ) ;
@@ -63,30 +25,6 @@ const StatTable = ({ season, allSeasons }) => {
63
25
fetchStats ( ) ;
64
26
} , [ selectedSeason ] ) ;
65
27
66
- // const showToast = (title, description) => {
67
- // toast({
68
- // title,
69
- // description,
70
- // status: 'success',
71
- // duration: 2000,
72
- // isClosable: true,
73
- // position: 'top',
74
- // colorScheme: 'blue'
75
- // });
76
- // };
77
-
78
- // const handleSeasonChange = (event) => {
79
- // const newSeason = event.target.value;
80
- // setSelectedSeason(newSeason);
81
- // showToast('Season Changed', `${newSeason.toUpperCase()}`);
82
- // };
83
-
84
- // const handleYearChange = (event) => {
85
- // const newYear = event.target.value;
86
- // setSelectedYear(newYear);
87
- // showToast('Year Changed', `Selected year changed to ${newYear}`);
88
- // };
89
-
90
28
const transformData = ( ) => {
91
29
const transformedData = { } ;
92
30
@@ -108,30 +46,13 @@ const StatTable = ({ season, allSeasons }) => {
108
46
const transformedStats = transformData ( ) ;
109
47
110
48
return (
111
- < div className = 'container' >
112
- < div className = 'select-container' >
113
- { /* <Select variant='filled' size='md' width = '200px' marginTop='20px' marginRight='20px' transition='all 0.3s ease' value={selectedSeason} onChange={handleSeasonChange}>
114
- {uniqueSeasons.map((season) => (
115
- <option key={season} value={season.toLowerCase()}>
116
- {season}
117
- </option>
118
- ))}
119
- </Select>
120
- <Select variant='filled' size='md' width='200px' marginTop='20px' value={selectedYear} onChange={handleYearChange}>
121
- {uniqueYears.map((seasonYear) => (
122
- <option key={seasonYear} value={seasonYear}>
123
- {seasonYear}
124
- </option>
125
- ))}
126
- </Select> */ }
49
+ < Box >
50
+ < Box mt = "1rem" >
127
51
< Select
128
- mb = "3vh"
129
- variant = "unstyled"
130
52
textColor = "black"
131
- placeholder = { allSeasons . indexOf ( season ) === - 1 && season }
132
53
value = { selectedSeason }
133
54
onChange = { ( e ) => setSelectedSeason ( e . target . value ) }
134
- width = "23% "
55
+ width = "max-content "
135
56
>
136
57
{ allSeasons . map ( item => (
137
58
< option key = { item } value = { item } >
@@ -140,7 +61,7 @@ const StatTable = ({ season, allSeasons }) => {
140
61
) )
141
62
}
142
63
</ Select >
143
- </ div >
64
+ </ Box >
144
65
< div className = 'table-container' >
145
66
< table >
146
67
< thead >
@@ -166,7 +87,7 @@ const StatTable = ({ season, allSeasons }) => {
166
87
</ tbody >
167
88
</ table >
168
89
</ div >
169
- </ div >
90
+ </ Box >
170
91
) ;
171
92
} ;
172
93
0 commit comments