index.tsx 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. import { useMemo } from 'react'
  2. import { useTranslation } from 'react-i18next'
  3. import {
  4. DocumentProcessingPriority,
  5. Plan,
  6. } from '../type'
  7. import { useProviderContext } from '@/context/provider-context'
  8. import {
  9. ZapFast,
  10. ZapNarrow,
  11. } from '@/app/components/base/icons/src/vender/solid/general'
  12. import Tooltip from '@/app/components/base/tooltip'
  13. const PriorityLabel = () => {
  14. const { t } = useTranslation()
  15. const { plan } = useProviderContext()
  16. const priority = useMemo(() => {
  17. if (plan.type === Plan.sandbox)
  18. return DocumentProcessingPriority.standard
  19. if (plan.type === Plan.professional)
  20. return DocumentProcessingPriority.priority
  21. if (plan.type === Plan.team || plan.type === Plan.enterprise)
  22. return DocumentProcessingPriority.topPriority
  23. }, [plan])
  24. return (
  25. <Tooltip popupContent={
  26. <div>
  27. <div className='mb-1 text-xs font-semibold text-gray-700'>{`${t('billing.plansCommon.documentProcessingPriority')}: ${t(`billing.plansCommon.priority.${priority}`)}`}</div>
  28. {
  29. priority !== DocumentProcessingPriority.topPriority && (
  30. <div className='text-xs text-gray-500'>{t('billing.plansCommon.documentProcessingPriorityTip')}</div>
  31. )
  32. }
  33. </div>
  34. }>
  35. <span className={`
  36. flex items-center ml-1 px-[5px] h-[18px] rounded border border-[#C7D7FE]
  37. text-[10px] font-medium text-[#3538CD]
  38. `}>
  39. {
  40. plan.type === Plan.professional && (
  41. <ZapNarrow className='mr-0.5 w-3 h-3' />
  42. )
  43. }
  44. {
  45. (plan.type === Plan.team || plan.type === Plan.enterprise) && (
  46. <ZapFast className='mr-0.5 w-3 h-3' />
  47. )
  48. }
  49. {t(`billing.plansCommon.priority.${priority}`)}
  50. </span>
  51. </Tooltip>
  52. )
  53. }
  54. export default PriorityLabel