@@ -19,7 +19,8 @@ const getDefaultDateRange = () => {
1919
2020export default function CostBreakdownPage ( ) {
2121 const [ dateRange , setDateRange ] = useState ( ( ) => getDefaultDateRange ( ) ) ;
22- const { activeOrganization } = useOrganizations ( ) ;
22+ const { activeOrganization, isLoading : isLoadingOrganizations } =
23+ useOrganizations ( ) ;
2324
2425 const usageQueryInput = useMemo (
2526 ( ) => ( {
@@ -31,8 +32,10 @@ export default function CostBreakdownPage() {
3132 ) ;
3233
3334 const { data : organizationUsage } = trpc . organizations . getUsage . useQuery ( ) ;
34- const { data : usageData , isLoading } =
35- trpc . billing . getUsage . useQuery ( usageQueryInput ) ;
35+ const { data : usageData , isLoading : isLoadingUsage } =
36+ trpc . billing . getUsage . useQuery ( usageQueryInput , {
37+ enabled : ! isLoadingOrganizations ,
38+ } ) ;
3639
3740 const handleDateRangeChange = ( startDate : string , endDate : string ) => {
3841 setDateRange ( { startDate, endDate } ) ;
@@ -89,7 +92,7 @@ export default function CostBreakdownPage() {
8992 < div className = "flex-[3]" >
9093 < Suspense fallback = { < Skeleton className = "h-full w-full" /> } >
9194 < ConsumptionChart
92- isLoading = { isLoading }
95+ isLoading = { isLoadingUsage }
9396 onDateRangeChange = { handleDateRangeChange }
9497 overageInfo = { overageInfo }
9598 usageData = { usageData }
@@ -99,7 +102,7 @@ export default function CostBreakdownPage() {
99102 < div className = "flex-[2]" >
100103 < Suspense fallback = { < Skeleton className = "h-full w-full" /> } >
101104 < UsageBreakdownTable
102- isLoading = { isLoading }
105+ isLoading = { isLoadingUsage }
103106 overageInfo = { overageInfo }
104107 usageData = { usageData }
105108 />
0 commit comments