Skip to content
This repository was archived by the owner on Jun 28, 2021. It is now read-only.
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
#372 colon separated surah/ayah
  • Loading branch information
thabti committed Jul 3, 2016
commit 52227a0e8d1fd5e8c627dca5b3bec0352a9c61d6
25 changes: 10 additions & 15 deletions src/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,35 +5,30 @@ import Route from 'react-router/lib/Route';
import checkValidSurah from './utils/checkValidSurah';
import App from './containers/App';

function getComponentByName(name) {
return (nextState, cb) => System.import(`./containers/${name}`).then(module => cb(null, module)).catch(err => console.trace(err));
}


export default () => (
<Route path="/" component={App}>
<IndexRoute getComponent={getComponentByName('Home')} />Donations
<IndexRoute getComponent={(nextState, cb) => System.import('./containers/Home').then(module => cb(null, module))} />

<Route path="/donations" getComponent={getComponentByName('Donations')} />
<Route path="/contributions" getComponent={getComponentByName('Donations')} />
<Route path="/donations" getComponent={(nextState, cb) => System.import('./containers/Donations').then(module => cb(null, module))} />
<Route path="/contributions" getComponent={(nextState, cb) => System.import('./containers/Donations').then(module => cb(null, module))} />

<Route path="/about" getComponent={getComponentByName('About')} />
<Route path="/about" getComponent={(nextState, cb) => System.import('./containers/About').then(module => cb(null, module))} />

<Route path="/contact" getComponent={getComponentByName('Contact')} />
<Route path="/contactus" getComponent={getComponentByName('Contact')} />
<Route path="/error/:errorKey" getComponent={getComponentByName('Error')} />
<Route path="/contact" getComponent={(nextState, cb) => System.import('./containers/Contact').then(module => cb(null, module))} />
<Route path="/contactus" getComponent={(nextState, cb) => System.import('./containers/Contact').then(module => cb(null, module))} />
<Route path="/error/:errorKey" getComponent={(nextState, cb) => System.import('./containers/Error').then(module => cb(null, module))} />

<Route path="/search" getComponent={getComponentByName('Search')} />
<Route path="/search" getComponent={(nextState, cb) => System.import('./containers/Search').then(module => cb(null, module))} />

<Route
path="/:surahId:(:range)"
getComponent={getComponentByName('Surah')}
getComponent={(nextState, cb) => System.import('./containers/Surah').then(module => cb(null, module)).catch(err => console.trace(err))}
onEnter={checkValidSurah}
/>

<Route
path="/:surahId(/:range)"
getComponent={getComponentByName('Surah')}
getComponent={(nextState, cb) => System.import('./containers/Surah').then(module => cb(null, module)).catch(err => console.trace(err))}
onEnter={checkValidSurah}
/>
</Route>
Expand Down