Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 29 additions & 29 deletions backend/src/controllers/permanence.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,37 +58,37 @@ export const createPermanence = async (req: Request, res: Response) => {


export const updatePermanence = async (req: Request, res: Response) => {
const { permId, name, description, location, start_at, end_at, capacity, difficulty, respoId } = req.body;
if (!name || !location || !start_at || !end_at || !capacity || !difficulty) {
Error(res, { msg: "Tous les champs sont requis" });
return;
}

const validation = validatePermanenceData(start_at, end_at);
if (!validation.valid) {
Error(res, { msg: validation.msg });
return;
}

try {
await permanence_service.updatePermanence(
permId,
name,
description,
location,
new Date(start_at),
new Date(end_at),
Number(capacity),
Number(difficulty),
Number(respoId)
);
Ok(res, { msg: "Permanence mis à jour avec succès" });
} catch (err) {
console.error(err);
Error(res, { msg: "Erreur lors de la mis à jour de la permanence" });
}
const { permId, name, description, location, start_at, end_at, capacity, difficulty, respoId } = req.body;

const validation = validatePermanenceData(start_at, end_at);
if (!validation.valid) {
Error(res, { msg: validation.msg });
return;
}

try {
const perm = await permanence_service.getPermanenceById(permId);

await permanence_service.updatePermanence(
permId ?? perm.id,
name ?? perm.name,
description ?? perm.description,
location ?? perm.location,
start_at ? new Date(start_at) : perm.start_at,
end_at ? new Date(end_at) : perm.end_at,
capacity !== undefined ? Number(capacity) : perm.capacity,
difficulty !== undefined ? Number(difficulty) : perm.difficulty,
Number(respoId)
);

Ok(res, { msg: "Permanence mise à jour avec succès" });
} catch (err) {
console.error(err);
Error(res, { msg: "Erreur lors de la mise à jour de la permanence" });
}
};


// ➕ Créer une permanence
export const deletePermanence = async (req: Request, res: Response) => {

Expand Down
21 changes: 10 additions & 11 deletions frontend/src/components/Admin/AdminPerm/adminPermForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,17 +69,16 @@ const PermanenceForm = ({
}, [editMode, editPermanence]);

const handleSubmit = async () => {
if (
!name ||
!desc ||
!location ||
!startAt ||
!endAt ||
!capacity ||
!difficulty
) {
Swal.fire("Erreur", "Veuillez remplir tous les champs", "warning");
return;
if (!editMode) {
if (!name || !desc || !location || !startAt || !endAt) {
Swal.fire("Erreur", "Veuillez remplir tous les champs", "warning");
return;
}

if (capacity < 0 || difficulty < 0) {
Swal.fire("Erreur", "Capacité et difficulté doivent être positives", "warning");
return;
}
}


Expand Down
129 changes: 67 additions & 62 deletions frontend/src/components/auth/authForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,69 +82,74 @@ export const AuthForm = () => {
};

return (
<div
className="relative min-h-screen flex items-center justify-center bg-no-repeat bg-cover bg-center"
style={{ backgroundImage: "url('img/bg_25.jpg')" }}
>
<div className="absolute inset-0 bg-black opacity-50"></div>
<div className="z-10 w-full max-w-md p-8 space-y-8 bg-white rounded-lg shadow-lg">
<h2 className="text-3xl font-bold text-center">Connexion</h2>

{error && <p className="text-red-500 text-center">{error}</p>}

<form onSubmit={handleLogin} className="space-y-6">
<div className="space-y-4">
<div>
<label htmlFor="email" className="block text-sm font-medium text-gray-700">Email</label>
<Input
type="email"
id="email"
name="email"
value={formData.email}
onChange={handleChange}
ref={userRef}
required
/>
</div>
<div>
<label htmlFor="password" className="block text-sm font-medium text-gray-700">Mot de passe</label>
<Input
type="password"
id="password"
name="password"
value={formData.password}
onChange={handleChange}
required
/>
</div>
<div
className="relative min-h-screen flex items-center justify-center bg-no-repeat bg-cover bg-center"
style={{ backgroundImage: "url('img/bg_25.jpg')" }}
>
<div className="absolute inset-0 bg-black opacity-50"></div>
<div className="z-10 w-full max-w-md p-8 space-y-8 bg-white rounded-lg shadow-lg">
<h2 className="text-3xl font-bold text-center">Connexion</h2>

{error && <p className="text-red-500 text-center">{error}</p>}

<form onSubmit={handleLogin} className="space-y-6">
<div className="space-y-4">
<div>
<label htmlFor="email" className="block text-sm font-medium text-gray-700">Email</label>
<Input
type="email"
id="email"
name="email"
value={formData.email}
onChange={handleChange}
ref={userRef}
required
/>
</div>

<div className="flex flex-col gap-4">
<Button type="submit" className="w-full py-2 bg-blue-600 text-white hover:bg-blue-700 transition">
Connexion
</Button>

<Button
type="button"
className="w-full py-2 bg-blue-900 text-white hover:bg-gray-700 transition"
onClick={UTT_Connexion}
>
Connexion Étudiant UTT (CAS)
</Button>
<Button
type="button"
className="w-full py-2 bg-gray-200 text-gray-800 hover:bg-gray-300 transition"
onClick={handlePasswordReset}
>
Mot de passe oublié ?
</Button>

<p className="text-center text-sm text-gray-500">
✉️ Tu es un nouveau ? Vérifie ton mail pour activer ton compte.
</p>
<div>
<label htmlFor="password" className="block text-sm font-medium text-gray-700">Mot de passe</label>
<Input
type="password"
id="password"
name="password"
value={formData.password}
onChange={handleChange}
required
/>
</div>
</form>
</div>
</div>

<div className="flex flex-col gap-4">
<Button type="submit" className="w-full py-2 bg-blue-600 text-white hover:bg-blue-700 transition">
Connexion - Nouveau
</Button>

<Button
type="button"
className="w-full py-2 bg-gray-200 text-gray-800 hover:bg-gray-300 transition"
onClick={handlePasswordReset}
>
Mot de passe oublié ?
</Button>

<p className="text-center text-sm text-gray-500">
✉️ Nouveau ? Ton compte se crée via <strong>login + mot de passe</strong>.
Vérifie ton mail pour l’activer.
</p>
</div>

{/* Bouton CAS placé en bas avec précision */}
<div className="pt-4 border-t border-gray-200">
<Button
type="button"
className="w-full py-2 bg-blue-900 text-white hover:bg-gray-700 transition"
onClick={UTT_Connexion}
>
Connexion CAS – Orga / CE
</Button>
</div>
</form>
</div>
);
</div>
);
}