import React from 'react'; import { TextField, Box, Button, Switch, FormGroup, Typography, InputAdornment, IconButton, CircularProgress, } from '@mui/material'; import { useTranslation } from 'react-i18next'; import { TickCircle, Edit } from 'iconsax-react'; import { Icon } from '@rkheftan/harmony-ui'; import { type EmailSectionProps } from '../types/settingForm'; export function EmailSection({ showEmail, setShowEmail, email, setEmail, correctEmail, codeSent, verificationCode, setVerificationCode, buttonState, getButtonLabel, handleSendCode, handleVerifyCode, emailVerified, loading, handleEditEmail, }: EmailSectionProps) { const { t } = useTranslation('completionForm'); const onSendCodeClick = () => { if (!correctEmail) return; handleSendCode(); }; const handleToggleEmail = (e: React.ChangeEvent) => { setShowEmail(e.target.checked); }; return ( <> {t('completion.determineEmail')} {showEmail && ( setEmail(e.target.value)} error={email.length > 0 && !correctEmail} sx={{ flex: '1 1 260px' }} slotProps={{ input: { startAdornment: !loading && emailVerified ? ( ) : null, endAdornment: buttonState === 'counting' ? ( ) : null, sx: { paddingLeft: buttonState === 'counting' ? 0 : undefined, }, }, }} /> {!loading && !emailVerified && ( )} {email && ( {correctEmail ? '' : t('completion.emailCorrectForm')} )} {!emailVerified && codeSent && correctEmail && ( setVerificationCode(e.target.value)} sx={{ flex: '1 1 260px' }} disabled={loading} /> )} )} ); }