File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -14,8 +14,8 @@ export default function App() {
1414 const { status, roto } = useStatus ( ) ;
1515 const routeName = routerState . route . name ;
1616
17- if ( ! status || ( status && status . error ) ) {
18- return < Loading error = { status ?. error } />
17+ if ( status && status . error ) {
18+ return < Loading status = { status } />
1919 }
2020
2121 return (
Original file line number Diff line number Diff line change 1+ import { useEffect , useState } from "react" ;
2+ import useStatus from "../hooks/useStatus" ;
3+ import { RoutinatorStatus } from "../types" ;
4+ import { API_ENDPOINT } from "../core/contants" ;
5+
16interface LoadingProps {
2- error ?: string ;
7+ status : RoutinatorStatus | null ;
38}
49
5- export default function Loading ( { error } : LoadingProps ) {
10+ export default function Loading ( { status } : LoadingProps ) {
11+ useEffect ( ( ) => {
12+ if ( status && status . error ) {
13+ const checkStatus = ( ) => {
14+ setTimeout ( ( ) => {
15+ fetch ( `${ API_ENDPOINT } /api/v1/status` )
16+ . then ( ( r ) => r . json ( ) )
17+ . then ( ( status ) => {
18+ if ( status && ! status . error ) {
19+ window . location . reload ( ) ;
20+ } else {
21+ checkStatus ( ) ;
22+ }
23+ } ) . catch ( ( ) => checkStatus ( ) ) ;
24+ } , 3000 )
25+ } ;
26+ checkStatus ( ) ;
27+ }
28+ } , [ ] ) ;
29+
630 return (
731 < div id = "loading" >
832 < div >
933 < img src = '/src/img/routinator_logo_white.svg' alt = 'Routinator logo' />
1034 < br />
11- < p > { error || "Something went wrong" } </ p >
35+ < p > { status ?. error || "Something went wrong" } </ p >
1236 </ div >
1337 </ div >
1438 ) ;
Original file line number Diff line number Diff line change 1515
1616# loading img {
1717 max-width : 40rem ;
18- animation : pulse 2s infinite;
1918}
You can’t perform that action at this time.
0 commit comments