feat: team admin can pay billing (#2240)

This commit is contained in:
Joel
2024-01-26 18:06:54 +08:00
committed by GitHub
parent 9fd55157d6
commit 2fc0dcc10a
9 changed files with 18 additions and 11 deletions

View File

@@ -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' />

View File

@@ -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(