Files
dify/web/service/use-billing.ts
非法操作 473c945839 chore: seprate vector space quota query (#36514)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2026-05-22 09:26:17 +00:00

35 lines
1.1 KiB
TypeScript

import { useMutation, useQuery } from '@tanstack/react-query'
import { consoleClient, consoleQuery } from '@/service/client'
import { fetchCurrentPlanVectorSpace } from './billing'
const currentPlanVectorSpaceQueryKey = ['billing', 'current-plan-vector-space'] as const
export const useBindPartnerStackInfo = () => {
return useMutation({
mutationKey: consoleQuery.billing.bindPartnerStack.mutationKey(),
mutationFn: (data: { partnerKey: string, clickId: string }) => consoleClient.billing.bindPartnerStack({
params: { partnerKey: data.partnerKey },
body: { click_id: data.clickId },
}),
})
}
export const useBillingUrl = (enabled: boolean) => {
return useQuery({
queryKey: consoleQuery.billing.invoices.queryKey(),
enabled,
queryFn: async () => {
const res = await consoleClient.billing.invoices()
return res.url
},
})
}
export const useCurrentPlanVectorSpace = (enabled = true) => {
return useQuery({
queryKey: currentPlanVectorSpaceQueryKey,
queryFn: () => fetchCurrentPlanVectorSpace(),
enabled,
})
}