@@ -35,7 +35,7 @@ function TripInvitation({
3535 email : "" ,
3636 message : "" ,
3737 } ) ;
38-
38+ const [ copyLink , setCopyLink ] = useState ( false ) ;
3939 const [ loading , setLoading ] = useState ( false ) ;
4040
4141 const formatDate = ( dateString : string ) => {
@@ -62,6 +62,7 @@ function TripInvitation({
6262
6363 const cancelInvitation = ( e : React . MouseEvent < HTMLButtonElement > ) => {
6464 setInvitationForm ( { email : "" , message : "" } ) ;
65+ setCopyLink ( false ) ;
6566 if ( onClose ) onClose ( e ) ;
6667 } ;
6768
@@ -74,7 +75,7 @@ function TripInvitation({
7475 const copyToClipboard = async ( text : string ) => {
7576 try {
7677 await navigator . clipboard . writeText ( text ) ;
77- toast . success ( "Lien d’ invitation copié 📋 " ) ;
78+ toast . success ( "Lien d' invitation copié" ) ;
7879 } catch {
7980 toast . error ( "Impossible de copier le lien" ) ;
8081 }
@@ -100,8 +101,13 @@ function TripInvitation({
100101 throw new Error ( data . error || "Erreur lors de l'envoi" ) ;
101102 }
102103
103- await copyToClipboard ( data . invitationLink ) ;
104+ if ( copyLink ) {
105+ await copyToClipboard ( data . invitationLink ) ;
106+ toast . success ( "Email envoyé avec succès" ) ;
107+ }
108+
104109 setInvitationForm ( { email : "" , message : "" } ) ;
110+ setCopyLink ( false ) ;
105111 } catch {
106112 toast . error ( "Erreur lors de l'envoi de l'invitation" ) ;
107113 } finally {
@@ -120,7 +126,6 @@ function TripInvitation({
120126 } }
121127 aria-modal = "true"
122128 >
123-
124129 < ToastContainer position = "top-right" autoClose = { 3000 } theme = "light" />
125130 < article className = "tripinvitation-invitation-form" >
126131 < div className = "tripinvitation-head" >
@@ -162,6 +167,7 @@ function TripInvitation({
162167 onChange = { updateInvitationForm }
163168 required
164169 placeholder = "adresse@email.com"
170+ disabled = { loading }
165171 />
166172 </ label >
167173
@@ -172,15 +178,28 @@ function TripInvitation({
172178 value = { invitationForm . message }
173179 onChange = { updateInvitationForm }
174180 placeholder = "Ajoutez un message personnalisé..."
181+ disabled = { loading }
175182 />
176183 </ label >
177184
185+ < label >
186+ < div className = "tripinvitation-copy-checkbox" >
187+ < input
188+ type = "checkbox"
189+ checked = { copyLink }
190+ onChange = { ( e ) => setCopyLink ( e . target . checked ) }
191+ disabled = { loading }
192+ />
193+ Copier aussi le lien d'invitation
194+ </ div >
195+ </ label >
196+
178197 < button
179198 type = "submit"
180199 className = "tripinvitation-btn-send-invitation"
181- disabled = { loading }
200+ disabled = { loading || ! invitationForm . email }
182201 >
183- { loading ? "Copie ..." : "Copier le lien d'invitation " }
202+ { loading ? "Envoi ..." : "Envoyer par email " }
184203 </ button >
185204
186205 < button
0 commit comments