diff --git a/src/components/ProfileModal.tsx b/src/components/ProfileModal.tsx index 7d2d5f8..bfa855b 100644 --- a/src/components/ProfileModal.tsx +++ b/src/components/ProfileModal.tsx @@ -6,7 +6,7 @@ import type { ProfileData } from '../sdk/models/ProfileData'; interface ProfileModalProps { isOpen: boolean; onClose: () => void; - onSubmit: (profileData: ProfileData) => void; + onSubmit: (profileData: ProfileData, validatorId: string | null, ownerId: string | null) => void; initialData?: Partial; } @@ -23,6 +23,10 @@ function ProfileModal({ isOpen, onClose, onSubmit, initialData = {} }: ProfileMo idDocument: initialData.idDocument || null, idCertified: false, }); + const [validatorId, setValidatorId] = useState(null); + const [ownerId, setOwnerId] = useState(null); + const [isOwnProfile, setIsOwnProfile] = useState(false); + const [errorMessage, setErrorMessage] = useState(null); const handleChange = (e: React.ChangeEvent) => { const { name, type, files, value } = e.target; @@ -44,7 +48,12 @@ function ProfileModal({ isOpen, onClose, onSubmit, initialData = {} }: ProfileMo const handleSubmit = (e: React.FormEvent) => { e.preventDefault(); - onSubmit(profileData); + if (!validatorId && !ownerId) { + setErrorMessage("Please set either a Validator ID or an Owner ID."); + return; + } + setErrorMessage(null); + onSubmit(profileData, validatorId, ownerId); }; return ( @@ -176,6 +185,45 @@ function ProfileModal({ isOpen, onClose, onSubmit, initialData = {} }: ProfileMo +
+

Profil

+ + {isOwnProfile ? ( +
+ + { + setValidatorId(e.target.value); + setOwnerId(null); + }} + placeholder="ID du validateur" + /> +
+ ) : ( +
+ + { + setOwnerId(e.target.value); + setValidatorId(null); + }} + placeholder="ID de l'utilisateur" + /> +
+ )} +
+ + {errorMessage &&
{errorMessage}
} +