Skip to content

Commit a44ad6b

Browse files
authored
Merge pull request #74 from ungdev/dev
Fix :
2 parents 1702778 + 8408d36 commit a44ad6b

File tree

3 files changed

+106
-102
lines changed

3 files changed

+106
-102
lines changed

backend/src/controllers/permanence.controller.ts

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -58,37 +58,37 @@ export const createPermanence = async (req: Request, res: Response) => {
5858

5959

6060
export const updatePermanence = async (req: Request, res: Response) => {
61-
const { permId, name, description, location, start_at, end_at, capacity, difficulty, respoId } = req.body;
62-
if (!name || !location || !start_at || !end_at || !capacity || !difficulty) {
63-
Error(res, { msg: "Tous les champs sont requis" });
64-
return;
65-
}
66-
67-
const validation = validatePermanenceData(start_at, end_at);
68-
if (!validation.valid) {
69-
Error(res, { msg: validation.msg });
70-
return;
71-
}
72-
73-
try {
74-
await permanence_service.updatePermanence(
75-
permId,
76-
name,
77-
description,
78-
location,
79-
new Date(start_at),
80-
new Date(end_at),
81-
Number(capacity),
82-
Number(difficulty),
83-
Number(respoId)
84-
);
85-
Ok(res, { msg: "Permanence mis à jour avec succès" });
86-
} catch (err) {
87-
console.error(err);
88-
Error(res, { msg: "Erreur lors de la mis à jour de la permanence" });
89-
}
61+
const { permId, name, description, location, start_at, end_at, capacity, difficulty, respoId } = req.body;
62+
63+
const validation = validatePermanenceData(start_at, end_at);
64+
if (!validation.valid) {
65+
Error(res, { msg: validation.msg });
66+
return;
67+
}
68+
69+
try {
70+
const perm = await permanence_service.getPermanenceById(permId);
71+
72+
await permanence_service.updatePermanence(
73+
permId ?? perm.id,
74+
name ?? perm.name,
75+
description ?? perm.description,
76+
location ?? perm.location,
77+
start_at ? new Date(start_at) : perm.start_at,
78+
end_at ? new Date(end_at) : perm.end_at,
79+
capacity !== undefined ? Number(capacity) : perm.capacity,
80+
difficulty !== undefined ? Number(difficulty) : perm.difficulty,
81+
Number(respoId)
82+
);
83+
84+
Ok(res, { msg: "Permanence mise à jour avec succès" });
85+
} catch (err) {
86+
console.error(err);
87+
Error(res, { msg: "Erreur lors de la mise à jour de la permanence" });
88+
}
9089
};
9190

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

frontend/src/components/Admin/AdminPerm/adminPermForm.tsx

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -69,17 +69,16 @@ const PermanenceForm = ({
6969
}, [editMode, editPermanence]);
7070

7171
const handleSubmit = async () => {
72-
if (
73-
!name ||
74-
!desc ||
75-
!location ||
76-
!startAt ||
77-
!endAt ||
78-
!capacity ||
79-
!difficulty
80-
) {
81-
Swal.fire("Erreur", "Veuillez remplir tous les champs", "warning");
82-
return;
72+
if (!editMode) {
73+
if (!name || !desc || !location || !startAt || !endAt) {
74+
Swal.fire("Erreur", "Veuillez remplir tous les champs", "warning");
75+
return;
76+
}
77+
78+
if (capacity < 0 || difficulty < 0) {
79+
Swal.fire("Erreur", "Capacité et difficulté doivent être positives", "warning");
80+
return;
81+
}
8382
}
8483

8584

frontend/src/components/auth/authForm.tsx

Lines changed: 67 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -82,69 +82,74 @@ export const AuthForm = () => {
8282
};
8383

8484
return (
85-
<div
86-
className="relative min-h-screen flex items-center justify-center bg-no-repeat bg-cover bg-center"
87-
style={{ backgroundImage: "url('img/bg_25.jpg')" }}
88-
>
89-
<div className="absolute inset-0 bg-black opacity-50"></div>
90-
<div className="z-10 w-full max-w-md p-8 space-y-8 bg-white rounded-lg shadow-lg">
91-
<h2 className="text-3xl font-bold text-center">Connexion</h2>
92-
93-
{error && <p className="text-red-500 text-center">{error}</p>}
94-
95-
<form onSubmit={handleLogin} className="space-y-6">
96-
<div className="space-y-4">
97-
<div>
98-
<label htmlFor="email" className="block text-sm font-medium text-gray-700">Email</label>
99-
<Input
100-
type="email"
101-
id="email"
102-
name="email"
103-
value={formData.email}
104-
onChange={handleChange}
105-
ref={userRef}
106-
required
107-
/>
108-
</div>
109-
<div>
110-
<label htmlFor="password" className="block text-sm font-medium text-gray-700">Mot de passe</label>
111-
<Input
112-
type="password"
113-
id="password"
114-
name="password"
115-
value={formData.password}
116-
onChange={handleChange}
117-
required
118-
/>
119-
</div>
85+
<div
86+
className="relative min-h-screen flex items-center justify-center bg-no-repeat bg-cover bg-center"
87+
style={{ backgroundImage: "url('img/bg_25.jpg')" }}
88+
>
89+
<div className="absolute inset-0 bg-black opacity-50"></div>
90+
<div className="z-10 w-full max-w-md p-8 space-y-8 bg-white rounded-lg shadow-lg">
91+
<h2 className="text-3xl font-bold text-center">Connexion</h2>
92+
93+
{error && <p className="text-red-500 text-center">{error}</p>}
94+
95+
<form onSubmit={handleLogin} className="space-y-6">
96+
<div className="space-y-4">
97+
<div>
98+
<label htmlFor="email" className="block text-sm font-medium text-gray-700">Email</label>
99+
<Input
100+
type="email"
101+
id="email"
102+
name="email"
103+
value={formData.email}
104+
onChange={handleChange}
105+
ref={userRef}
106+
required
107+
/>
120108
</div>
121-
122-
<div className="flex flex-col gap-4">
123-
<Button type="submit" className="w-full py-2 bg-blue-600 text-white hover:bg-blue-700 transition">
124-
Connexion
125-
</Button>
126-
127-
<Button
128-
type="button"
129-
className="w-full py-2 bg-blue-900 text-white hover:bg-gray-700 transition"
130-
onClick={UTT_Connexion}
131-
>
132-
Connexion Étudiant UTT (CAS)
133-
</Button>
134-
<Button
135-
type="button"
136-
className="w-full py-2 bg-gray-200 text-gray-800 hover:bg-gray-300 transition"
137-
onClick={handlePasswordReset}
138-
>
139-
Mot de passe oublié ?
140-
</Button>
141-
142-
<p className="text-center text-sm text-gray-500">
143-
✉️ Tu es un nouveau ? Vérifie ton mail pour activer ton compte.
144-
</p>
109+
<div>
110+
<label htmlFor="password" className="block text-sm font-medium text-gray-700">Mot de passe</label>
111+
<Input
112+
type="password"
113+
id="password"
114+
name="password"
115+
value={formData.password}
116+
onChange={handleChange}
117+
required
118+
/>
145119
</div>
146-
</form>
147-
</div>
120+
</div>
121+
122+
<div className="flex flex-col gap-4">
123+
<Button type="submit" className="w-full py-2 bg-blue-600 text-white hover:bg-blue-700 transition">
124+
Connexion - Nouveau
125+
</Button>
126+
127+
<Button
128+
type="button"
129+
className="w-full py-2 bg-gray-200 text-gray-800 hover:bg-gray-300 transition"
130+
onClick={handlePasswordReset}
131+
>
132+
Mot de passe oublié ?
133+
</Button>
134+
135+
<p className="text-center text-sm text-gray-500">
136+
✉️ Nouveau ? Ton compte se crée via <strong>login + mot de passe</strong>.
137+
Vérifie ton mail pour l’activer.
138+
</p>
139+
</div>
140+
141+
{/* Bouton CAS placé en bas avec précision */}
142+
<div className="pt-4 border-t border-gray-200">
143+
<Button
144+
type="button"
145+
className="w-full py-2 bg-blue-900 text-white hover:bg-gray-700 transition"
146+
onClick={UTT_Connexion}
147+
>
148+
Connexion CAS – Orga / CE
149+
</Button>
150+
</div>
151+
</form>
148152
</div>
149-
);
153+
</div>
154+
);
150155
}

0 commit comments

Comments
 (0)