index.jsx 679 Bytes
Newer Older
Azizov Aziz 's avatar
Azizov Aziz committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
import React from 'react'
import { connect } from 'react-redux'
import { MainPage, TgAccountSettingsPage, BillingPage, CallCard } from '../pages'

const mapStateToProps = (state) => ({
  path: state.__route.current.path,
  datas: state.__route.current.datas,
})

const AppRouter = ({path, datas}) => {
  const render = Component => <Component {...datas} />

  switch (path) {
    case 'settings':
      return render(TgAccountSettingsPage)
    case 'billing':
      return render(BillingPage)
    case 'plc_call_card':
      return render(CallCard)
    default:
      return render(MainPage)
  }
}

export default connect(mapStateToProps, null)(AppRouter)