Skip to content

Commit 3b0fa05

Browse files
Merge pull request #412 from YOGESH-08/staging
fix: disable FiPlus when PDF is uploaded
2 parents 65618da + 0fef8fa commit 3b0fa05

File tree

1 file changed

+23
-11
lines changed

1 file changed

+23
-11
lines changed

src/app/upload/page.tsx

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -374,27 +374,39 @@ export default function Page() {
374374
}}
375375
multiple={true}
376376
>
377-
{({ getRootProps, getInputProps, isDragActive }) => (
377+
{({ getRootProps, getInputProps, isDragActive }) => {
378+
const pdfUploaded = files.some(f => f.type === "application/pdf");
379+
return(
378380
<div
379-
className={`relative h-20 w-20 flex-shrink-0 cursor-pointer touch-none ${
380-
isDragActive || isGlobalDragging
381-
? "border-2 border-solid border-[#6D28D9]"
382-
: ""
383-
}`}
384-
{...getRootProps()}
381+
className={`relative h-20 w-20 flex-shrink-0 touch-none group${
382+
isDragActive || isGlobalDragging
383+
? "border-2 border-solid border-[#6D28D9]"
384+
: ""
385+
}`}
386+
{...(!pdfUploaded ? getRootProps() : {})}
385387
>
386-
<input {...getInputProps()} />
387-
<div className="absolute left-4 top-4 h-16 w-16 rounded-2xl bg-violet-950" />
388+
{!pdfUploaded && <input {...getInputProps()} />}
389+
<div className={`absolute left-4 top-4 h-16 w-16 rounded-2xl bg-violet-950 ${pdfUploaded ? "text-gray-500 cursor-not-allowed" : "text-white cursor-pointer"}`} />
388390
<div className="absolute left-0 top-0 h-10 w-10 rounded-[20px] bg-violet-950" />
389391
<div className="absolute left-1 top-1 flex h-8 w-8 items-center rounded-[20px] bg-black/50" />
390-
<div className="absolute left-9 top-9 text-2xl text-white">
392+
<div className={`absolute left-9 top-9 text-2xl ${pdfUploaded ? "text-gray-500 cursor-not-allowed" : "text-white cursor-pointer"}`}
393+
>
394+
<div className={`absolute text-2xl ${pdfUploaded ? "text-gray-500 cursor-not-allowed" : "text-white cursor-pointer"}`}
395+
>
391396
<FiPlus className="h-7 w-7" />
397+
398+
{pdfUploaded && (<div className="absolute left-12 top-1/2 -translate-y-1/2 whitespace-nowrap rounded-md bg-gradient-to-r from-indigo-900 to-violet-900 px-3 py-1 text-xs text-white shadow-lg opacity-0 group-hover:opacity-100 transition-all duration-300 group-hover:translate-x-1">
399+
Only one PDF file is permitted.
400+
</div>
401+
)}
402+
</div>
392403
</div>
393404
<div className="absolute left-4 top-3 text-xs font-semibold text-white">
394405
{previews.length}
395406
</div>
396407
</div>
397-
)}
408+
);
409+
}}
398410
</Dropzone>
399411
)}
400412
{previews.length > 0 && (

0 commit comments

Comments
 (0)