Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

index.tsx 3.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. 'use client'
  2. import type { FC } from 'react'
  3. import React from 'react'
  4. import { useTranslation } from 'react-i18next'
  5. import UpgradeBtn from '../upgrade-btn'
  6. import ProgressBar from '@/app/components/billing/progress-bar'
  7. import Button from '@/app/components/base/button'
  8. import { mailToSupport } from '@/app/components/header/utils/util'
  9. import { useProviderContext } from '@/context/provider-context'
  10. import { useAppContext } from '@/context/app-context'
  11. import { Plan } from '@/app/components/billing/type'
  12. import s from './style.module.css'
  13. import cn from '@/utils/classnames'
  14. const LOW = 50
  15. const MIDDLE = 80
  16. const AppsFull: FC<{ loc: string; className?: string; }> = ({
  17. loc,
  18. className,
  19. }) => {
  20. const { t } = useTranslation()
  21. const { plan } = useProviderContext()
  22. const { userProfile, langGeniusVersionInfo } = useAppContext()
  23. const isTeam = plan.type === Plan.team
  24. const usage = plan.usage.buildApps
  25. const total = plan.total.buildApps
  26. const percent = usage / total * 100
  27. const color = (() => {
  28. if (percent < LOW)
  29. return 'bg-components-progress-bar-progress-solid'
  30. if (percent < MIDDLE)
  31. return 'bg-components-progress-warning-progress'
  32. return 'bg-components-progress-error-progress'
  33. })()
  34. return (
  35. <div className={cn(
  36. 'flex flex-col gap-3 rounded-xl border-[0.5px] border-components-panel-border-subtle bg-components-panel-on-panel-item-bg p-4 shadow-xs backdrop-blur-sm',
  37. className,
  38. )}>
  39. <div className='flex justify-between'>
  40. {!isTeam && (
  41. <div>
  42. <div className={cn('title-xl-semi-bold mb-1', s.textGradient)}>
  43. {t('billing.apps.fullTip1')}
  44. </div>
  45. <div className='system-xs-regular text-text-tertiary'>{t('billing.apps.fullTip1des')}</div>
  46. </div>
  47. )}
  48. {isTeam && (
  49. <div>
  50. <div className={cn('title-xl-semi-bold mb-1', s.textGradient)}>
  51. {t('billing.apps.fullTip2')}
  52. </div>
  53. <div className='system-xs-regular text-text-tertiary'>{t('billing.apps.fullTip2des')}</div>
  54. </div>
  55. )}
  56. {(plan.type === Plan.sandbox || plan.type === Plan.professional) && (
  57. <UpgradeBtn isShort loc={loc} />
  58. )}
  59. {plan.type !== Plan.sandbox && plan.type !== Plan.professional && (
  60. <Button variant='secondary-accent'>
  61. <a target='_blank' rel='noopener noreferrer' href={mailToSupport(userProfile.email, plan.type, langGeniusVersionInfo.current_version)}>
  62. {t('billing.apps.contactUs')}
  63. </a>
  64. </Button>
  65. )}
  66. </div>
  67. <div className='flex flex-col gap-2'>
  68. <div className='system-xs-medium flex items-center justify-between text-text-secondary'>
  69. <div>{t('billing.usagePage.buildApps')}</div>
  70. <div>{usage}/{total}</div>
  71. </div>
  72. <ProgressBar
  73. percent={percent}
  74. color={color}
  75. />
  76. </div>
  77. </div>
  78. )
  79. }
  80. export default React.memo(AppsFull)