Checkpoint: Ajout de la possibilité de joindre un fichier dans l'envoi des rappels par email

Modifications apportées :
- Ajout des colonnes nomFichier, urlFichier, s3Key, typeFichier, tailleFichier dans la table rappels
- Création du composant FileUpload pour l'upload de fichiers vers S3 (max 10 Mo)
- Création de l'endpoint API /api/upload-file pour gérer l'upload
- Intégration du composant FileUpload dans les formulaires de création et modification de rappels
- Mise à jour des procédures tRPC create et update pour gérer les informations de fichier
- Modification des fonctions sendRappelJ7Email et sendRappelJ1Email pour inclure les pièces jointes
- Mise à jour du scheduler de rappels pour passer les informations de fichier lors de l'envoi
- Les fichiers sont téléchargés depuis S3 et convertis en base64 pour être attachés aux emails
This commit is contained in:
Manus
2026-01-08 06:00:27 -05:00
parent 6e25c00865
commit 5308b7921e
16 changed files with 2613 additions and 4 deletions

View File

@@ -24,6 +24,7 @@ import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@
import { trpc } from "@/lib/trpc";
import { Bell, Edit, Plus, Trash2 } from "lucide-react";
import { toast } from "sonner";
import { FileUpload } from "@/components/FileUpload";
// Types de templates disponibles pour les rappels
const TEMPLATE_TYPES = [
@@ -46,6 +47,13 @@ export default function AdminRappels() {
joursAvant: 7,
heureEnvoi: "09:00",
actif: true,
fichier: null as {
nomFichier: string;
urlFichier: string;
s3Key: string;
typeFichier: string;
tailleFichier: number;
} | null,
});
const { data: rappels, refetch } = trpc.rappels.list.useQuery();
@@ -98,6 +106,7 @@ export default function AdminRappels() {
setFormData({
nom: "",
templateType: "",
fichier: null,
timing: "pre_formation",
joursAvant: 7,
heureEnvoi: "09:00",
@@ -122,6 +131,13 @@ export default function AdminRappels() {
joursAvant: rappel.joursAvant,
heureEnvoi: rappel.heureEnvoi,
actif: rappel.actif,
fichier: rappel.nomFichier ? {
nomFichier: rappel.nomFichier,
urlFichier: rappel.urlFichier,
s3Key: rappel.s3Key,
typeFichier: rappel.typeFichier,
tailleFichier: rappel.tailleFichier,
} : null,
});
setIsEditOpen(true);
};
@@ -358,6 +374,13 @@ export default function AdminRappels() {
</p>
</div>
<FileUpload
value={formData.fichier}
onChange={(fichier) => setFormData({ ...formData, fichier })}
accept=".pdf,.doc,.docx,.xls,.xlsx,.ppt,.pptx,.jpg,.jpeg,.png"
maxSize={10}
/>
<div className="flex items-center space-x-2">
<Switch
id="actif"
@@ -478,6 +501,13 @@ export default function AdminRappels() {
/>
</div>
<FileUpload
value={formData.fichier}
onChange={(fichier) => setFormData({ ...formData, fichier })}
accept=".pdf,.doc,.docx,.xls,.xlsx,.ppt,.pptx,.jpg,.jpeg,.png"
maxSize={10}
/>
<div className="flex items-center space-x-2">
<Switch
id="edit-actif"