10
10
See the License for the specific language governing permissions and
11
11
limitations under the License.
12
12
*/
13
- import { Box } from '@mui/material' ;
13
+ import { Box , InputProps , Tab , Tabs } from '@mui/material' ;
14
14
import { useEffect , useState , SyntheticEvent } from 'react' ;
15
15
import DataTable , { TableDataRow } from './DataTable' ;
16
16
import GsMap , { GsValue } from './GsMap' ;
17
17
import { useRecoilRefresher_UNSTABLE , useRecoilValue } from 'recoil' ;
18
18
import GlobalState from '../GlobalState' ;
19
19
import styles from './main.module.scss' ;
20
20
import Chart , { TimeSlot } from './Chart' ;
21
- import { BrowserRouter , Outlet , Route , Routes , Link } from 'react-router-dom' ;
21
+
22
22
23
23
24
24
interface GasPriceAvgs {
@@ -95,30 +95,9 @@ interface TimeSlotResponse {
95
95
CountyDataID : number ;
96
96
}
97
97
98
- interface TabPanelProps {
99
- children ?: React . ReactNode ;
100
- index : number ;
101
- value : number ;
102
- }
103
-
104
- function TabPanel ( props : TabPanelProps ) {
105
- const { children, value, index, ...other } = props ;
106
-
107
- return (
108
- < div
109
- role = "tabpanel"
110
- hidden = { value !== index }
111
- id = { `simple-tabpanel-${ index } ` }
112
- aria-labelledby = { `simple-tab-${ index } ` }
113
- { ...other }
114
- >
115
- { value === index && (
116
- < Box sx = { { p : 3 } } className = { styles . myText } >
117
- { children }
118
- </ Box >
119
- ) }
120
- </ div >
121
- ) ;
98
+ interface TargetAreaProperties {
99
+ rows : TableDataRow [ ] ;
100
+ timeSlots : TimeSlot [ ] ;
122
101
}
123
102
124
103
export default function Main ( ) {
@@ -242,69 +221,27 @@ export default function Main() {
242
221
. then ( ( ) => setController ( null ) ) ;
243
222
}
244
223
245
- const Area = ( ) => {
246
- return (
247
- < >
248
- < DataTable diesel = 'Diesel' e10 = 'E10' e5 = 'E5' location = 'Location' showAverages = { true } time = 'Time' rows = { rows } > </ DataTable >
249
- </ >
250
- )
251
- } ;
252
-
253
- const Target = ( ) => {
254
- return (
255
- < >
256
- < Chart timeSlots = { avgTimeSlots } > </ Chart >
257
- < DataTable diesel = 'Diesel' e10 = 'E10' e5 = 'E5' location = 'Location' showAverages = { true } time = 'Time' rows = { rows } > </ DataTable >
258
- </ >
259
- )
260
- }
261
-
262
- const Map = ( ) => {
263
- return (
264
- < >
265
- < GsMap gsValues = { gsValues } center = { globalUserDataState } > </ GsMap >
266
- </ >
267
- )
268
- }
269
-
270
- const Layout = ( ) => {
271
- return (
272
- < >
273
- < div className = { styles . headerTabs } >
274
- < div className = { styles . headerTab } >
275
- < Link className = { styles . linkText } to = "/area" > Area Gas Prices</ Link >
276
- </ div >
277
- < div className = { styles . headerTab } >
278
- < Link className = { styles . linkText } to = "/target" > Target Gas Prices</ Link >
279
- </ div >
280
- < div className = { styles . headerTab } >
281
- < Link className = { styles . linkText } to = "/map" > Map Gas Prices</ Link >
282
- </ div >
283
- </ div >
284
- < Outlet />
285
- </ >
286
- ) ;
287
- }
288
-
289
224
// eslint-disable-next-line
290
225
useEffect ( ( ) => {
291
226
if ( globalJwtTokenState ?. length > 10 && globalUserUuidState ?. length > 10 && first ) {
292
- setTimeout ( ( ) => handleTabChange ( { } as unknown as SyntheticEvent , value ) , 3000 ) ;
227
+ setTimeout ( ( ) => handleTabChange ( { } as unknown as SyntheticEvent , value ) , 3000 ) ;
293
228
setFirst ( false ) ;
294
229
}
295
230
} ) ;
296
231
297
232
return ( < Box sx = { { width : '100%' } } >
298
- < BrowserRouter >
299
- < Routes >
300
- < Route path = "/" element = { < Layout /> } >
301
- < Route index element = { < Area /> } />
302
- < Route path = "area" element = { < Area /> } />
303
- < Route path = "target" element = { < Target /> } />
304
- < Route path = "map" element = { < Map /> } />
305
- < Route path = "*" element = { < Area /> } />
306
- </ Route >
307
- </ Routes >
308
- </ BrowserRouter >
233
+ < Tabs value = { value } onChange = { handleTabChange } centered = { true } >
234
+ < Tab label = "Current Prices" />
235
+ < Tab label = "Last Price matches" />
236
+ < Tab label = "Current Prices Map" />
237
+ </ Tabs >
238
+ { value === 0 &&
239
+ < DataTable diesel = 'Diesel' e10 = 'E10' e5 = 'E5' location = 'Location' showAverages = { true } time = 'Time' rows = { rows } > </ DataTable > }
240
+ { value === 1 &&
241
+ < Chart timeSlots = { avgTimeSlots } > </ Chart > }
242
+ { value === 1 &&
243
+ < DataTable diesel = 'Diesel' e10 = 'E10' e5 = 'E5' location = 'Location' showAverages = { true } time = 'Time' rows = { rows } > </ DataTable > }
244
+ { value === 2 &&
245
+ < GsMap gsValues = { gsValues } center = { globalUserDataState } > </ GsMap > }
309
246
</ Box > ) ;
310
247
}
0 commit comments