Checkpoint: Ajout de l'authentification formateur et upload logo/signature pour attestations
## Authentification formateur - Ajout du rôle "formateur" dans l'enum de la table users - Ajout du champ formateurId pour lier un compte à un formateur - Mise à jour de l'interface AdminUsers avec sélection du formateur - Redirection automatique selon le rôle (admin → /admin, formateur → /formateur) - Badges et filtres mis à jour pour inclure le rôle formateur ## Upload logo et signature - Création du composant ImageUpload.tsx avec prévisualisation - Création de l'endpoint /api/upload-image avec multer pour l'upload vers S3 - Intégration dans AdminAttestations.tsx - Modification du service PDF pour inclure le logo (en haut à droite) et la signature (en bas) - Mise à jour des procédures tRPC pour accepter logoUrl, logoS3Key, signatureUrl, signatureS3Key
This commit is contained in:
@@ -8,6 +8,7 @@ import { Label } from "@/components/ui/label";
|
||||
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";
|
||||
import { toast } from "sonner";
|
||||
import { FileText, Save } from "lucide-react";
|
||||
import ImageUpload from "@/components/ImageUpload";
|
||||
|
||||
export default function AdminAttestations() {
|
||||
const { data: config, isLoading, refetch } = trpc.attestations.getConfig.useQuery();
|
||||
@@ -17,6 +18,10 @@ export default function AdminAttestations() {
|
||||
nomSignataire: "",
|
||||
fonctionSignataire: "",
|
||||
texteAttestation: "",
|
||||
logoUrl: "",
|
||||
logoS3Key: "",
|
||||
signatureUrl: "",
|
||||
signatureS3Key: "",
|
||||
});
|
||||
|
||||
// Mettre à jour le formulaire quand les données sont chargées
|
||||
@@ -26,6 +31,10 @@ export default function AdminAttestations() {
|
||||
nomSignataire: config.nomSignataire || "",
|
||||
fonctionSignataire: config.fonctionSignataire || "",
|
||||
texteAttestation: config.texteAttestation || "",
|
||||
logoUrl: config.logoUrl || "",
|
||||
logoS3Key: config.logoS3Key || "",
|
||||
signatureUrl: config.signatureUrl || "",
|
||||
signatureS3Key: config.signatureS3Key || "",
|
||||
});
|
||||
}
|
||||
}, [config]);
|
||||
@@ -101,6 +110,32 @@ export default function AdminAttestations() {
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<CardTitle>Logo et signature</CardTitle>
|
||||
<CardDescription>
|
||||
Ajoutez un logo et une signature pour personnaliser vos attestations
|
||||
</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent className="space-y-6">
|
||||
<ImageUpload
|
||||
label="Logo de l'organisation"
|
||||
currentImageUrl={formData.logoUrl}
|
||||
onUploadComplete={(url, s3Key) =>
|
||||
setFormData({ ...formData, logoUrl: url, logoS3Key: s3Key })
|
||||
}
|
||||
/>
|
||||
|
||||
<ImageUpload
|
||||
label="Signature du signataire"
|
||||
currentImageUrl={formData.signatureUrl}
|
||||
onUploadComplete={(url, s3Key) =>
|
||||
setFormData({ ...formData, signatureUrl: url, signatureS3Key: s3Key })
|
||||
}
|
||||
/>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<CardTitle>Texte de l'attestation</CardTitle>
|
||||
@@ -137,6 +172,10 @@ export default function AdminAttestations() {
|
||||
nomSignataire: config.nomSignataire || "",
|
||||
fonctionSignataire: config.fonctionSignataire || "",
|
||||
texteAttestation: config.texteAttestation || "",
|
||||
logoUrl: config.logoUrl || "",
|
||||
logoS3Key: config.logoS3Key || "",
|
||||
signatureUrl: config.signatureUrl || "",
|
||||
signatureS3Key: config.signatureS3Key || "",
|
||||
});
|
||||
}
|
||||
}}
|
||||
|
||||
Reference in New Issue
Block a user