File tree 2 files changed +15
-19
lines changed
2 files changed +15
-19
lines changed Original file line number Diff line number Diff line change @@ -38,15 +38,14 @@ export default connect((state) => {
38
38
memo ( function LoadInstance ( props ) {
39
39
const [ error , setError ] = useState ( "" ) ;
40
40
useEffect ( ( ) => {
41
- props
42
- . dispatch ( fetchInstance ( ) )
43
- . then ( ( res ) => {
44
- document . title = `Manager - ${ res . data . name } - Zesty` ;
45
- CONFIG . URL_PREVIEW_FULL = `${ CONFIG . URL_PREVIEW_PROTOCOL } ${ res . data . randomHashID } ${ CONFIG . URL_PREVIEW } ` ;
46
- } )
47
- . catch ( ( res ) => {
48
- setError ( res . message ) ;
49
- } ) ;
41
+ props . dispatch ( fetchInstance ( ) ) . then ( ( res ) => {
42
+ if ( res . status !== 200 ) {
43
+ setError ( "You do not have permission to access this instance" ) ;
44
+ } else {
45
+ document . title = `Manager - ${ res . data ?. name } - Zesty` ;
46
+ CONFIG . URL_PREVIEW_FULL = `${ CONFIG . URL_PREVIEW_PROTOCOL } ${ res . data ?. randomHashID } ${ CONFIG . URL_PREVIEW } ` ;
47
+ }
48
+ } ) ;
50
49
51
50
Promise . all ( [
52
51
props . dispatch ( fetchUser ( props . user . ZUID ) ) ,
Original file line number Diff line number Diff line change @@ -32,17 +32,14 @@ export function fetchInstance() {
32
32
} ) ;
33
33
34
34
return request ( `${ CONFIG . API_ACCOUNTS } /instances/${ ZUID } ` ) . then ( ( res ) => {
35
- if ( res . status === 403 ) {
36
- throw new Error (
37
- "You do not have permission to access to this instance"
38
- ) ;
35
+ if ( res . status === 200 ) {
36
+ dispatch ( {
37
+ type : "FETCHING_INSTANCE_SUCCESS" ,
38
+ payload : {
39
+ data : res . data ,
40
+ } ,
41
+ } ) ;
39
42
}
40
- dispatch ( {
41
- type : "FETCHING_INSTANCE_SUCCESS" ,
42
- payload : {
43
- data : res . data ,
44
- } ,
45
- } ) ;
46
43
47
44
return res ;
48
45
} ) ;
You can’t perform that action at this time.
0 commit comments