1010 See the License for the specific language governing permissions and
1111 limitations under the License.
1212*/
13- import { Box } from '@mui/material' ;
13+ import { Box , InputProps , Tab , Tabs } from '@mui/material' ;
1414import { useEffect , useState , SyntheticEvent } from 'react' ;
1515import DataTable , { TableDataRow } from './DataTable' ;
1616import GsMap , { GsValue } from './GsMap' ;
1717import { useRecoilRefresher_UNSTABLE , useRecoilValue } from 'recoil' ;
1818import GlobalState from '../GlobalState' ;
1919import styles from './main.module.scss' ;
2020import Chart , { TimeSlot } from './Chart' ;
21- import { BrowserRouter , Outlet , Route , Routes , Link } from 'react-router-dom' ;
21+
2222
2323
2424interface GasPriceAvgs {
@@ -95,30 +95,9 @@ interface TimeSlotResponse {
9595 CountyDataID : number ;
9696}
9797
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 [ ] ;
122101}
123102
124103export default function Main ( ) {
@@ -242,69 +221,27 @@ export default function Main() {
242221 . then ( ( ) => setController ( null ) ) ;
243222 }
244223
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-
289224 // eslint-disable-next-line
290225 useEffect ( ( ) => {
291226 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 ) ;
293228 setFirst ( false ) ;
294229 }
295230 } ) ;
296231
297232 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 > }
309246 </ Box > ) ;
310247}
0 commit comments