File tree Expand file tree Collapse file tree 10 files changed +139
-61
lines changed
app/Http/Controllers/Api/Auth Expand file tree Collapse file tree 10 files changed +139
-61
lines changed Original file line number Diff line number Diff line change @@ -35,8 +35,8 @@ public function login(Request $request)
3535 return json_decode ((string )$ response ->getBody (), true );
3636 } catch (\Exception $ e ) {
3737 return response ()->json ([
38- " error " => " invalid_credentials " ,
39- " message " => "The user credentials were incorrect. "
38+ ' error ' => ' invalid_credentials ' ,
39+ ' message ' => "{ $ e -> getCode ()} : { $ e -> getMessage ()} "
4040 ], 401 );
4141 }
4242 }
Original file line number Diff line number Diff line change 4848 "react-document-title" : " ^2.0.3" ,
4949 "react-dom" : " ^16.2.0" ,
5050 "react-draft-wysiwyg" : " ^1.12.3" ,
51+ "react-loadable" : " ^5.3.1" ,
5152 "react-redux" : " ^5.0.6" ,
5253 "react-router-dom" : " ^4.2.2" ,
5354 "reactstrap" : " 5.0.0-alpha.4" ,
Original file line number Diff line number Diff line change 1+ import React from 'react'
2+ import PropTypes from 'prop-types'
3+
4+ // set display name for component
5+ const displayName = 'CommonLoader'
6+
7+ // validate component properties
8+ const propTypes = {
9+ isLoading : PropTypes . bool ,
10+ error : PropTypes . object ,
11+ }
12+
13+ const LoadingComponent = ( { isLoading, error} ) => {
14+ // Handle the loading state
15+ if ( isLoading ) {
16+ return < div > Loading...</ div >
17+ }
18+ // Handle the error state
19+ else if ( error ) {
20+ return < div > Sorry, there was a problem loading the page.</ div >
21+ }
22+ else {
23+ return null
24+ }
25+ }
26+
27+ LoadingComponent . displayName = displayName
28+ LoadingComponent . propTypes = propTypes
29+
30+ export default LoadingComponent
Original file line number Diff line number Diff line change 1- import Articles from "./pages/list"
2- import EditArticle from "./pages/edit"
3- import AddArticle from "./pages/add"
1+ // import lib
2+ import Loadable from 'react-loadable'
3+
4+ // import components
5+ import LoadingComponent from '../../common/loader'
46
57export default [
68 {
79 path : '/articles' ,
810 exact : true ,
911 auth : true ,
10- component : Articles ,
12+ component : Loadable ( {
13+ loader : ( ) => import ( './pages/list' ) ,
14+ loading : LoadingComponent ,
15+ } ) ,
1116 } ,
1217 {
1318 path : '/articles/create' ,
1419 exact : true ,
1520 auth : true ,
16- component : AddArticle ,
21+ component : Loadable ( {
22+ loader : ( ) => import ( './pages/add' ) ,
23+ loading : LoadingComponent ,
24+ } ) ,
1725 } ,
1826 {
1927 path : '/articles/:id/edit' ,
2028 exact : true ,
2129 auth : true ,
22- component : EditArticle ,
30+ component : Loadable ( {
31+ loader : ( ) => import ( './pages/edit' ) ,
32+ loading : LoadingComponent ,
33+ } ) ,
2334 } ,
2435]
Original file line number Diff line number Diff line change 1- import Register from "./pages/register"
2- import Login from "./pages/login"
1+ // import lib
2+ import Loadable from 'react-loadable'
3+
4+ // import components
5+ import LoadingComponent from '../../common/loader'
6+
37
48export default [
59 {
610 path : '/login' ,
711 exact : true ,
8- component : Login ,
12+ component : Loadable ( {
13+ loader : ( ) => import ( './pages/login' ) ,
14+ loading : LoadingComponent ,
15+ } ) ,
916 } ,
1017 {
1118 path : '/register' ,
1219 exact : true ,
13- component : Register ,
20+ component : Loadable ( {
21+ loader : ( ) => import ( './pages/register' ) ,
22+ loading : LoadingComponent ,
23+ } ) ,
1424 } ,
1525]
Original file line number Diff line number Diff line change 1- import Edit from "./pages/edit"
1+ // import lib
2+ import Loadable from 'react-loadable'
3+
4+ // import components
5+ import LoadingComponent from '../../common/loader'
26
37export default [
48 {
59 path : '/users/:id/edit' ,
610 exact : true ,
711 auth : true ,
8- component : Edit ,
12+ component : Loadable ( {
13+ loader : ( ) => import ( './pages/edit' ) ,
14+ loading : LoadingComponent ,
15+ } ) ,
916 } ,
1017]
Original file line number Diff line number Diff line change @@ -7,6 +7,8 @@ import Page from './Page'
77const mapStateToProps = ( state , router ) => {
88 const { params } = router . match
99
10+ console . log ( params )
11+
1012 const article = state . articles . data . find ( article => article . slug === params . slug )
1113 return {
1214 article : article ? new Article ( article ) : new Article ( { } )
You can’t perform that action at this time.
0 commit comments