clean edt athlete

This commit is contained in:
tuanvu
2026-01-08 15:31:07 +01:00
parent e72243d355
commit 286fa78eb0
3 changed files with 0 additions and 81 deletions

View File

@@ -11,21 +11,13 @@ import EdtCoach from './components/edt_coach'
import { Coach } from "./classes";
import RessourcePanel from './components/ressourcePanel';
import TestAPI from './components/test_api';
import EdtAthlete from './components/edt_athlete';
// Test
const testCoach = new Coach();
testCoach.id = 1;
testCoach.nom = "Coach Test";
const keycloakInitOptions = {
onLoad: 'login-required',
checkLoginIframe: false
}
function App() {
return (
<ReactKeycloakProvider authClient={keycloak} /*initOptions={keycloakInitOptions}*/>
<LocalDataProvider>
@@ -36,7 +28,6 @@ function App() {
<RessourcePanel/>
<EDT/>
<CreateSession/>
<EdtAthlete/>
<TestAPI/>
</div>
</LocalDataProvider>

View File

@@ -1,65 +0,0 @@
import React, { useState } from 'react';
export const EdtAthlete = () => {
const [formData, setFormData] = useState({
name: '',
prenom: '',
id_keycloak: '',
categorie: '',
niveau: ''
});
const handleSubmit = async (e: React.FormEvent) => {
e.preventDefault();
try {
const response = await fetch("http://localhost:8081/api/athlete/create", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify(formData),
});
if (response.ok) {
alert("Athlete created successfully in PostgreSQL!");
setFormData({ name: '', prenom: '', id_keycloak: '', categorie: '', niveau: '' });
} else {
alert("Failed to create athlete. Status: " + response.status);
}
} catch (error) {
console.error("Error creating athlete:", error);
alert("Error: Check console");
}
};
return (
<div style={{ padding: '20px', border: '1px solid #ccc', margin: '10px' }}>
<h3>Test Create Athlete (PostgreSQL)</h3>
<form onSubmit={handleSubmit}>
<div>
<label>Nom: </label>
<input type="text" value={formData.name} onChange={(e) => setFormData({...formData, name: e.target.value})} />
</div>
<div>
<label>Prénom: </label>
<input type="text" value={formData.prenom} onChange={(e) => setFormData({...formData, prenom: e.target.value})} />
</div>
<div>
<label>Keycloak ID: </label>
<input type="text" value={formData.id_keycloak} onChange={(e) => setFormData({...formData, id_keycloak: e.target.value})} />
</div>
<div>
<label>Catégorie: </label>
<input type="text" value={formData.categorie} onChange={(e) => setFormData({...formData, categorie: e.target.value})} />
</div>
<div>
<label>Niveau: </label>
<input type="text" value={formData.niveau} onChange={(e) => setFormData({...formData, niveau: e.target.value})} />
</div>
<button type="submit" style={{ marginTop: '10px' }}>Créer l'athlète</button>
</form>
</div>
);
};
export default EdtAthlete;