Skip to content

Commit

Permalink
update site
Browse files Browse the repository at this point in the history
  • Loading branch information
thomaslrt05 committed May 3, 2024
1 parent af7c965 commit 5bcc773
Showing 1 changed file with 34 additions and 3 deletions.
37 changes: 34 additions & 3 deletions src/conference-ia/src/Components/CreateConference.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,40 @@ import { Link } from 'react-router-dom';

const CreateConference: React.FC = () => {
const [title, setTitle] = useState('');
const [isLoading] = useState(false);
const [message] = useState('');
const [isLoading, setIsLoading] = useState(false);
const [message, setMessage] = useState('');

// eslint-disable-next-line @typescript-eslint/no-unused-vars
const handleSubmit = async (event: React.FormEvent) => {
event.preventDefault();

if (!title || !title.trim()) {
setMessage('Vous devez écrire un contexte.');
return;
}

setIsLoading(true);
setMessage('Création en cours...');

try {
const response = await fetch('https://api-generateconference.azurewebsites.net/Conference/CreateConference', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({ Prompt: title })
});

if (response.ok) {
setMessage('La conférence a été créée.');
} else {
setMessage('La création de la conférence a échoué.');
}
} catch (error) {
setMessage('Une erreur est survenue lors de la création de la conférence.');
} finally {
setIsLoading(false);
}
};

return (
<div className="flex flex-col items-center justify-center min-h-screen bg-gray-100 space-y-10">
Expand All @@ -24,6 +54,7 @@ const CreateConference: React.FC = () => {
/>
<button
type="submit"
onClick={handleSubmit}
disabled={isLoading}
className="px-6 py-3 bg-blue-500 text-white rounded-lg shadow-md hover:bg-blue-600 transition-colors duration-200"
>
Expand Down

0 comments on commit 5bcc773

Please sign in to comment.