index.tsx 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. 'use client'
  2. import type { FC } from 'react'
  3. import React from 'react'
  4. import { createPortal } from 'react-dom'
  5. import { useTranslation } from 'react-i18next'
  6. import { RiCloseLine } from '@remixicon/react'
  7. import { Plan } from '../type'
  8. import SelectPlanRange, { PlanRange } from './select-plan-range'
  9. import PlanItem from './plan-item'
  10. import { useProviderContext } from '@/context/provider-context'
  11. import GridMask from '@/app/components/base/grid-mask'
  12. import { useAppContext } from '@/context/app-context'
  13. type Props = {
  14. onCancel: () => void
  15. }
  16. const Pricing: FC<Props> = ({
  17. onCancel,
  18. }) => {
  19. const { t } = useTranslation()
  20. const { plan } = useProviderContext()
  21. const { isCurrentWorkspaceManager } = useAppContext()
  22. const canPay = isCurrentWorkspaceManager
  23. const [planRange, setPlanRange] = React.useState<PlanRange>(PlanRange.monthly)
  24. return createPortal(
  25. <div
  26. className='fixed inset-0 flex bg-white z-[1000] overflow-auto'
  27. onClick={e => e.stopPropagation()}
  28. >
  29. <GridMask wrapperClassName='grow'>
  30. <div className='grow width-[0] mt-6 p-6 flex flex-col items-center'>
  31. <div className='mb-3 leading-[38px] text-[30px] font-semibold text-gray-900'>
  32. {t('billing.plansCommon.title')}
  33. </div>
  34. <SelectPlanRange
  35. value={planRange}
  36. onChange={setPlanRange}
  37. />
  38. <div className='mt-8 pb-6 w-full justify-center flex-nowrap flex space-x-3'>
  39. <PlanItem
  40. currentPlan={plan.type}
  41. plan={Plan.sandbox}
  42. planRange={planRange}
  43. canPay={canPay}
  44. />
  45. <PlanItem
  46. currentPlan={plan.type}
  47. plan={Plan.professional}
  48. planRange={planRange}
  49. canPay={canPay}
  50. />
  51. <PlanItem
  52. currentPlan={plan.type}
  53. plan={Plan.team}
  54. planRange={planRange}
  55. canPay={canPay}
  56. />
  57. <PlanItem
  58. currentPlan={plan.type}
  59. plan={Plan.enterprise}
  60. planRange={planRange}
  61. canPay={canPay}
  62. />
  63. </div>
  64. </div>
  65. </GridMask>
  66. <div
  67. className='fixed top-6 right-6 flex items-center justify-center w-10 h-10 bg-black/[0.05] rounded-full backdrop-blur-[2px] cursor-pointer z-[1001]'
  68. onClick={onCancel}
  69. >
  70. <RiCloseLine className='w-4 h-4 text-gray-900' />
  71. </div>
  72. </div>,
  73. document.body,
  74. )
  75. }
  76. export default React.memo(Pricing)