'use client' import type { FC } from 'react' import { RiArrowRightUpLine, } from '@remixicon/react' import * as React from 'react' import { useTranslation } from 'react-i18next' import { useAppContext } from '@/context/app-context' import { useProviderContext } from '@/context/provider-context' import { useAsyncWindowOpen } from '@/hooks/use-async-window-open' import { useBillingUrl } from '@/service/use-billing' import PlanComp from '../plan' const Billing: FC = () => { const { t } = useTranslation() const { isCurrentWorkspaceManager } = useAppContext() const { enableBilling } = useProviderContext() const { data: billingUrl, isFetching, refetch } = useBillingUrl(enableBilling && isCurrentWorkspaceManager) const openAsyncWindow = useAsyncWindowOpen() const handleOpenBilling = async () => { await openAsyncWindow(async () => { const url = (await refetch()).data if (url) return url return null }, { immediateUrl: billingUrl, features: 'noopener,noreferrer', onError: (err) => { console.error('Failed to fetch billing url', err) }, }) } return (
{enableBilling && isCurrentWorkspaceManager && ( )}
) } export default React.memo(Billing)