import React, { useState } from 'react'; import { Box, Avatar, Typography, Button, IconButton } from '@mui/material'; import { useTranslation } from 'react-i18next'; import { Camera, Trash } from 'iconsax-react'; import { Icon } from '@rkheftan/harmony-ui'; const MAX_FILE_SIZE_MB = 10; interface ProfileImageProps { initials: string; uploadedImageUrl: string | null; onImageChange: (file: File) => void; onRemoveImage?: () => void; } export function ProfileImage({ initials, uploadedImageUrl, onImageChange, onRemoveImage, }: ProfileImageProps) { const { t } = useTranslation('profileSetting'); const [error, setError] = useState(null); const handleImageChange = (e: React.ChangeEvent) => { setError(null); const file = e.target.files?.[0]; if (!file) return; const fileSizeMB = file.size / (1024 * 1024); if (fileSizeMB > MAX_FILE_SIZE_MB) { setError(t('settingForm.fileSizeError', { size: MAX_FILE_SIZE_MB })); return; } onImageChange(file); }; return ( {initials} {t('settingForm.profilePicture')} {t('settingForm.allowedFormat')} {error && ( {error} )} {uploadedImageUrl && onRemoveImage && ( )} ); }