Skip to content

Commit 4c1269e

Browse files
committed
cleaner loading state
1 parent d83889a commit 4c1269e

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

apps/dashboard/app/(main)/billing/cost-breakdown/components/usage-breakdown-table.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ export function UsageBreakdownTable({
8888
);
8989
}
9090

91-
if (!usageData || usageData.eventTypeBreakdown.length === 0) {
91+
if (!usageData || !usageData.eventTypeBreakdown || usageData.eventTypeBreakdown.length === 0) {
9292
return (
9393
<div className="flex h-full items-center justify-center">
9494
<div className="text-center">

apps/dashboard/app/(main)/billing/cost-breakdown/page.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,15 @@ export default function CostBreakdownPage() {
3131
[dateRange, activeOrganization?.id]
3232
);
3333

34-
const { data: organizationUsage } = trpc.organizations.getUsage.useQuery();
3534
const { data: usageData, isLoading: isLoadingUsage } =
3635
trpc.billing.getUsage.useQuery(usageQueryInput, {
3736
enabled: !isLoadingOrganizations,
3837
});
3938

39+
const { data: organizationUsage } = trpc.organizations.getUsage.useQuery();
40+
41+
const isLoading = isLoadingUsage;
42+
4043
const handleDateRangeChange = (startDate: string, endDate: string) => {
4144
setDateRange({ startDate, endDate });
4245
};
@@ -92,7 +95,7 @@ export default function CostBreakdownPage() {
9295
<div className="flex-[3]">
9396
<Suspense fallback={<Skeleton className="h-full w-full" />}>
9497
<ConsumptionChart
95-
isLoading={isLoadingUsage}
98+
isLoading={isLoading}
9699
onDateRangeChange={handleDateRangeChange}
97100
overageInfo={overageInfo}
98101
usageData={usageData}
@@ -102,7 +105,7 @@ export default function CostBreakdownPage() {
102105
<div className="flex-[2]">
103106
<Suspense fallback={<Skeleton className="h-full w-full" />}>
104107
<UsageBreakdownTable
105-
isLoading={isLoadingUsage}
108+
isLoading={isLoading}
106109
overageInfo={overageInfo}
107110
usageData={usageData}
108111
/>

0 commit comments

Comments
 (0)