diff --git a/src/app/portfolio/page.tsx b/src/app/portfolio/page.tsx index 5a5de29..653d319 100644 --- a/src/app/portfolio/page.tsx +++ b/src/app/portfolio/page.tsx @@ -6,7 +6,8 @@ import NavbarStyleCentered from "@/components/navbar/NavbarStyleCentered/NavbarS import TestimonialCardOne from "@/components/sections/testimonial/TestimonialCardOne"; import ContactText from "@/components/sections/contact/ContactText"; import FooterBaseCard from "@/components/sections/footer/FooterBaseCard"; -import { Camera } from "lucide-react"; +import { Camera, Upload, Trash2 } from "lucide-react"; +import { useState } from "react"; export default function PortfolioPage() { const navItems = [ @@ -51,6 +52,58 @@ export default function PortfolioPage() { }, ]; + const [uploadedMedia, setUploadedMedia] = useState< + Array<{ id: string; type: "photo" | "video"; src: string; name: string }> + >([]); + const [uploadError, setUploadError] = useState(""); + const [uploadSuccess, setUploadSuccess] = useState(false); + + const handleMediaUpload = ( + e: React.ChangeEvent, + mediaType: "photo" | "video" + ) => { + setUploadError(""); + setUploadSuccess(false); + + const files = e.target.files; + if (!files) return; + + Array.from(files).forEach((file) => { + const validPhotoTypes = ["image/jpeg", "image/png", "image/webp"]; + const validVideoTypes = ["video/mp4", "video/webm", "video/ogg"]; + const isValidPhoto = mediaType === "photo" && validPhotoTypes.includes(file.type); + const isValidVideo = mediaType === "video" && validVideoTypes.includes(file.type); + + if (!isValidPhoto && !isValidVideo) { + setUploadError(`Type de fichier non supporté: ${file.type}`); + return; + } + + if (file.size > 50 * 1024 * 1024) { + setUploadError("Le fichier est trop volumineux (max 50MB)"); + return; + } + + const reader = new FileReader(); + reader.onload = () => { + const newMedia = { + id: Date.now().toString(), + type: mediaType, + src: reader.result as string, + name: file.name, + }; + setUploadedMedia((prev) => [...prev, newMedia]); + setUploadSuccess(true); + setTimeout(() => setUploadSuccess(false), 3000); + }; + reader.readAsDataURL(file); + }); + }; + + const handleDeleteMedia = (id: string) => { + setUploadedMedia((prev) => prev.filter((media) => media.id !== id)); + }; + return ( + {/* Media Upload and Management Section */} +
+
+
+ {/* Header */} +
+
+ + Gestion des Médias +
+

+ Galerie des Projets Réalisés +

+

+ Téléchargez et gérez les photos et vidéos de vos projets complétés. Présentez votre portefeuille aux clients potentiels. +

+
+ +
+ {/* Upload Section */} +
+ {/* Photo Upload */} +
+

+ + Télécharger des Photos +

+ +
+ + {/* Video Upload */} +
+

+ + Télécharger des Vidéos +

+ +
+ + {/* Feedback Messages */} + {uploadError && ( +
+

{uploadError}

+
+ )} + {uploadSuccess && ( +
+

✓ Fichier uploadé avec succès!

+
+ )} +
+ + {/* Media Gallery */} +
+
+

+ Galerie ({uploadedMedia.length}) +

+ + {uploadedMedia.length === 0 ? ( +
+ +

+ Aucun média téléchargé. Commencez par ajouter des photos ou des vidéos de vos projets. +

+
+ ) : ( +
+ {uploadedMedia.map((media) => ( +
+ {media.type === "photo" ? ( + {media.name} + ) : ( +
+ )} +
+
+
+
+
+
+ {/* CTA Section */}