mirror of
https://git.mirrors.martin98.com/https://github.com/langgenius/dify.git
synced 2025-05-31 02:24:53 +08:00

Co-authored-by: NFish <douxc512@gmail.com> Co-authored-by: zxhlyh <jasonapring2015@outlook.com> Co-authored-by: twwu <twwu@dify.ai> Co-authored-by: jZonG <jzongcode@gmail.com>
41 lines
1.3 KiB
TypeScript
41 lines
1.3 KiB
TypeScript
'use client'
|
|
import type { FC } from 'react'
|
|
import React from 'react'
|
|
import { useTranslation } from 'react-i18next'
|
|
import useSWR from 'swr'
|
|
import {
|
|
RiArrowRightUpLine,
|
|
} from '@remixicon/react'
|
|
import PlanComp from '../plan'
|
|
import Divider from '@/app/components/base/divider'
|
|
import { fetchBillingUrl } from '@/service/billing'
|
|
import { useAppContext } from '@/context/app-context'
|
|
import { useProviderContext } from '@/context/provider-context'
|
|
|
|
const Billing: FC = () => {
|
|
const { t } = useTranslation()
|
|
const { isCurrentWorkspaceManager } = useAppContext()
|
|
const { enableBilling } = useProviderContext()
|
|
const { data: billingUrl } = useSWR(
|
|
(!enableBilling || !isCurrentWorkspaceManager) ? null : ['/billing/invoices'],
|
|
() => fetchBillingUrl().then(data => data.url),
|
|
)
|
|
|
|
return (
|
|
<div>
|
|
<PlanComp loc={'billing-page'} />
|
|
{enableBilling && isCurrentWorkspaceManager && billingUrl && (
|
|
<>
|
|
<Divider className='my-4' />
|
|
<a className='system-xs-medium flex cursor-pointer items-center text-text-accent-light-mode-only' href={billingUrl} target='_blank' rel='noopener noreferrer'>
|
|
<span className='pr-0.5'>{t('billing.viewBilling')}</span>
|
|
<RiArrowRightUpLine className='h-4 w-4' />
|
|
</a>
|
|
</>
|
|
)}
|
|
</div>
|
|
)
|
|
}
|
|
|
|
export default React.memo(Billing)
|