import React, { useState } from 'react'; import axios from 'axios'; import { FaCloudUploadAlt, FaFileExcel, FaFilePdf, FaSpinner } from 'react-icons/fa'; import { motion } from 'framer-motion'; const UploadStep = ({ onUploadSuccess }) => { const [excelFile, setExcelFile] = useState(null); const [pdfFile, setPdfFile] = useState(null); const [loading, setLoading] = useState(false); const [error, setError] = useState(null); const handleUpload = async () => { if (!excelFile || !pdfFile) { setError("Please select both files."); return; } setLoading(true); setError(null); const formData = new FormData(); formData.append("excel_file", excelFile); formData.append("pdf_file", pdfFile); try { const response = await axios.post("/api/certificates/upload", formData, { headers: { "Content-Type": "multipart/form-data" } }); onUploadSuccess(response.data); } catch (err) { setError("Upload failed. Please try again."); console.error(err); } finally { setLoading(false); } }; const FileInput = ({ accept, label, icon: Icon, file, setFile }) => ( setFile(e.target.files[0])} className="absolute inset-0 w-full h-full opacity-0 cursor-pointer z-10" />

{label}

{file ? ( {file.name} ) : ( "Click to browse or drag & drop" )}

); return (

Upload Files

Upload your attendee list and certificate template to begin.

{error && ( {error} )}
{loading ? ( <> Processing... ) : ( <> Upload & Continue )}
); }; export default UploadStep;