Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

Fix styling issue on org billing v2 page and shift invoices org billing v2 to RQ

Joshen Lim7dc9f212faf9
diff --git a/studio/components/interfaces/BillingV2/Invoices.tsx b/studio/components/interfaces/BillingV2/Invoices.tsx
index 34faf9f2b1f..3eefb5702b3 100644
--- a/studio/components/interfaces/BillingV2/Invoices.tsx
+++ b/studio/components/interfaces/BillingV2/Invoices.tsx
@@ -1,12 +1,12 @@
import { useParams } from 'common'
import Link from 'next/link'
-import { useState } from 'react'
+import { useEffect, useState } from 'react'
import { Button, IconChevronLeft, IconChevronRight, IconDownload, IconFileText } from 'ui'
import Table from 'components/to-be-cleaned/Table'
import AlertError from 'components/ui/AlertError'
import { GenericSkeletonLoader } from 'components/ui/ShimmeringLoader'
-import { getProjectInvoice } from 'data/invoices/project-invoice-query'
+import { getInvoice } from 'data/invoices/invoice-query'
import { useProjectInvoicesCountQuery } from 'data/invoices/project-invoices-count-query'
import { useProjectInvoicesQuery } from 'data/invoices/project-invoices-query'
import { useStore } from 'hooks'
@@ -29,9 +29,13 @@ const Invoices = () => {
})
const invoices = data || []
+ useEffect(() => {
+ setPage(1)
+ }, [projectRef])
+
const fetchInvoice = async (id: string) => {
try {
- const invoice = await getProjectInvoice({ id })
+ const invoice = await getInvoice({ id })
if (invoice?.invoice_pdf) window.open(invoice.invoice_pdf, '_blank')
} catch (error: any) {
ui.setNotification({
diff --git a/studio/components/interfaces/Organization/BillingSettingsV2/BillingAddress/BillingAddress.tsx b/studio/components/interfaces/Organization/BillingSettingsV2/BillingAddress/BillingAddress.tsx
index c35082667d2..98951927271 100644
--- a/studio/components/interfaces/Organization/BillingSettingsV2/BillingAddress/BillingAddress.tsx
+++ b/studio/components/interfaces/Organization/BillingSettingsV2/BillingAddress/BillingAddress.tsx
@@ -56,9 +56,9 @@ const BillingAddress = () => {
return (
<ScaffoldSection>
<ScaffoldSectionDetail>
- <div className="sticky top-16">
- <p className="text-base">Billing Address</p>
- <p className="text-sm text-scale-1000">
+ <div className="sticky space-y-2 top-12">
+ <p className="text-base m-0">Billing Address</p>
+ <p className="text-sm text-scale-1000 m-0">
This will be reflected in every upcoming invoice, past invoices are not affected
</p>
</div>
diff --git a/studio/components/interfaces/Organization/BillingSettingsV2/BillingBreakdown/BillingBreakdown.tsx b/studio/components/interfaces/Organization/BillingSettingsV2/BillingBreakdown/BillingBreakdown.tsx
index 706150d5c43..44049b6780a 100644
--- a/studio/components/interfaces/Organization/BillingSettingsV2/BillingBreakdown/BillingBreakdown.tsx
+++ b/studio/components/interfaces/Organization/BillingSettingsV2/BillingBreakdown/BillingBreakdown.tsx
@@ -49,9 +49,9 @@ const BillingBreakdown = () => {
return (
<ScaffoldSection>
<ScaffoldSectionDetail>
- <div className="sticky space-y-6 top-16">
- <p className="text-base">Billing breakdown</p>
- <p className="text-sm text-scale-1000">
+ <div className="sticky space-y-2 top-12">
+ <p className="text-base m-0">Billing breakdown</p>
+ <p className="text-sm text-scale-1000 m-0">
Current billing cycle: {billingCycleStart.format('MMM DD')} -{' '}
{billingCycleEnd.format('MMM DD')}
</p>
diff --git a/studio/components/interfaces/Organization/BillingSettingsV2/BillingEmail.tsx b/studio/components/interfaces/Organization/BillingSettingsV2/BillingEmail.tsx
index 130960f0e2f..2041551f264 100644
--- a/studio/components/interfaces/Organization/BillingSettingsV2/BillingEmail.tsx
+++ b/studio/components/interfaces/Organization/BillingSettingsV2/BillingEmail.tsx
@@ -56,13 +56,11 @@ const BillingEmail = () => {
return (
<ScaffoldSection>
<ScaffoldSectionDetail>
- <div className="sticky space-y-6 top-16">
- <div>
- <p className="text-base">Email Recipient</p>
- <p className="text-sm text-scale-1000">
- All billing correspondence will go to this email
- </p>
- </div>
+ <div className="sticky space-y-2 top-12">
+ <p className="text-base m-0">Email Recipient</p>
+ <p className="text-sm text-scale-1000 m-0">
+ All billing correspondence will go to this email
+ </p>
</div>
</ScaffoldSectionDetail>
<ScaffoldSectionContent>
diff --git a/studio/components/interfaces/Organization/BillingSettingsV2/CostControl/CostControl.tsx b/studio/components/interfaces/Organization/BillingSettingsV2/CostControl/CostControl.tsx
index 68ce2b7bd22..e377cb39452 100644
--- a/studio/components/interfaces/Organization/BillingSettingsV2/CostControl/CostControl.tsx
+++ b/studio/components/interfaces/Organization/BillingSettingsV2/CostControl/CostControl.tsx
@@ -42,10 +42,10 @@ const CostControl = ({}: CostControlProps) => {
<>
<ScaffoldSection>
<ScaffoldSectionDetail>
- <div className="sticky space-y-6 top-16">
- <div>
- <p className="text-base">Cost Control</p>
- <p className="text-sm text-scale-1000">
+ <div className="sticky space-y-6 top-12">
+ <div className="space-y-2">
+ <p className="text-base m-0">Cost Control</p>
+ <p className="text-sm text-scale-1000 m-0">
Control whether to use beyond your plans included quota
</p>
</div>
@@ -55,7 +55,7 @@ const CostControl = ({}: CostControlProps) => {
<Link href="https://supabase.com/docs/guides/platform/spend-cap">
<a target="_blank" rel="noreferrer">
<div className="flex items-center space-x-2 opacity-50 hover:opacity-100 transition">
- <p className="text-sm">Spend cap</p>
+ <p className="text-sm m-0">Spend cap</p>
<IconExternalLink size={16} strokeWidth={1.5} />
</div>
</a>
diff --git a/studio/components/interfaces/Organization/BillingSettingsV2/CreditBalance.tsx b/studio/components/interfaces/Organization/BillingSettingsV2/CreditBalance.tsx
index 25e255174a5..6ad16720eec 100644
--- a/studio/components/interfaces/Organization/BillingSettingsV2/CreditBalance.tsx
+++ b/studio/components/interfaces/Organization/BillingSettingsV2/CreditBalance.tsx
@@ -26,13 +26,13 @@ const CreditBalance = () => {
return (
<ScaffoldSection>
<ScaffoldSectionDetail>
- <div className="sticky top-16">
+ <div className="sticky space-y-2 top-12">
<div className="flex items-center space-x-2">
- <p className="text-base">Credit balance</p>
+ <p className="text-base m-0">Credit balance</p>
{isCredit && <Badge>You have credits available</Badge>}
{isDebt && <Badge color="red">Outstanding payments</Badge>}
</div>
- <p className="text-sm text-scale-1000">
+ <p className="text-sm text-scale-1000 m-0">
Charges will be deducted from your balance first
</p>
</div>
diff --git a/studio/components/interfaces/Organization/BillingSettingsV2/PaymentMethods/PaymentMethods.tsx b/studio/components/interfaces/Organization/BillingSettingsV2/PaymentMethods/PaymentMethods.tsx
index 92cba91045c..4d5dbb62166 100644
--- a/studio/components/interfaces/Organization/BillingSettingsV2/PaymentMethods/PaymentMethods.tsx
+++ b/studio/components/interfaces/Organization/BillingSettingsV2/PaymentMethods/PaymentMethods.tsx
@@ -54,14 +54,12 @@ const PaymentMethods = () => {
<>
<ScaffoldSection>
<ScaffoldSectionDetail>
- <div className="sticky space-y-6 top-16">
- <div>
- <p className="text-base">Payment methods</p>
- <p className="text-sm text-scale-1000 mb-2 pr-4">
- After adding a payment method, make sure to mark it as active to use it for billing.
- You can remove unused cards.
- </p>
- </div>
+ <div className="sticky space-y-2 top-12">
+ <p className="text-base m-0">Payment methods</p>
+ <p className="text-sm text-scale-1000 mb-2 pr-4 m-0">
+ After adding a payment method, make sure to mark it as active to use it for billing.
+ You can remove unused cards.
+ </p>
</div>
</ScaffoldSectionDetail>
<ScaffoldSectionContent>
diff --git a/studio/components/interfaces/Organization/BillingSettingsV2/Subscription/Subscription.tsx b/studio/components/interfaces/Organization/BillingSettingsV2/Subscription/Subscription.tsx
index c5c07a0f72f..1c16833a2a0 100644
--- a/studio/components/interfaces/Organization/BillingSettingsV2/Subscription/Subscription.tsx
+++ b/studio/components/interfaces/Organization/BillingSettingsV2/Subscription/Subscription.tsx
@@ -43,15 +43,15 @@ const Subscription = () => {
<>
<ScaffoldSection>
<ScaffoldSectionDetail>
- <div className="sticky space-y-6 top-16">
- <p className="text-base">Subscription Plan</p>
+ <div className="sticky space-y-6 top-12">
+ <p className="text-base m-0">Subscription Plan</p>
<div className="space-y-2">
- <p className="text-sm text-scale-1100">More information</p>
+ <p className="text-sm text-scale-1100 m-0">More information</p>
<div>
<Link href="https://supabase.com/pricing">
<a target="_blank" rel="noreferrer">
<div className="flex items-center space-x-2 opacity-50 hover:opacity-100 transition">
- <p className="text-sm">Pricing</p>
+ <p className="text-sm m-0">Pricing</p>
<IconExternalLink size={16} strokeWidth={1.5} />
</div>
</a>
diff --git a/studio/components/interfaces/Organization/BillingSettingsV2/TaxID/TaxID.tsx b/studio/components/interfaces/Organization/BillingSettingsV2/TaxID/TaxID.tsx
index 6e5f4c6d1c2..a18a716e5bc 100644
--- a/studio/components/interfaces/Organization/BillingSettingsV2/TaxID/TaxID.tsx
+++ b/studio/components/interfaces/Organization/BillingSettingsV2/TaxID/TaxID.tsx
@@ -134,17 +134,15 @@ const TaxID = () => {
return (
<ScaffoldSection>
<ScaffoldSectionDetail>
- <div className="sticky space-y-6 top-16">
- <div>
- <p className="text-base">Tax ID</p>
- <p className="text-sm text-scale-1000 pr-4">
- If you would like to include specific tax ID(s) to your invoices. Old invoices are not
- affected.
- </p>
- <p className="text-sm text-scale-1000">
- Make sure the tax ID looks exactly like the placeholder text.
- </p>
- </div>
+ <div className="sticky space-y-2 top-12">
+ <p className="text-base m-0">Tax ID</p>
+ <p className="text-sm text-scale-1000 pr-4 m-0">
+ If you would like to include specific tax ID(s) to your invoices. Old invoices are not
+ affected.
+ </p>
+ <p className="text-sm text-scale-1000 m-0">
+ Make sure the tax ID looks exactly like the placeholder text.
+ </p>
</div>
</ScaffoldSectionDetail>
<ScaffoldSectionContent>
diff --git a/studio/components/interfaces/Organization/InvoicesSettings/InvoicesSettings.tsx b/studio/components/interfaces/Organization/InvoicesSettings/InvoicesSettings.tsx
index 318871d4b62..5b3d9534538 100644
--- a/studio/components/interfaces/Organization/InvoicesSettings/InvoicesSettings.tsx
+++ b/studio/components/interfaces/Organization/InvoicesSettings/InvoicesSettings.tsx
@@ -3,14 +3,15 @@ import Link from 'next/link'
import { useEffect, useState } from 'react'
import { InvoiceStatusBadge } from 'components/interfaces/BillingV2'
-import { Invoice, InvoiceStatus } from 'components/interfaces/BillingV2/Invoices.types'
+import { InvoiceStatus } from 'components/interfaces/BillingV2/Invoices.types'
+import { ScaffoldContainerLegacy } from 'components/layouts/Scaffold'
import Table from 'components/to-be-cleaned/Table'
import NoPermission from 'components/ui/NoPermission'
+import { getInvoice } from 'data/invoices/invoice-query'
+import { useInvoicesCountQuery } from 'data/invoices/invoices-count-query'
+import { useInvoicesQuery } from 'data/invoices/invoices-query'
import { useCheckPermissions, useSelectedOrganization, useStore } from 'hooks'
-import { get, head } from 'lib/common/fetch'
-import { API_URL } from 'lib/constants'
import { Button, IconChevronLeft, IconChevronRight, IconDownload, IconFileText, Loading } from 'ui'
-import { ScaffoldContainerLegacy } from 'components/layouts/Scaffold'
const PAGE_LIMIT = 10
@@ -18,11 +19,7 @@ const PAGE_LIMIT = 10
const InvoicesSettings = () => {
const { ui } = useStore()
- const [loading, setLoading] = useState<any>(false)
-
const [page, setPage] = useState(1)
- const [count, setCount] = useState(0)
- const [invoices, setInvoices] = useState<Invoice[]>([])
const selectedOrganization = useSelectedOrganization()
const { stripe_customer_id, slug } = selectedOrganization ?? {}
@@ -30,66 +27,30 @@ const InvoicesSettings = () => {
const canReadInvoices = useCheckPermissions(PermissionAction.READ, 'invoices')
- useEffect(() => {
- if (!canReadInvoices || !stripe_customer_id || !slug) return
-
- let cancel = false
- const page = 1
-
- const fetchInvoiceCount = async () => {
- const res = await head(
- `${API_URL}/stripe/invoices?customer=${stripe_customer_id}&slug=${slug}`,
- ['X-Total-Count']
- )
- if (!cancel) {
- if (res.error) {
- ui.setNotification({ category: 'error', message: res.error.message })
- } else {
- setCount(res['X-Total-Count'])
- }
- }
- }
-
- setPage(page)
- fetchInvoices(page)
- fetchInvoiceCount()
-
- return () => {
- cancel = true
- }
- }, [stripe_customer_id, slug])
+ const { data: count, isError: isErrorCount } = useInvoicesCountQuery({
+ customerId: stripe_customer_id,
+ slug,
+ })
+ const { data, isLoading } = useInvoicesQuery({
+ customerId: stripe_customer_id,
+ slug,
+ offset,
+ limit: PAGE_LIMIT,
+ })
+ const invoices = data || []
- const fetchInvoices = async (page: number) => {
- setLoading(true)
- setPage(page)
-
- const offset = (page - 1) * PAGE_LIMIT
- const invoices = await get(
- `${API_URL}/stripe/invoices?offset=${offset}&limit=${PAGE_LIMIT}&customer=${stripe_customer_id}&slug=${slug}`
- )
-
- if (invoices.error) {
- ui.setNotification({
- error: invoices.error,
- category: 'error',
- message: `Failed to fetch invoices: ${invoices.error.message}`,
- })
- } else {
- setInvoices(invoices)
- }
-
- setLoading(false)
- }
-
- const fetchInvoice = async (invoiceId: string) => {
- const invoice = await get(`${API_URL}/stripe/invoices/${invoiceId}`)
- if (invoice?.invoice_pdf) {
- window.open(invoice.invoice_pdf, '_blank')
- } else {
+ useEffect(() => {
+ setPage(1)
+ }, [slug])
+
+ const fetchInvoice = async (id: string) => {
+ try {
+ const invoice = await getInvoice({ id })
+ if (invoice?.invoice_pdf) window.open(invoice.invoice_pdf, '_blank')
+ } catch (error: any) {
ui.setNotification({
- error: invoice.error,
category: 'info',
- message: `Unable to fetch the selected invoice: ${invoice.error.message}`,
+ message: `Failed to fetch the selected invoice: ${error.message}`,
})
}
}
@@ -100,7 +61,7 @@ const InvoicesSettings = () => {
return (
<ScaffoldContainerLegacy>
- <Loading active={loading}>
+ <Loading active={isLoading}>
<Table
head={[
<Table.th key="header-icon"></Table.th>,
@@ -117,7 +78,7 @@ const InvoicesSettings = () => {
<Table.tr>
<Table.td colSpan={6} className="p-3 py-12 text-center">
<p className="text-scale-1000">
- {loading ? 'Checking for invoices' : 'No invoices for this organization yet'}
+ {isLoading ? 'Checking for invoices' : 'No invoices for this organization yet'}
</p>
</Table.td>
</Table.tr>
@@ -165,7 +126,11 @@ const InvoicesSettings = () => {
<Table.td colSpan={6}>
<div className="flex items-center justify-between">
<p className="text-sm opacity-50">
- Showing {offset + 1} to {offset + invoices.length} out of {count} invoices
+ {isErrorCount
+ ? 'Failed to retrieve total number of invoices'
+ : `Showing ${offset + 1} to ${
+ offset + invoices.length
+ } out of ${count} invoices`}
</p>
<div className="flex items-center space-x-2">
<Button
@@ -173,14 +138,14 @@ const InvoicesSettings = () => {
type="default"
size="tiny"
disabled={page === 1}
- onClick={async () => await fetchInvoices(page - 1)}
+ onClick={async () => setPage(page - 1)}
/>
<Button
icon={<IconChevronRight />}
type="default"
size="tiny"
- disabled={page * PAGE_LIMIT >= count}
- onClick={async () => await fetchInvoices(page + 1)}
+ disabled={page * PAGE_LIMIT >= (count ?? 0)}
+ onClick={async () => setPage(page + 1)}
/>
</div>
</div>
diff --git a/studio/components/layouts/Scaffold.tsx b/studio/components/layouts/Scaffold.tsx
index 0ed8f43a859..e86c3ace300 100644
--- a/studio/components/layouts/Scaffold.tsx
+++ b/studio/components/layouts/Scaffold.tsx
@@ -65,7 +65,7 @@ const ScaffoldSectionDetail = React.forwardRef<
>(({ className, children, title, ...props }, ref) => {
return (
<div ref={ref} {...props} className={cn('col-span-4 xl:col-span-5 prose text-sm', className)}>
- <h2>{title}</h2>
+ {title && <h2>{title}</h2>}
{children}
</div>
)
diff --git a/studio/data/invoices/invoice-query.ts b/studio/data/invoices/invoice-query.ts
new file mode 100644
index 00000000000..e1ff6e23fd5
--- /dev/null
+++ b/studio/data/invoices/invoice-query.ts
@@ -0,0 +1,36 @@
+import { useQuery, UseQueryOptions } from '@tanstack/react-query'
+import { get } from 'data/fetchers'
+import { ResponseError } from 'types'
+import { invoicesKeys } from './keys'
+
+export type InvoiceVariables = {
+ id?: string
+}
+
+export async function getInvoice({ id }: InvoiceVariables, signal?: AbortSignal) {
+ if (!id) throw new Error('Invoice ID is required')
+
+ const { data, error } = await get(`/platform/stripe/invoices/{id}`, {
+ params: { path: { id } },
+ signal,
+ })
+
+ if (error) throw error
+ return data
+}
+
+export type InvoiceData = Awaited<ReturnType<typeof getInvoice>>
+export type InvoiceError = ResponseError
+
+export const useInvoiceQuery = <TData = InvoiceData>(
+ { id }: InvoiceVariables,
+ { enabled = true, ...options }: UseQueryOptions<InvoiceData, InvoiceError, TData> = {}
+) =>
+ useQuery<InvoiceData, InvoiceError, TData>(
+ invoicesKeys.invoice(id),
+ ({ signal }) => getInvoice({ id }, signal),
+ {
+ enabled: enabled && typeof id !== 'undefined',
+ ...options,
+ }
+ )
diff --git a/studio/data/invoices/invoices-count-query.ts b/studio/data/invoices/invoices-count-query.ts
new file mode 100644
index 00000000000..8d8fe650e3d
--- /dev/null
+++ b/studio/data/invoices/invoices-count-query.ts
@@ -0,0 +1,41 @@
+import { useQuery, UseQueryOptions } from '@tanstack/react-query'
+import { head } from 'data/fetchers'
+import { ResponseError } from 'types'
+import { invoicesKeys } from './keys'
+
+export type InvoicesCountVariables = {
+ customerId?: string
+ slug?: string
+}
+
+export async function getInvoicesCount(
+ { customerId, slug }: InvoicesCountVariables,
+ signal?: AbortSignal
+) {
+ if (!customerId) throw new Error('Customer ID is required')
+ if (!slug) throw new Error('Slug is required')
+
+ const res = await head(`/platform/stripe/invoices`, {
+ params: { query: { customer: customerId, slug } },
+ signal,
+ })
+
+ if (res.error) throw (res as any).error
+ return Number(res.response.headers.get('X-Total-Count'))
+}
+
+export type InvoicesCountData = Awaited<ReturnType<typeof getInvoicesCount>>
+export type InvoicesCountError = ResponseError
+
+export const useInvoicesCountQuery = <TData = InvoicesCountData>(
+ { customerId, slug }: InvoicesCountVariables,
+ { enabled = true, ...options }: UseQueryOptions<InvoicesCountData, InvoicesCountError, TData> = {}
+) =>
+ useQuery<InvoicesCountData, InvoicesCountError, TData>(
+ invoicesKeys.count(customerId, slug),
+ ({ signal }) => getInvoicesCount({ customerId, slug }, signal),
+ {
+ enabled: enabled && typeof customerId !== 'undefined' && typeof slug !== 'undefined',
+ ...options,
+ }
+ )
diff --git a/studio/data/invoices/invoices-query.ts b/studio/data/invoices/invoices-query.ts
new file mode 100644
index 00000000000..1031d9650d9
--- /dev/null
+++ b/studio/data/invoices/invoices-query.ts
@@ -0,0 +1,50 @@
+import { useQuery, UseQueryOptions } from '@tanstack/react-query'
+import { get } from 'data/fetchers'
+import { ResponseError } from 'types'
+import { invoicesKeys } from './keys'
+
+export type InvoicesVariables = {
+ customerId?: string
+ slug?: string
+ offset: number
+ limit: number
+}
+
+export async function getInvoices(
+ { customerId, slug, offset, limit }: InvoicesVariables,
+ signal?: AbortSignal
+) {
+ if (!customerId) throw new Error('Customer ID is required')
+ if (!slug) throw new Error('Org slug is required')
+
+ const { data, error } = await get(`/platform/stripe/invoices`, {
+ params: {
+ query: { offset: offset.toString(), limit: limit.toString(), customer: customerId, slug },
+ },
+ signal,
+ })
+
+ if (error) throw error
+ return data
+}
+
+export type InvoicesData = Awaited<ReturnType<typeof getInvoices>>
+export type InvoicesError = ResponseError
+
+export const useInvoicesQuery = <TData = InvoicesData>(
+ { customerId, slug, offset, limit }: InvoicesVariables,
+ { enabled = true, ...options }: UseQueryOptions<InvoicesData, InvoicesError, TData> = {}
+) =>
+ useQuery<InvoicesData, InvoicesError, TData>(
+ invoicesKeys.list(customerId, slug),
+ ({ signal }) => getInvoices({ customerId, slug, offset, limit }, signal),
+ {
+ enabled:
+ enabled &&
+ typeof customerId !== 'undefined' &&
+ typeof slug !== 'undefined' &&
+ typeof limit !== 'undefined' &&
+ typeof offset !== 'undefined',
+ ...options,
+ }
+ )
diff --git a/studio/data/invoices/keys.ts b/studio/data/invoices/keys.ts
index b515f9788aa..6c25d4fe23e 100644
--- a/studio/data/invoices/keys.ts
+++ b/studio/data/invoices/keys.ts
@@ -1,6 +1,12 @@
export const invoicesKeys = {
overdueInvoices: () => ['invoices', 'overdue'] as const,
- invoice: (id: string | undefined) => ['invoices', id] as const,
+
+ invoice: (id: string | undefined) => ['invoice', id] as const,
+ list: (customerId: string | undefined, slug: string | undefined) =>
+ ['invoices', customerId, slug] as const,
+ count: (customerId: string | undefined, slug: string | undefined) =>
+ ['invoices', customerId, slug, 'count'] as const,
+
projectInvoices: (projectRef: string | undefined) => ['invoices', projectRef] as const,
projectInvoicesCount: (projectRef: string | undefined) =>
['invoices', projectRef, 'count'] as const,
diff --git a/studio/data/invoices/project-invoice-query.ts b/studio/data/invoices/project-invoice-query.ts
deleted file mode 100644
index 157dda1176c..00000000000
--- a/studio/data/invoices/project-invoice-query.ts
+++ /dev/null
@@ -1,39 +0,0 @@
-import { useQuery, UseQueryOptions } from '@tanstack/react-query'
-import { get } from 'data/fetchers'
-import { ResponseError } from 'types'
-import { invoicesKeys } from './keys'
-
-export type ProjectInvoiceVariables = {
- id?: string
-}
-
-export async function getProjectInvoice({ id }: ProjectInvoiceVariables, signal?: AbortSignal) {
- if (!id) throw new Error('Invoice ID is required')
-
- const { data, error } = await get(`/platform/stripe/invoices/{id}`, {
- params: { path: { id } },
- signal,
- })
-
- if (error) throw error
- return data
-}
-
-export type ProjectInvoiceData = Awaited<ReturnType<typeof getProjectInvoice>>
-export type ProjectInvoiceError = ResponseError
-
-export const useProjectInvoiceQuery = <TData = ProjectInvoiceData>(
- { id }: ProjectInvoiceVariables,
- {
- enabled = true,
- ...options
- }: UseQueryOptions<ProjectInvoiceData, ProjectInvoiceError, TData> = {}
-) =>
- useQuery<ProjectInvoiceData, ProjectInvoiceError, TData>(
- invoicesKeys.invoice(id),
- ({ signal }) => getProjectInvoice({ id }, signal),
- {
- enabled: enabled && typeof id !== 'undefined',
- ...options,
- }
- )