mirror of
https://github.com/supabase/supabase.git
synced 2026-12-06 08:29:01 +00:00
Makes use of the new data returned from the upcoming invoice endpoint and wraps it in an accordion-based layout. The current implementation is fairly bare-bones, so discussed with @kevcodez that we roll out this version first (which should already be an improvement), then talk to a designer on the team to get it polished. Ran `pnpm api:codegen:prod` from the root of the repo. The $10.01 in Compute Credits are an upstream data issue on Orb 😢 ## Testing If you'd like to test this in the browser, these are the steps: 1. checkout commit, launch local stack, create org + project; upgrade to paid 2. reach out to me so I can set up some usage and credits for your project/org 3. click around the upcoming invoice https://github.com/user-attachments/assets/6a814560-5d05-479a-a3f8-d658532b91c1 <img width="1180" height="235" alt="Screenshot 2026-11-13 at 10 03 01" src="https://github.com/user-attachments/assets/682083b7-77ea-4da8-a599-36f5063e922b" /> <img width="910" height="235" alt="Screenshot 2026-11-13 at 10 02 59" src="https://github.com/user-attachments/assets/59903f2a-2af4-4e18-8d97-35baee7401e0" /> <img width="815" height="140" alt="Screenshot 2026-11-13 at 12 03 17" src="https://github.com/user-attachments/assets/4370d10a-dc5a-4010-b03e-dcf0b23140d1" /> <img width="507" height="143" alt="Screenshot 2026-11-13 at 12 03 21" src="https://github.com/user-attachments/assets/3243855e-b02a-4e93-8139-5a7dfaad3230" />
47 lines
1.5 KiB
TypeScript
47 lines
1.5 KiB
TypeScript
import { useQuery } from '@tanstack/react-query'
|
|
import { components } from 'api-types'
|
|
|
|
import { invoicesKeys } from './keys'
|
|
import { get, handleError } from '@/data/fetchers'
|
|
import type { StudioError } from '@/lib/errors/studio-errors'
|
|
import type { UseCustomQueryOptions } from '@/types'
|
|
|
|
export type UpcomingInvoiceVariables = {
|
|
orgSlug?: string
|
|
}
|
|
|
|
export type UpcomingInvoiceResponse = components['schemas']['UpcomingInvoice_Output']
|
|
|
|
export async function getUpcomingInvoice(
|
|
{ orgSlug }: UpcomingInvoiceVariables,
|
|
signal?: AbortSignal
|
|
) {
|
|
if (!orgSlug) throw new Error('orgSlug is required')
|
|
|
|
const { data, error } = await get(`/platform/organizations/{slug}/billing/invoices/upcoming`, {
|
|
params: { path: { slug: orgSlug }, query: { enable_v2: 'true' } },
|
|
headers: { Version: '2' },
|
|
signal,
|
|
})
|
|
|
|
if (error) handleError(error)
|
|
return data as UpcomingInvoiceResponse
|
|
}
|
|
|
|
export type UpcomingInvoiceData = Awaited<ReturnType<typeof getUpcomingInvoice>>
|
|
export type UpcomingInvoiceError = StudioError
|
|
|
|
export const useOrgUpcomingInvoiceQuery = <TData = UpcomingInvoiceData>(
|
|
{ orgSlug }: UpcomingInvoiceVariables,
|
|
{
|
|
enabled = true,
|
|
...options
|
|
}: UseCustomQueryOptions<UpcomingInvoiceData, UpcomingInvoiceError, TData> = {}
|
|
) =>
|
|
useQuery<UpcomingInvoiceData, UpcomingInvoiceError, TData>({
|
|
queryKey: invoicesKeys.orgUpcomingPreview(orgSlug),
|
|
queryFn: ({ signal }) => getUpcomingInvoice({ orgSlug }, signal),
|
|
enabled: enabled && typeof orgSlug !== 'undefined',
|
|
...options,
|
|
})
|