import { useTranslation } from 'react-i18next' import Indicator from '../../indicator' import type { Status } from './declarations' type OperateProps = { isOpen: boolean status: Status disabled?: boolean onCancel: () => void onSave: () => void onAdd: () => void onEdit: () => void } const Operate = ({ isOpen, status, disabled, onCancel, onSave, onAdd, onEdit, }: OperateProps) => { const { t } = useTranslation() if (isOpen) { return (
{t('common.operation.cancel')}
{t('common.operation.save')}
) } if (status === 'add') { return (
!disabled && onAdd()}> {t('common.provider.addKey')}
) } if (status === 'fail' || status === 'success') { return (
{ status === 'fail' && (
{t('common.provider.invalidApiKey')}
) } { status === 'success' && ( ) }
!disabled && onEdit()}> {t('common.provider.editKey')}
) } return null } export default Operate