@@ -8,16 +8,21 @@ export default function ProjectList() {
88 const intl = useIntl ( ) ;
99 const [ currentUser , setCurrentUser ] = useState ( null ) ;
1010 const [ projects , setProjects ] = useState ( [ ] ) ;
11+ const [ loading , setLoading ] = useState ( true ) ;
1112 const [ sortConfig , setSortConfig ] = useState ( { key : null , direction : "asc" } ) ;
1213 const [ currentPage , setCurrentPage ] = useState ( 1 ) ;
1314 const [ projectsPerPage , setProjectsPerPage ] = useState ( 10 ) ;
1415 const [ gotoPage , setGotoPage ] = useState ( 1 ) ;
1516
1617 const fetchData = async ( ) => {
17- const response = await axios . get ( "/api/v3/user" ) ;
18- setCurrentUser ( response . data . displayName ) ;
19- const projectsResponse = await axios . get ( "/api/v3/projects" ) ;
20- setProjects ( projectsResponse . data . projects ) ;
18+ try {
19+ const response = await axios . get ( "/api/v3/user" ) ;
20+ setCurrentUser ( response . data . displayName ) ;
21+ const projectsResponse = await axios . get ( "/api/v3/projects" ) ;
22+ setProjects ( projectsResponse . data . projects ) ;
23+ } finally {
24+ setLoading ( false ) ;
25+ }
2126 } ;
2227
2328 useEffect ( ( ) => {
@@ -79,7 +84,15 @@ export default function ProjectList() {
7984 < FormattedMessage id = "NEW_PROJECT" />
8085 </ button >
8186 </ div >
82- { projects . length === 0 ? (
87+ { loading ? (
88+ < div className = "d-flex justify-content-center align-items-center" style = { { minHeight : "200px" } } >
89+ < div className = "spinner-border text-primary" role = "status" >
90+ < span className = "visually-hidden" >
91+ < FormattedMessage id = "LOADING" />
92+ </ span >
93+ </ div >
94+ </ div >
95+ ) : projects . length === 0 ? (
8396 < h4 >
8497 < FormattedMessage id = "NO_PROJECTS" />
8598 </ h4 >
0 commit comments