index.tsx 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. 'use client'
  2. import type { FC } from 'react'
  3. import React from 'react'
  4. import { useTranslation } from 'react-i18next'
  5. import {
  6. RiBook2Line,
  7. RiBox3Line,
  8. RiFileEditLine,
  9. RiGroup3Line,
  10. RiGroupLine,
  11. RiSquareLine,
  12. } from '@remixicon/react'
  13. import { Plan, SelfHostedPlan } from '../type'
  14. import VectorSpaceInfo from '../usage-info/vector-space-info'
  15. import AppsInfo from '../usage-info/apps-info'
  16. import UpgradeBtn from '../upgrade-btn'
  17. import { useProviderContext } from '@/context/provider-context'
  18. import UsageInfo from '@/app/components/billing/usage-info'
  19. type Props = {
  20. loc: string
  21. }
  22. const PlanComp: FC<Props> = ({
  23. loc,
  24. }) => {
  25. const { t } = useTranslation()
  26. const { plan } = useProviderContext()
  27. const {
  28. type,
  29. } = plan
  30. const {
  31. usage,
  32. total,
  33. } = plan
  34. return (
  35. <div className='bg-background-section-burn rounded-2xl border-[0.5px] border-effects-highlight-lightmode-off'>
  36. <div className='p-6 pb-2'>
  37. {plan.type === Plan.sandbox && (
  38. <RiBox3Line className='w-7 h-7 text-text-primary'/>
  39. )}
  40. {plan.type === Plan.professional && (
  41. <RiSquareLine className='w-7 h-7 rotate-90 text-util-colors-blue-brand-blue-brand-600'/>
  42. )}
  43. {plan.type === Plan.team && (
  44. <RiGroup3Line className='w-7 h-7 text-util-colors-indigo-indigo-600'/>
  45. )}
  46. {(plan.type as any) === SelfHostedPlan.enterprise && (
  47. <RiGroup3Line className='w-7 h-7 text-util-colors-indigo-indigo-600'/>
  48. )}
  49. <div className='mt-1 flex items-center'>
  50. <div className='grow'>
  51. <div className='mb-1 flex items-center gap-1'>
  52. <div className='text-text-primary system-md-semibold-uppercase'>{t(`billing.plans.${type}.name`)}</div>
  53. <div className='px-1 py-0.5 border border-divider-deep rounded-[5px] text-text-tertiary system-2xs-medium-uppercase'>{t('billing.currentPlan')}</div>
  54. </div>
  55. <div className='system-xs-regular text-util-colors-gray-gray-600'>{t(`billing.plans.${type}.for`)}</div>
  56. </div>
  57. {(plan.type as any) !== SelfHostedPlan.enterprise && (
  58. <UpgradeBtn
  59. className='shrink-0'
  60. isPlain={type === Plan.team}
  61. isShort
  62. loc={loc}
  63. />
  64. )}
  65. </div>
  66. </div>
  67. {/* Plan detail */}
  68. <div className='p-2 grid content-start grid-cols-3 gap-1'>
  69. <AppsInfo />
  70. <UsageInfo
  71. Icon={RiGroupLine}
  72. name={t('billing.usagePage.teamMembers')}
  73. usage={usage.teamMembers}
  74. total={total.teamMembers}
  75. />
  76. <UsageInfo
  77. Icon={RiBook2Line}
  78. name={t('billing.usagePage.documentsUploadQuota')}
  79. usage={usage.documentsUploadQuota}
  80. total={total.documentsUploadQuota}
  81. />
  82. <VectorSpaceInfo />
  83. <UsageInfo
  84. Icon={RiFileEditLine}
  85. name={t('billing.usagePage.annotationQuota')}
  86. usage={usage.annotatedResponse}
  87. total={total.annotatedResponse}
  88. />
  89. </div>
  90. </div>
  91. )
  92. }
  93. export default React.memo(PlanComp)