feat: show more usage info in billing page (#4808)
This commit is contained in:
parent
11f173693b
commit
a7fb1ffcd8
12 changed files with 134 additions and 23 deletions
|
|
@ -1,7 +1,7 @@
|
|||
'use client'
|
||||
import { useEffect, useRef, useState } from 'react'
|
||||
import { useCallback, useEffect } from 'react'
|
||||
import Link from 'next/link'
|
||||
import { useBoolean, useClickAway } from 'ahooks'
|
||||
import { useBoolean } from 'ahooks'
|
||||
import { useSelectedLayoutSegment } from 'next/navigation'
|
||||
import { Bars3Icon } from '@heroicons/react/20/solid'
|
||||
import HeaderBillingBtn from '../billing/header-billing-btn'
|
||||
|
|
@ -15,9 +15,9 @@ import GithubStar from './github-star'
|
|||
import { WorkspaceProvider } from '@/context/workspace-context'
|
||||
import { useAppContext } from '@/context/app-context'
|
||||
import LogoSite from '@/app/components/base/logo/logo-site'
|
||||
import PlanComp from '@/app/components/billing/plan'
|
||||
import useBreakpoints, { MediaType } from '@/hooks/use-breakpoints'
|
||||
import { useProviderContext } from '@/context/provider-context'
|
||||
import { useModalContext } from '@/context/modal-context'
|
||||
|
||||
const navClassName = `
|
||||
flex items-center relative mr-0 sm:mr-3 px-3 h-8 rounded-xl
|
||||
|
|
@ -26,18 +26,21 @@ const navClassName = `
|
|||
`
|
||||
|
||||
const Header = () => {
|
||||
const { isCurrentWorkspaceManager, langeniusVersionInfo } = useAppContext()
|
||||
const [showUpgradePanel, setShowUpgradePanel] = useState(false)
|
||||
const upgradeBtnRef = useRef<HTMLElement>(null)
|
||||
useClickAway(() => {
|
||||
setShowUpgradePanel(false)
|
||||
}, upgradeBtnRef)
|
||||
const { isCurrentWorkspaceManager } = useAppContext()
|
||||
|
||||
const selectedSegment = useSelectedLayoutSegment()
|
||||
const media = useBreakpoints()
|
||||
const isMobile = media === MediaType.mobile
|
||||
const [isShowNavMenu, { toggle, setFalse: hideNavMenu }] = useBoolean(false)
|
||||
const { enableBilling } = useProviderContext()
|
||||
const { enableBilling, plan } = useProviderContext()
|
||||
const { setShowPricingModal, setShowAccountSettingModal } = useModalContext()
|
||||
const isFreePlan = plan.type === 'sandbox'
|
||||
const handlePlanClick = useCallback(() => {
|
||||
if (isFreePlan)
|
||||
setShowPricingModal()
|
||||
else
|
||||
setShowAccountSettingModal({ payload: 'billing' })
|
||||
}, [isFreePlan, setShowAccountSettingModal, setShowPricingModal])
|
||||
|
||||
useEffect(() => {
|
||||
hideNavMenu()
|
||||
|
|
@ -79,15 +82,7 @@ const Header = () => {
|
|||
<EnvNav />
|
||||
{enableBilling && (
|
||||
<div className='mr-3 select-none'>
|
||||
<HeaderBillingBtn onClick={() => setShowUpgradePanel(true)} />
|
||||
{showUpgradePanel && (
|
||||
<div
|
||||
ref={upgradeBtnRef as any}
|
||||
className='fixed z-10 top-12 right-1 w-[360px]'
|
||||
>
|
||||
<PlanComp loc='header' />
|
||||
</div>
|
||||
)}
|
||||
<HeaderBillingBtn onClick={handlePlanClick} />
|
||||
</div>
|
||||
)}
|
||||
<WorkspaceProvider>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue