Removed unused imports
This commit is contained in:
@@ -4,7 +4,6 @@ import { useState, useRef } from "react";
|
||||
import { motion } from "framer-motion";
|
||||
import {
|
||||
Upload,
|
||||
Image as ImageIcon,
|
||||
FileText,
|
||||
X,
|
||||
CheckCircle,
|
||||
@@ -46,6 +45,7 @@ export default function SubmitPage() {
|
||||
});
|
||||
const [file, setFile] = useState<File | null>(null);
|
||||
const [preview, setPreview] = useState<string | null>(null);
|
||||
const [fileError, setFileError] = useState<string | null>(null);
|
||||
const [isDragging, setIsDragging] = useState(false);
|
||||
const [isSubmitting, setIsSubmitting] = useState(false);
|
||||
const [submitSuccess, setSubmitSuccess] = useState(false);
|
||||
@@ -55,13 +55,15 @@ export default function SubmitPage() {
|
||||
const validTypes = ["image/jpeg", "image/png", "application/pdf"];
|
||||
const maxSize = 10 * 1024 * 1024; // 10MB
|
||||
|
||||
setFileError(null);
|
||||
|
||||
if (!validTypes.includes(selectedFile.type)) {
|
||||
alert("Please upload a JPG, PNG, or PDF file.");
|
||||
setFileError("Invalid file type. Please upload a JPG, PNG, or PDF file.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (selectedFile.size > maxSize) {
|
||||
alert("File size must be less than 10MB.");
|
||||
setFileError("File too large. Maximum size is 10MB.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -97,6 +99,7 @@ export default function SubmitPage() {
|
||||
const removeFile = () => {
|
||||
setFile(null);
|
||||
setPreview(null);
|
||||
setFileError(null);
|
||||
if (fileInputRef.current) fileInputRef.current.value = "";
|
||||
};
|
||||
|
||||
@@ -125,6 +128,7 @@ export default function SubmitPage() {
|
||||
setFormData({ title: "", description: "", category: "" });
|
||||
setFile(null);
|
||||
setPreview(null);
|
||||
setFileError(null);
|
||||
}}
|
||||
className="inline-flex items-center justify-center gap-2 bg-lime-400 text-black px-8 py-4 rounded-full font-bold hover:bg-lime-300 transition-all"
|
||||
>
|
||||
@@ -300,6 +304,12 @@ export default function SubmitPage() {
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
{fileError && (
|
||||
<div className="flex items-center gap-2 mt-3 text-red-500 text-sm">
|
||||
<AlertCircle className="w-4 h-4 flex-shrink-0" />
|
||||
{fileError}
|
||||
</div>
|
||||
)}
|
||||
</motion.div>
|
||||
|
||||
{/* Title & Description */}
|
||||
|
||||
Reference in New Issue
Block a user