index.tsx 2.3 KB

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