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 }) => (
{file ? (
{file.name}
) : (
"Click to browse or drag & drop"
)}
{label}
Upload your attendee list and certificate template to begin.