This repository was archived by the owner on Jun 28, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 371
Fixes #248 Out of range bug #336
Merged
Merged
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
5ae212a
fix(redirect to home page on invalid surah)
37fb458
chore(add errror page)
7e4c334
(finishes #248) handles the surah invalid from the componentWillMount
abiodun0 00d94df
fixes for #248 with respect to @mmahalwy comments
abiodun0 be24d92
more fixes #248
abiodun0 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| NODE_ENV=development | ||
| PORT=8000 | ||
| API_URL=http://quran.com:3000 | ||
| API_URL=http://api.quran.com:3000 | ||
| SEGMENTS_KEY= | ||
| SENTRY_KEY_CLIENT= | ||
| SENTRY_KEY_SERVER= |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| import React, { Component } from 'react'; | ||
| import IndexHeader from '../../components/IndexHeader'; | ||
| import Link from 'react-router/lib/Link'; | ||
| import Helmet from 'react-helmet'; | ||
|
|
||
| export default ({params}) => { | ||
| const error = { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Alignment is off? |
||
| 'invalid-surah': 'Surah is out of range', | ||
| 'invalid-ayah-range': 'Ayah(s) selected are out of range' | ||
| } | ||
| return ( | ||
| <div> | ||
| <Helmet title={`Error ${params.errorTitle}`} /> | ||
| <IndexHeader noSearch={true} /> | ||
| <div className="container-fluid about-text"> | ||
| <div className="row"> | ||
| <div className="col-md-8 col-md-offset-2"> | ||
| <h4 className="source-sans"> | ||
| {error[params.errorKey]}. Please go to the <a href="/">home page </a>and select a surah/Ayah | ||
|
||
| </h4> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| ); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -141,6 +141,14 @@ class Home extends React.Component { | |
| Ayat Al-Kursi | ||
| </Link> | ||
| </li> | ||
| <li> | ||
|
||
| <Link | ||
|
||
| to="/948484888585/255" | ||
| data-metrics-event-name="QuickLinks:Click" | ||
| data-metrics-surah-id="2/255"> | ||
| Random Links | ||
| </Link> | ||
| </li> | ||
| </ul> | ||
| </span> | ||
| ); | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,11 @@ | ||
| import React from 'react'; | ||
| import IndexRoute from 'react-router/lib/IndexRoute'; | ||
| import Route from 'react-router/lib/Route'; | ||
|
|
||
| import checkValidSurah from './utils/checkValidSurah'; | ||
| import App from './containers/App'; | ||
|
|
||
|
|
||
|
|
||
| export default () => { | ||
| return ( | ||
| <Route path="/" component={App}> | ||
|
|
@@ -16,10 +18,12 @@ export default () => { | |
|
|
||
| <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={(nextState, cb) => System.import('./containers/Search').then(module => cb(null, module))} /> | ||
|
|
||
| <Route path="/:surahId(/:range)" getComponent={(nextState, cb) => System.import('./containers/Surah').then(module => cb(null, module)).catch(err => console.trace(err))} /> | ||
| <Route path="/:surahId(/:range)" getComponent={(nextState, cb) => System.import('./containers/Surah').then(module => cb(null, module)).catch(err => console.trace(err))} | ||
| onEnter={checkValidSurah} /> | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nice! |
||
| </Route> | ||
| ); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| export default function isValidSurah(nextState, replaceState) { | ||
| let surahId = parseInt(nextState.params.surahId, 10) | ||
| if(isNaN(surahId) || surahId > 114 || surahId < 1){ | ||
|
|
||
| replaceState('/error/invalid-surah'); | ||
| } | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This component is awesome! What I'd recommend, because I assume we'd want to reuse it for other errors, is having
:errorTitlebe a key to return text given THAT error. For example,/errors/out-of-rangewould then return's an invalid Surah/Ayah. Please go to the <a href="/">home page </a>and select a surah'and say/errors/some-other-errorwould return that text.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is exactly what this component does. Maybe errorTitle isn't exactly the name to use should I use
errorText?