2023-05-23 14:15:33 +08:00
|
|
|
import Link from 'next/link'
|
|
|
|
import { CheckCircleIcon, ExclamationCircleIcon } from '@heroicons/react/24/solid'
|
|
|
|
import { useTranslation } from 'react-i18next'
|
|
|
|
import { useContext } from 'use-context-selector'
|
|
|
|
import I18n from '@/context/i18n'
|
|
|
|
|
|
|
|
export const ValidatedErrorIcon = () => {
|
|
|
|
return <ExclamationCircleIcon className='w-4 h-4 text-[#D92D20]' />
|
|
|
|
}
|
|
|
|
|
|
|
|
export const ValidatedSuccessIcon = () => {
|
|
|
|
return <CheckCircleIcon className='w-4 h-4 text-[#039855]' />
|
|
|
|
}
|
|
|
|
|
|
|
|
export const ValidatingTip = () => {
|
|
|
|
const { t } = useTranslation()
|
|
|
|
return (
|
2023-06-01 23:19:36 +08:00
|
|
|
<div className={'mt-2 text-primary-600 text-xs font-normal'}>
|
2023-05-23 14:15:33 +08:00
|
|
|
{t('common.provider.validating')}
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
export const ValidatedExceedOnOpenaiTip = () => {
|
|
|
|
const { t } = useTranslation()
|
|
|
|
const { locale } = useContext(I18n)
|
|
|
|
|
|
|
|
return (
|
2023-06-01 23:19:36 +08:00
|
|
|
<div className={'mt-2 text-[#D92D20] text-xs font-normal'}>
|
2023-05-23 14:15:33 +08:00
|
|
|
{t('common.provider.apiKeyExceedBill')}
|
2023-06-01 23:19:36 +08:00
|
|
|
<Link
|
2023-05-23 14:15:33 +08:00
|
|
|
className='underline'
|
2023-06-01 23:19:36 +08:00
|
|
|
href="https://platform.openai.com/account/api-keys"
|
2023-05-23 14:15:33 +08:00
|
|
|
target={'_blank'}>
|
|
|
|
{locale === 'en' ? 'this link' : '这篇文档'}
|
|
|
|
</Link>
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2023-05-24 19:50:14 +08:00
|
|
|
export const ValidatedErrorOnOpenaiTip = ({ errorMessage }: { errorMessage: string }) => {
|
2023-05-23 14:15:33 +08:00
|
|
|
const { t } = useTranslation()
|
|
|
|
|
|
|
|
return (
|
2023-06-01 23:19:36 +08:00
|
|
|
<div className={'mt-2 text-[#D92D20] text-xs font-normal'}>
|
2023-05-24 19:50:14 +08:00
|
|
|
{t('common.provider.validatedError')}{errorMessage}
|
2023-05-23 14:15:33 +08:00
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2023-05-24 19:50:14 +08:00
|
|
|
export const ValidatedErrorOnAzureOpenaiTip = ({ errorMessage }: { errorMessage: string }) => {
|
2023-05-23 14:15:33 +08:00
|
|
|
const { t } = useTranslation()
|
|
|
|
|
|
|
|
return (
|
2023-06-01 23:19:36 +08:00
|
|
|
<div className={'mt-2 text-[#D92D20] text-xs font-normal'}>
|
2023-05-24 19:50:14 +08:00
|
|
|
{t('common.provider.validatedError')}{errorMessage}
|
2023-05-23 14:15:33 +08:00
|
|
|
</div>
|
|
|
|
)
|
2023-06-01 23:19:36 +08:00
|
|
|
}
|