Validate.tsx 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. import Link from 'next/link'
  2. import { CheckCircleIcon, ExclamationCircleIcon } from '@heroicons/react/24/solid'
  3. import { useTranslation } from 'react-i18next'
  4. import { useContext } from 'use-context-selector'
  5. import I18n from '@/context/i18n'
  6. export const ValidatedErrorIcon = () => {
  7. return <ExclamationCircleIcon className='w-4 h-4 text-[#D92D20]' />
  8. }
  9. export const ValidatedSuccessIcon = () => {
  10. return <CheckCircleIcon className='w-4 h-4 text-[#039855]' />
  11. }
  12. export const ValidatingTip = () => {
  13. const { t } = useTranslation()
  14. return (
  15. <div className={`mt-2 text-primary-600 text-xs font-normal`}>
  16. {t('common.provider.validating')}
  17. </div>
  18. )
  19. }
  20. export const ValidatedExceedOnOpenaiTip = () => {
  21. const { t } = useTranslation()
  22. const { locale } = useContext(I18n)
  23. return (
  24. <div className={`mt-2 text-[#D92D20] text-xs font-normal`}>
  25. {t('common.provider.apiKeyExceedBill')}&nbsp;
  26. <Link
  27. className='underline'
  28. href="https://platform.openai.com/account/api-keys"
  29. target={'_blank'}>
  30. {locale === 'en' ? 'this link' : '这篇文档'}
  31. </Link>
  32. </div>
  33. )
  34. }
  35. export const ValidatedErrorOnOpenaiTip = ({ errorMessage }: { errorMessage: string }) => {
  36. const { t } = useTranslation()
  37. return (
  38. <div className={`mt-2 text-[#D92D20] text-xs font-normal`}>
  39. {t('common.provider.validatedError')}{errorMessage}
  40. </div>
  41. )
  42. }
  43. export const ValidatedErrorOnAzureOpenaiTip = ({ errorMessage }: { errorMessage: string }) => {
  44. const { t } = useTranslation()
  45. return (
  46. <div className={`mt-2 text-[#D92D20] text-xs font-normal`}>
  47. {t('common.provider.validatedError')}{errorMessage}
  48. </div>
  49. )
  50. }