import { CopyOutlined, ReloadOutlined } from '@ant-design/icons'; import { Button, Card, Descriptions, Form, Input, Space, Tag, Typography } from 'antd'; import { useI18n } from '../frontend/i18n/react'; import type { RuntimeConfig, SmtpCredential } from '../frontend/types'; interface SmtpCredentialsProps { config: RuntimeConfig | null; credential: SmtpCredential | null; loading?: boolean; onCopy: (value: string) => void; onSave: (values: { username: string; password?: string }) => Promise; } export default function SmtpCredentials({ config, credential, loading, onCopy, onSave }: SmtpCredentialsProps) { const { t } = useI18n(); const [form] = Form.useForm(); function generatePassword() { const bytes = new Uint8Array(24); crypto.getRandomValues(bytes); const password = btoa(String.fromCharCode(...bytes)).replace(/[+/=]/g, '').slice(0, 28); form.setFieldValue('password', password); } return ( {copyable(config?.submission?.host || '-', onCopy)} {(config?.submission?.ports || []).map((item) => {item.port} ยท {item.protocol})} {config?.submission?.tls ? 'TLS' : 'STARTTLS'} {copyable(credential?.username || config?.submission?.username || '-', onCopy)} {credential?.password ? copyable(credential.password, onCopy) : {t('smtp.resetToCopy')}}
); } function copyable(value: string, onCopy: (value: string) => void) { return ( {value}