import {
Box,
Typography,
TextField,
Button,
IconButton,
InputAdornment,
CircularProgress,
} from '@mui/material';
import { Edit2, TickCircle } from 'iconsax-react';
import { CountDownTimer } from '@/components/CountDownTimer';
import { CountryCodeSelector } from '../../CountryCodeSelector';
import { Icon } from '@rkheftan/harmony-ui';
import { type PhoneEditFormProps } from '@/features/profile/types/settingsType';
import { useState } from 'react';
export default function PhoneEditForm({
phoneNumber,
setPhoneNumber,
countryCode,
setCountryCode,
verificationCode,
setVerificationCode,
isVerified,
isVerifying,
buttonState,
setButtonState,
handleSendCode,
handleVerifyClick,
error,
inputError,
handleBlur,
textFieldRef,
inputRef,
phones,
t,
}: PhoneEditFormProps) {
const isValidPhoneNumber = (phone: string) => {
const digitsOnly = phone.replace(/\D/g, '');
return digitsOnly.length >= 8 && digitsOnly.length <= 15;
};
const [isSending, setIsSending] = useState(false);
return (
<>
{t('settingForm.editPhoneNumber')}
{t('settingForm.phoneNumberText')}({phones.map((p) => p.withCode)})
{t('settingForm.verb')}
setPhoneNumber(e.target.value)}
sx={{ flex: '1 1 220px' }}
placeholder="09123456789"
InputProps={{
endAdornment:
buttonState === 'counting' ? (
{
setButtonState('default');
setPhoneNumber('');
setVerificationCode('');
}}
edge="end"
>
) : (
),
}}
/>
{isVerified ? (
{t('settingForm.successButton')}
) : (
)}
{buttonState === 'counting' && !isVerified && (
setVerificationCode(e.target.value.replace(/\D/g, ''))
}
sx={{ flex: '1 1 240px', minWidth: 0 }}
placeholder={t('settingForm.verificationCode')}
/>
)}
>
);
}