Checkpoint: Ajout du champ "Public cible" dans la fiche formation avec liste déroulante identique à celle de "Fonction" des apprenants (Directeur, Chef de service, Autre). Mise à jour du schéma de base de données, des procédures tRPC, du formulaire de gestion des formations avec affichage dans le tableau, et affichage du public cible sur la page d'inscription publique.
This commit is contained in:
@@ -22,6 +22,7 @@ export default function AdminFormations() {
|
||||
const [formData, setFormData] = useState({
|
||||
nom: "",
|
||||
description: "",
|
||||
publicCible: "autre" as "directeur" | "chef_service" | "autre",
|
||||
lienUnique: "",
|
||||
actif: true,
|
||||
});
|
||||
@@ -63,7 +64,7 @@ export default function AdminFormations() {
|
||||
});
|
||||
|
||||
const resetForm = () => {
|
||||
setFormData({ nom: "", description: "", lienUnique: "", actif: true });
|
||||
setFormData({ nom: "", description: "", publicCible: "autre" as "directeur" | "chef_service" | "autre", lienUnique: "", actif: true });
|
||||
setEditingId(null);
|
||||
};
|
||||
|
||||
@@ -71,6 +72,7 @@ export default function AdminFormations() {
|
||||
setFormData({
|
||||
nom: formation.nom,
|
||||
description: formation.description || "",
|
||||
publicCible: formation.publicCible || "autre",
|
||||
lienUnique: formation.lienUnique,
|
||||
actif: formation.actif,
|
||||
});
|
||||
@@ -167,6 +169,22 @@ export default function AdminFormations() {
|
||||
rows={3}
|
||||
/>
|
||||
</div>
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="publicCible">Public cible *</Label>
|
||||
<Select
|
||||
value={formData.publicCible}
|
||||
onValueChange={(value: "directeur" | "chef_service" | "autre") => setFormData({ ...formData, publicCible: value })}
|
||||
>
|
||||
<SelectTrigger id="publicCible">
|
||||
<SelectValue placeholder="Sélectionner le public cible" />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="directeur">Directeur</SelectItem>
|
||||
<SelectItem value="chef_service">Chef de service</SelectItem>
|
||||
<SelectItem value="autre">Autre</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="lienUnique">Lien unique *</Label>
|
||||
<Input
|
||||
@@ -270,16 +288,20 @@ export default function AdminFormations() {
|
||||
<TableRow>
|
||||
<TableHead>Nom</TableHead>
|
||||
<TableHead>Description</TableHead>
|
||||
<TableHead>Public cible</TableHead>
|
||||
<TableHead>Lien d'inscription</TableHead>
|
||||
<TableHead>Statut</TableHead>
|
||||
<TableHead className="text-right">Actions</TableHead>
|
||||
</TableRow>
|
||||
</TableHeader>
|
||||
<TableBody>
|
||||
{filteredFormations.map((formation) => (
|
||||
{filteredFormations.map((formation) => {
|
||||
const publicCibleLabel = formation.publicCible === "directeur" ? "Directeur" : formation.publicCible === "chef_service" ? "Chef de service" : "Autre";
|
||||
return (
|
||||
<TableRow key={formation.id}>
|
||||
<TableCell className="font-medium">{formation.nom}</TableCell>
|
||||
<TableCell className="max-w-xs truncate">{formation.description || "-"}</TableCell>
|
||||
<TableCell>{publicCibleLabel}</TableCell>
|
||||
<TableCell>
|
||||
<a
|
||||
href={getInscriptionUrl(formation.lienUnique)}
|
||||
@@ -319,7 +341,8 @@ export default function AdminFormations() {
|
||||
</div>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
))}
|
||||
);
|
||||
})}
|
||||
</TableBody>
|
||||
</Table>
|
||||
) : (
|
||||
|
||||
@@ -230,6 +230,10 @@ export default function Inscription() {
|
||||
{formation.description}
|
||||
</p>
|
||||
)}
|
||||
<div className="inline-flex items-center gap-2 bg-blue-100 text-blue-800 px-4 py-2 rounded-full text-sm font-medium">
|
||||
<Users className="w-4 h-4" />
|
||||
Public cible : {formation.publicCible === "directeur" ? "Directeurs" : formation.publicCible === "chef_service" ? "Chefs de service" : "Autre"}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Sessions disponibles */}
|
||||
|
||||
Reference in New Issue
Block a user