feat: team admin can pay billing (#2240)
This commit is contained in:
@@ -11,23 +11,23 @@ import { useProviderContext } from '@/context/provider-context'
|
||||
|
||||
const Billing: FC = () => {
|
||||
const { t } = useTranslation()
|
||||
const { isCurrentWorkspaceOwner } = useAppContext()
|
||||
const { isCurrentWorkspaceManager } = useAppContext()
|
||||
const [billingUrl, setBillingUrl] = React.useState('')
|
||||
const { enableBilling } = useProviderContext()
|
||||
|
||||
useEffect(() => {
|
||||
if (!enableBilling || !isCurrentWorkspaceOwner)
|
||||
if (!enableBilling || !isCurrentWorkspaceManager)
|
||||
return
|
||||
(async () => {
|
||||
const { url } = await fetchBillingUrl()
|
||||
setBillingUrl(url)
|
||||
})()
|
||||
}, [isCurrentWorkspaceOwner])
|
||||
}, [isCurrentWorkspaceManager])
|
||||
|
||||
return (
|
||||
<div>
|
||||
<PlanComp loc={'billing-page'} />
|
||||
{enableBilling && isCurrentWorkspaceOwner && billingUrl && (
|
||||
{enableBilling && isCurrentWorkspaceManager && billingUrl && (
|
||||
<a className='mt-5 flex px-6 justify-between h-12 items-center bg-gray-50 rounded-xl cursor-pointer' href={billingUrl} target='_blank'>
|
||||
<div className='flex items-center'>
|
||||
<ReceiptList className='w-4 h-4 text-gray-700' />
|
||||
|
||||
@@ -20,8 +20,8 @@ const Pricing: FC<Props> = ({
|
||||
}) => {
|
||||
const { t } = useTranslation()
|
||||
const { plan } = useProviderContext()
|
||||
const { isCurrentWorkspaceOwner } = useAppContext()
|
||||
const canPay = isCurrentWorkspaceOwner
|
||||
const { isCurrentWorkspaceManager } = useAppContext()
|
||||
const canPay = isCurrentWorkspaceManager
|
||||
const [planRange, setPlanRange] = React.useState<PlanRange>(PlanRange.monthly)
|
||||
|
||||
return createPortal(
|
||||
|
||||
@@ -132,6 +132,7 @@ export enum CurrentSystemQuotaTypeEnum {
|
||||
export enum QuotaUnitEnum {
|
||||
times = 'times',
|
||||
tokens = 'tokens',
|
||||
credits = 'credits',
|
||||
}
|
||||
|
||||
export type QuotaConfiguration = {
|
||||
|
||||
@@ -62,6 +62,9 @@ const QuotaPanel: FC<QuotaPanelProps> = ({
|
||||
{
|
||||
currentQuota?.quota_unit === QuotaUnitEnum.times && t('common.modelProvider.callTimes')
|
||||
}
|
||||
{
|
||||
currentQuota?.quota_unit === QuotaUnitEnum.credits && t('common.modelProvider.credits')
|
||||
}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user