// LIBRARIES
import React, { Component } from 'react';
import { Switch, Route } from 'react-router-dom';
 
// COMPONENTS
import StationList from './List';
import StationCreate from './Create'

import MainContent from 'components/Dashboard/Layout/components/MainContent';
import { PAGE404 } from "components/PageError/index"
import EditStation from './Edit';
 
class StationLocator extends Component {
  state = {
    pageRoutes: [ 
      {
        path: `${this.props.match.url}`,
        name: "Station List",
        component: StationList,
      },
      {
        path: `${this.props.match.url}/create`,
        name: "Add Station",
        component: StationCreate,
      },
      {
        path: `${this.props.match.url}/view`,
        params: '1',
        name: "Edit Station",
        component: EditStation,
      }
    ],  
  }

  render() {  
    const { pageRoutes } = this.state        
    console.log('here')
    return (
      <div style={{position: 'relative'}}>
        <MainContent pageRoutes={pageRoutes}>
          <Switch>
            <Route exact path = "/stations" component = { StationList } />
            <Route exact path = "/stations/create" component = { StationCreate } />
            <Route exact path = "/stations/view/:id" component = { EditStation} />
            {/* <Route exact path = "/promotions/view/:id" component = { PromotionsView } /> */}
            <PAGE404 />
          </Switch>
        </MainContent>
      </div>
    );
  }
}

export default StationLocator;