@@ -17,6 +17,7 @@ import Header from "../components/Header";
17
17
import { ErrorCodes } from "@gitpod/gitpod-protocol/lib/messaging/error" ;
18
18
import { FeatureFlagContext } from "../contexts/FeatureFlagContext" ;
19
19
import { ReactComponent as CreditsSvg } from "../images/credits.svg" ;
20
+ import { ReactComponent as Spinner } from "../icons/Spinner.svg" ;
20
21
21
22
function TeamUsage ( ) {
22
23
const { teams } = useContext ( TeamsContext ) ;
@@ -32,6 +33,7 @@ function TeamUsage() {
32
33
const timestampStartOfCurrentMonth = startOfCurrentMonth . getTime ( ) ;
33
34
const [ startDateOfBillMonth , setStartDateOfBillMonth ] = useState ( timestampStartOfCurrentMonth ) ;
34
35
const [ endDateOfBillMonth , setEndDateOfBillMonth ] = useState ( Date . now ( ) ) ;
36
+ const [ isLoading , setIsLoading ] = useState < boolean > ( true ) ;
35
37
36
38
useEffect ( ( ) => {
37
39
if ( ! team ) {
@@ -50,6 +52,8 @@ function TeamUsage() {
50
52
if ( error . code === ErrorCodes . PERMISSION_DENIED ) {
51
53
setErrorMessage ( "Access to usage details is restricted to team owners." ) ;
52
54
}
55
+ } finally {
56
+ setIsLoading ( false ) ;
53
57
}
54
58
} ) ( ) ;
55
59
} , [ team , startDateOfBillMonth , endDateOfBillMonth ] ) ;
@@ -146,7 +150,7 @@ function TeamUsage() {
146
150
</ div >
147
151
</ div >
148
152
</ div >
149
- { billedUsage . length === 0 && ! errorMessage && (
153
+ { billedUsage . length === 0 && ! errorMessage && ! isLoading && (
150
154
< div className = "flex flex-col w-full mb-8" >
151
155
< h3 className = "text-center text-gray-500 mt-8" > No sessions found.</ h3 >
152
156
< p className = "text-center text-gray-500 mt-1" >
@@ -163,7 +167,15 @@ function TeamUsage() {
163
167
</ p >
164
168
</ div >
165
169
) }
166
- { billedUsage . length > 0 && (
170
+ { isLoading && (
171
+ < div className = "flex flex-col place-items-center align-center w-full" >
172
+ < div className = "uppercase text-sm text-gray-400 dark:text-gray-500 mb-5" >
173
+ Fetching usage...
174
+ </ div >
175
+ < Spinner className = "m-2 h-5 w-5 animate-spin" />
176
+ </ div >
177
+ ) }
178
+ { billedUsage . length > 0 && ! isLoading && (
167
179
< div className = "flex flex-col w-full mb-8" >
168
180
< ItemsList className = "mt-2 text-gray-500" >
169
181
< Item header = { false } className = "grid grid-cols-5 bg-gray-100 mb-5" >
0 commit comments