support.tsx 4.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. import { Menu, MenuButton, MenuItem, MenuItems, 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 h-full w-full">
  21. {
  22. ({ open }) => (
  23. <>
  24. <MenuButton className={
  25. cn('group flex h-9 w-full items-center gap-1 rounded-lg py-2 pl-3 pr-2 hover:bg-state-base-hover',
  26. open && 'bg-state-base-hover',
  27. )}>
  28. <RiQuestionLine className='size-4 shrink-0 text-text-tertiary' />
  29. <div className='system-md-regular grow px-1 text-left text-text-secondary'>{t('common.userProfile.support')}</div>
  30. <RiArrowRightSLine className='size-[14px] shrink-0 text-text-tertiary' />
  31. </MenuButton>
  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. <MenuItems
  42. className={cn(
  43. `absolute top-[1px] z-10 max-h-[70vh] w-[216px] origin-top-right -translate-x-full divide-y divide-divider-subtle overflow-y-scroll
  44. rounded-xl border-[0.5px] border-components-panel-border bg-components-panel-bg-blur shadow-lg backdrop-blur-[5px] focus:outline-none
  45. `,
  46. )}
  47. >
  48. <div className="px-1 py-1">
  49. {canEmailSupport && <MenuItem>
  50. <a
  51. className={cn(itemClassName, 'group justify-between',
  52. 'data-[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='size-4 shrink-0 text-text-tertiary' />
  57. <div className='system-md-regular grow px-1 text-text-secondary'>{t('common.userProfile.emailSupport')}</div>
  58. <RiArrowRightUpLine className='size-[14px] shrink-0 text-text-tertiary' />
  59. </a>
  60. </MenuItem>}
  61. <MenuItem>
  62. <Link
  63. className={cn(itemClassName, 'group justify-between',
  64. 'data-[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='size-4 shrink-0 text-text-tertiary' />
  69. <div className='system-md-regular grow px-1 text-text-secondary'>{t('common.userProfile.communityFeedback')}</div>
  70. <RiArrowRightUpLine className='size-[14px] shrink-0 text-text-tertiary' />
  71. </Link>
  72. </MenuItem>
  73. <MenuItem>
  74. <Link
  75. className={cn(itemClassName, 'group justify-between',
  76. 'data-[active]:bg-state-base-hover',
  77. )}
  78. href='https://discord.gg/5AEfbxcd9k'
  79. target='_blank' rel='noopener noreferrer'>
  80. <RiDiscordLine className='size-4 shrink-0 text-text-tertiary' />
  81. <div className='system-md-regular grow px-1 text-text-secondary'>{t('common.userProfile.community')}</div>
  82. <RiArrowRightUpLine className='size-[14px] shrink-0 text-text-tertiary' />
  83. </Link>
  84. </MenuItem>
  85. </div>
  86. </MenuItems>
  87. </Transition>
  88. </>
  89. )
  90. }
  91. </Menu>
  92. }