@@ -3,10 +3,40 @@ import { Link } from 'react-router-dom';
3
3
4
4
const CreateConference : React . FC = ( ) => {
5
5
const [ title , setTitle ] = useState ( '' ) ;
6
- const [ isLoading ] = useState ( false ) ;
7
- const [ message ] = useState ( '' ) ;
6
+ const [ isLoading , setIsLoading ] = useState ( false ) ;
7
+ const [ message , setMessage ] = useState ( '' ) ;
8
8
9
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
9
+ const handleSubmit = async ( event : React . FormEvent ) => {
10
+ event . preventDefault ( ) ;
11
+
12
+ if ( ! title || ! title . trim ( ) ) {
13
+ setMessage ( 'Vous devez écrire un contexte.' ) ;
14
+ return ;
15
+ }
16
+
17
+ setIsLoading ( true ) ;
18
+ setMessage ( 'Création en cours...' ) ;
19
+
20
+ try {
21
+ const response = await fetch ( 'https://api-generateconference.azurewebsites.net/Conference/CreateConference' , {
22
+ method : 'POST' ,
23
+ headers : {
24
+ 'Content-Type' : 'application/json'
25
+ } ,
26
+ body : JSON . stringify ( { Prompt : title } )
27
+ } ) ;
28
+
29
+ if ( response . ok ) {
30
+ setMessage ( 'La conférence a été créée.' ) ;
31
+ } else {
32
+ setMessage ( 'La création de la conférence a échoué.' ) ;
33
+ }
34
+ } catch ( error ) {
35
+ setMessage ( 'Une erreur est survenue lors de la création de la conférence.' ) ;
36
+ } finally {
37
+ setIsLoading ( false ) ;
38
+ }
39
+ } ;
10
40
11
41
return (
12
42
< div className = "flex flex-col items-center justify-center min-h-screen bg-gray-100 space-y-10" >
@@ -24,6 +54,7 @@ const CreateConference: React.FC = () => {
24
54
/>
25
55
< button
26
56
type = "submit"
57
+ onClick = { handleSubmit }
27
58
disabled = { isLoading }
28
59
className = "px-6 py-3 bg-blue-500 text-white rounded-lg shadow-md hover:bg-blue-600 transition-colors duration-200"
29
60
>
0 commit comments