support.tsx 4.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. import { Menu, Transition } from '@headlessui/react'
  2. import { RiArrowRightSLine, RiArrowRightUpLine, RiDiscordLine, RiFeedbackLine, RiMailSendLine, RiQuestionLine } from '@remixicon/react'
  3. import { Fragment } from 'react'
  4. import Link from 'next/link'
  5. import { useTranslation } from 'react-i18next'
  6. import { mailToSupport } from '../utils/util'
  7. import cn from '@/utils/classnames'
  8. import { useProviderContext } from '@/context/provider-context'
  9. import { Plan } from '@/app/components/billing/type'
  10. import { useAppContext } from '@/context/app-context'
  11. export default function Support() {
  12. const itemClassName = `
  13. flex items-center w-full h-9 pl-3 pr-2 text-text-secondary system-md-regular
  14. rounded-lg hover:bg-state-base-hover cursor-pointer gap-1
  15. `
  16. const { t } = useTranslation()
  17. const { plan } = useProviderContext()
  18. const { userProfile, langeniusVersionInfo } = useAppContext()
  19. const canEmailSupport = plan.type === Plan.professional || plan.type === Plan.team || plan.type === Plan.enterprise
  20. return <Menu as="div" className="relative w-full h-full">
  21. {
  22. ({ open }) => (
  23. <>
  24. <Menu.Button className={
  25. cn('flex items-center pl-3 pr-2 py-2 h-9 w-full group hover:bg-state-base-hover rounded-lg gap-1',
  26. open && 'bg-state-base-hover',
  27. )}>
  28. <RiQuestionLine className='flex-shrink-0 size-4 text-text-tertiary' />
  29. <div className='flex-grow text-left system-md-regular text-text-secondary px-1'>{t('common.userProfile.support')}</div>
  30. <RiArrowRightSLine className='shrink-0 size-[14px] text-text-tertiary' />
  31. </Menu.Button>
  32. <Transition
  33. as={Fragment}
  34. enter="transition ease-out duration-100"
  35. enterFrom="transform opacity-0 scale-95"
  36. enterTo="transform opacity-100 scale-100"
  37. leave="transition ease-in duration-75"
  38. leaveFrom="transform opacity-100 scale-100"
  39. leaveTo="transform opacity-0 scale-95"
  40. >
  41. <Menu.Items
  42. className={cn(
  43. `absolute top-[1px] w-[216px] max-h-[70vh] overflow-y-scroll z-10 bg-components-panel-bg-blur backdrop-blur-[5px] border-[0.5px] border-components-panel-border
  44. divide-y divide-divider-subtle origin-top-right rounded-xl focus:outline-none shadow-lg -translate-x-full
  45. `,
  46. )}
  47. >
  48. <div className="px-1 py-1">
  49. {canEmailSupport && <Menu.Item>
  50. {({ active }) => <a
  51. className={cn(itemClassName, 'group justify-between',
  52. active && 'bg-state-base-hover',
  53. )}
  54. href={mailToSupport(userProfile.email, plan.type, langeniusVersionInfo.current_version)}
  55. target='_blank' rel='noopener noreferrer'>
  56. <RiMailSendLine className='flex-shrink-0 size-4 text-text-tertiary' />
  57. <div className='flex-grow system-md-regular text-text-secondary px-1'>{t('common.userProfile.emailSupport')}</div>
  58. <RiArrowRightUpLine className='flex-shrink-0 size-[14px] text-text-tertiary' />
  59. </a>}
  60. </Menu.Item>}
  61. <Menu.Item>
  62. {({ active }) => <Link
  63. className={cn(itemClassName, 'group justify-between',
  64. active && 'bg-state-base-hover',
  65. )}
  66. href='https://github.com/langgenius/dify/discussions/categories/feedbacks'
  67. target='_blank' rel='noopener noreferrer'>
  68. <RiFeedbackLine className='flex-shrink-0 size-4 text-text-tertiary' />
  69. <div className='flex-grow system-md-regular text-text-secondary px-1'>{t('common.userProfile.communityFeedback')}</div>
  70. <RiArrowRightUpLine className='flex-shrink-0 size-[14px] text-text-tertiary' />
  71. </Link>}
  72. </Menu.Item>
  73. <Menu.Item>
  74. {({ active }) => <Link
  75. className={cn(itemClassName, 'group justify-between',
  76. active && 'bg-state-base-hover',
  77. )}
  78. href='https://discord.gg/5AEfbxcd9k'
  79. target='_blank' rel='noopener noreferrer'>
  80. <RiDiscordLine className='flex-shrink-0 size-4 text-text-tertiary' />
  81. <div className='flex-grow system-md-regular text-text-secondary px-1'>{t('common.userProfile.community')}</div>
  82. <RiArrowRightUpLine className='flex-shrink-0 size-[14px] text-text-tertiary' />
  83. </Link>}
  84. </Menu.Item>
  85. </div>
  86. </Menu.Items>
  87. </Transition>
  88. </>
  89. )
  90. }
  91. </Menu>
  92. }