advanced-mode-waring.tsx 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. 'use client'
  2. import type { FC } from 'react'
  3. import React from 'react'
  4. import { useTranslation } from 'react-i18next'
  5. import { useContext } from 'use-context-selector'
  6. import I18n from '@/context/i18n'
  7. import { LanguagesSupported } from '@/i18n/language'
  8. type Props = {
  9. onReturnToSimpleMode: () => void
  10. }
  11. const AdvancedModeWarning: FC<Props> = ({
  12. onReturnToSimpleMode,
  13. }) => {
  14. const { t } = useTranslation()
  15. const { locale } = useContext(I18n)
  16. const [show, setShow] = React.useState(true)
  17. if (!show)
  18. return null
  19. return (
  20. <div className='mb-3 py-3 px-4 border border-[#FEF0C7] rounded-xl bg-[#FFFAEB]' >
  21. <div className='mb-2 text-xs leading-[18px] font-bold text-[#DC6803]'>{t('appDebug.promptMode.advancedWarning.title')}</div>
  22. <div className='flex justify-between items-center'>
  23. <div className='text-xs leading-[18px] '>
  24. <span className='text-gray-700'>{t('appDebug.promptMode.advancedWarning.description')}</span>
  25. <a
  26. className='font-medium text-[#155EEF]'
  27. href={`https://docs.dify.ai/${locale === LanguagesSupported[1] ? 'v/zh-hans/guides/application-design/prompt-engineering' : 'features/prompt-engineering'}`}
  28. target='_blank' rel='noopener noreferrer'
  29. >
  30. {t('appDebug.promptMode.advancedWarning.learnMore')}
  31. </a>
  32. </div>
  33. <div className='flex items-center space-x-1'>
  34. <div
  35. onClick={onReturnToSimpleMode}
  36. className='shrink-0 flex items-center h-6 px-2 bg-indigo-600 shadow-xs border border-gray-200 rounded-lg text-white text-xs font-semibold cursor-pointer space-x-1'
  37. >
  38. <div className='text-xs font-semibold uppercase'>{t('appDebug.promptMode.switchBack')}</div>
  39. </div>
  40. <div
  41. className='flex items-center h-6 px-2 rounded-md bg-[#fff] border border-gray-200 shadow-xs text-xs font-medium text-primary-600 cursor-pointer'
  42. onClick={() => setShow(false)}
  43. >{t('appDebug.promptMode.advancedWarning.ok')}</div>
  44. </div>
  45. </div>
  46. </div>
  47. )
  48. }
  49. export default React.memo(AdvancedModeWarning)