Skip to content

Commit a6a344e

Browse files
toast fix
1 parent 89270c5 commit a6a344e

1 file changed

Lines changed: 27 additions & 11 deletions

File tree

src/app/upload/page.tsx

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -97,17 +97,33 @@ export default function Page() {
9797
(file) => file.type === "application/pdf",
9898
);
9999

100-
if (
101-
(isNewPdf && acceptedFiles.length > 1) ||
102-
(isNewPdf && hasExistingImages) ||
103-
(isNewPdf && hasExistingPdf) ||
104-
(!isNewPdf && hasExistingPdf)
105-
) {
106-
toast.error("PDFs must be uploaded separately from images", {
107-
id: toastId,
108-
});
109-
return;
110-
}
100+
if (isNewPdf && acceptedFiles.length > 1) {
101+
toast.error("Only one PDF can be uploaded at a time.", {
102+
id: toastId,
103+
});
104+
return;
105+
}
106+
107+
if (isNewPdf && hasExistingImages) {
108+
toast.error("PDFs cannot be uploaded together with images.", {
109+
id: toastId,
110+
});
111+
return;
112+
}
113+
114+
if (isNewPdf && hasExistingPdf) {
115+
toast.error("Only one PDF is allowed. You’ve already uploaded a PDF.", {
116+
id: toastId,
117+
});
118+
return;
119+
}
120+
121+
if (!isNewPdf && hasExistingPdf) {
122+
toast.error("Images cannot be uploaded after a PDF. Upload them separately.", {
123+
id: toastId,
124+
});
125+
return;
126+
}
111127

112128
const allFiles = [...files, ...acceptedFiles];
113129
if (allFiles.length > 5) {

0 commit comments

Comments
 (0)