fix: add another check to limit submit form custom images to 3

This commit is contained in:
trafficlunar 2025-04-19 23:05:47 +01:00
parent efda1acdc1
commit febb83a164
2 changed files with 8 additions and 8 deletions

View file

@ -7,9 +7,5 @@ export default async function SubmitPage() {
if (!session) redirect("/login");
return (
<div className="flex justify-center">
<SubmitForm />
</div>
);
return <SubmitForm />;
}

View file

@ -23,9 +23,13 @@ import Carousel from "../carousel";
export default function SubmitForm() {
const [files, setFiles] = useState<FileWithPath[]>([]);
const handleDrop = useCallback((acceptedFiles: FileWithPath[]) => {
setFiles((prev) => [...prev, ...acceptedFiles]);
}, []);
const handleDrop = useCallback(
(acceptedFiles: FileWithPath[]) => {
if (files.length >= 3) return;
setFiles((prev) => [...prev, ...acceptedFiles]);
},
[files.length]
);
const { getRootProps, getInputProps } = useDropzone({
onDrop: handleDrop,