diff --git a/src/components/Profile/ProfileEditForm.tsx b/src/components/Profile/ProfileEditForm.tsx index d1baa4ef..73240931 100644 --- a/src/components/Profile/ProfileEditForm.tsx +++ b/src/components/Profile/ProfileEditForm.tsx @@ -3,23 +3,37 @@ import styles from './ProfileEditForm.module.css'; import { AvatarUpload } from './AvatarUpload'; import { ProfileCompletion } from './ProfileCompletion'; +interface UserProfileData { + firstName?: string; + lastName?: string; + email?: string; + phone?: string; + avatarUrl?: string; + dateOfBirth?: string; + address?: string; + city?: string; + country?: string; +} + +interface UserProfile extends UserProfileData { + id: string; + firstName: string; + lastName: string; + email: string; + emailVerified?: boolean; + phoneVerified?: boolean; + isVerified?: boolean; +} + +interface ProfileCompletionState { + completionScore: number; + isComplete: boolean; + missingFields: string[]; +} + interface ProfileEditFormProps { - user?: { - id: string; - firstName: string; - lastName: string; - email: string; - phone?: string; - avatarUrl?: string; - emailVerified?: boolean; - phoneVerified?: boolean; - isVerified?: boolean; - dateOfBirth?: string; - address?: string; - city?: string; - country?: string; - }; - onSubmit: (data: any) => Promise; + user?: UserProfile; + onSubmit: (data: UserProfileData) => Promise; onAvatarUpload: (file: File) => Promise; isLoading?: boolean; } @@ -45,7 +59,7 @@ export const ProfileEditForm: React.FC = ({ const [errors, setErrors] = useState>({}); const [successMessage, setSuccessMessage] = useState(''); const [isSubmitting, setIsSubmitting] = useState(false); - const [profileCompletion, setProfileCompletion] = useState(null); + const [profileCompletion, setProfileCompletion] = useState(null); useEffect(() => { if (user) { @@ -72,7 +86,7 @@ export const ProfileEditForm: React.FC = ({ } }, [user]); - const calculateCompletion = (userData: any) => { + const calculateCompletion = (userData: UserProfileData): number => { let score = 0; const fields = [ userData.firstName, @@ -91,7 +105,7 @@ export const ProfileEditForm: React.FC = ({ return score; }; - const calculateMissingFields = (userData: any) => { + const calculateMissingFields = (userData: UserProfileData): string[] => { const missing = []; if (!userData.firstName) missing.push('firstName'); if (!userData.lastName) missing.push('lastName'); @@ -180,9 +194,9 @@ export const ProfileEditForm: React.FC = ({ missingFields: calculateMissingFields(formData), }; setProfileCompletion(completion); - } catch (error: any) { + } catch (error: unknown) { setErrors({ - submit: error.message || 'Failed to update profile', + submit: error instanceof Error ? error.message : 'Failed to update profile', }); } finally { setIsSubmitting(false);