diff --git a/static/gsApp/hooks/useCurrentBillingHistory.tsx b/static/gsApp/hooks/useCurrentBillingHistory.tsx index bff97880d2b65e..e3c107f2af97bc 100644 --- a/static/gsApp/hooks/useCurrentBillingHistory.tsx +++ b/static/gsApp/hooks/useCurrentBillingHistory.tsx @@ -9,17 +9,16 @@ export function useCurrentBillingHistory() { const organization = useOrganization(); const { - data: histories, + data: history, isPending, isError, - } = useApiQuery([`/customers/${organization.slug}/history/`], { - staleTime: 0, // TODO(billing): Create an endpoint that returns the current history + } = useApiQuery([`/customers/${organization.slug}/history/current/`], { + staleTime: 0, }); const currentHistory: BillingHistory | null = useMemo(() => { - if (!histories) return null; - return histories.find((history: BillingHistory) => history.isCurrent) ?? null; - }, [histories]); + return history ?? null; + }, [history]); return {currentHistory, isPending, isError}; } diff --git a/static/gsApp/views/subscriptionPage/overview.spec.tsx b/static/gsApp/views/subscriptionPage/overview.spec.tsx index 29873e4825667a..0ade7e45fe47c7 100644 --- a/static/gsApp/views/subscriptionPage/overview.spec.tsx +++ b/static/gsApp/views/subscriptionPage/overview.spec.tsx @@ -93,7 +93,7 @@ describe('Subscription > Overview', () => { }); MockApiClient.addMockResponse({ - url: `/customers/${organization.slug}/history/`, + url: `/customers/${organization.slug}/history/current/`, method: 'GET', }); diff --git a/static/gsApp/views/subscriptionPage/usageOverview.spec.tsx b/static/gsApp/views/subscriptionPage/usageOverview.spec.tsx index 5d02908948dc8d..ea198c64699c29 100644 --- a/static/gsApp/views/subscriptionPage/usageOverview.spec.tsx +++ b/static/gsApp/views/subscriptionPage/usageOverview.spec.tsx @@ -21,7 +21,7 @@ describe('UsageOverview', () => { organization.access = ['org:billing']; SubscriptionStore.set(organization.slug, subscription); MockApiClient.addMockResponse({ - url: `/customers/${organization.slug}/history/`, + url: `/customers/${organization.slug}/history/current/`, method: 'GET', body: BillingHistoryFixture(), });