Skip to content

Commit 5bcc773

Browse files
author
thomaslrt05
committed
update site
1 parent af7c965 commit 5bcc773

File tree

1 file changed

+34
-3
lines changed

1 file changed

+34
-3
lines changed

src/conference-ia/src/Components/CreateConference.tsx

+34-3
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,40 @@ import { Link } from 'react-router-dom';
33

44
const CreateConference: React.FC = () => {
55
const [title, setTitle] = useState('');
6-
const [isLoading] = useState(false);
7-
const [message] = useState('');
6+
const [isLoading, setIsLoading] = useState(false);
7+
const [message, setMessage] = useState('');
88

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+
};
1040

1141
return (
1242
<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 = () => {
2454
/>
2555
<button
2656
type="submit"
57+
onClick={handleSubmit}
2758
disabled={isLoading}
2859
className="px-6 py-3 bg-blue-500 text-white rounded-lg shadow-md hover:bg-blue-600 transition-colors duration-200"
2960
>

0 commit comments

Comments
 (0)