Skip to content

Commit f939ad3

Browse files
authored
Merge pull request #602 from mfts/feat/show-types
feat: add filetypes to upload
2 parents b16215f + 0a82ce9 commit f939ad3

File tree

2 files changed

+68
-51
lines changed

2 files changed

+68
-51
lines changed

components/document-upload.tsx

Lines changed: 36 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,10 @@ import { fileIcon } from "@/lib/utils/get-file-icon";
1111
import { getPagesCount } from "@/lib/utils/get-page-number-count";
1212

1313
const fileSizeLimits: { [key: string]: number } = {
14-
"application/vnd.ms-excel": 30, // 30 MB
15-
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": 30, // 30 MB
16-
"application/vnd.oasis.opendocument.spreadsheet": 30, // 30 MB
17-
"application/vnd.ms-powerpoint": 30, // 30 MB
18-
"application/vnd.openxmlformats-officedocument.presentationml.presentation": 30, // 30 MB
19-
"application/vnd.oasis.opendocument.presentation": 30, // 30 MB
20-
"application/msword": 30, // 30 MB
21-
"application/vnd.openxmlformats-officedocument.wordprocessingml.document": 30, // 30 MB
22-
"application/vnd.oasis.opendocument.text": 30, // 30 MB
23-
"text/csv": 30, // 30 MB
14+
"application/vnd.ms-excel": 40, // 40 MB
15+
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": 40, // 40 MB
16+
"application/vnd.oasis.opendocument.spreadsheet": 40, // 40 MB
17+
"text/csv": 40, // 40 MB
2418
};
2519

2620
export default function DocumentUpload({
@@ -33,26 +27,39 @@ export default function DocumentUpload({
3327
const { theme, systemTheme } = useTheme();
3428
const isLight =
3529
theme === "light" || (theme === "system" && systemTheme === "light");
36-
const { plan } = usePlan();
30+
const { plan, trial } = usePlan();
31+
const isFreePlan = plan === "free";
32+
const isTrial = !!trial;
3733
const maxSize = plan === "business" || plan === "datarooms" ? 100 : 30;
3834
const maxNumPages = plan === "business" || plan === "datarooms" ? 500 : 100;
3935

4036
const { getRootProps, getInputProps } = useDropzone({
41-
accept: {
42-
"application/pdf": [], // ".pdf"
43-
"application/vnd.ms-excel": [], // ".xls"
44-
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": [], // ".xlsx"
45-
"text/csv": [], // ".csv"
46-
"application/vnd.oasis.opendocument.spreadsheet": [], // ".ods"
47-
"application/vnd.ms-powerpoint": [], // ".ppt"
48-
"application/vnd.openxmlformats-officedocument.presentationml.presentation":
49-
[], // ".pptx"
50-
"application/vnd.oasis.opendocument.presentation": [], // ".odp"
51-
"application/msword": [], // ".doc"
52-
"application/vnd.openxmlformats-officedocument.wordprocessingml.document":
53-
[], // ".docx"
54-
"application/vnd.oasis.opendocument.text": [], // ".odt"
55-
},
37+
accept:
38+
isFreePlan && !isTrial
39+
? {
40+
"application/pdf": [], // ".pdf"
41+
"application/vnd.ms-excel": [], // ".xls"
42+
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":
43+
[], // ".xlsx"
44+
"text/csv": [], // ".csv"
45+
"application/vnd.oasis.opendocument.spreadsheet": [], // ".ods"
46+
}
47+
: {
48+
"application/pdf": [], // ".pdf"
49+
"application/vnd.ms-excel": [], // ".xls"
50+
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":
51+
[], // ".xlsx"
52+
"text/csv": [], // ".csv"
53+
"application/vnd.oasis.opendocument.spreadsheet": [], // ".ods"
54+
"application/vnd.ms-powerpoint": [], // ".ppt"
55+
"application/vnd.openxmlformats-officedocument.presentationml.presentation":
56+
[], // ".pptx"
57+
"application/vnd.oasis.opendocument.presentation": [], // ".odp"
58+
"application/msword": [], // ".doc"
59+
"application/vnd.openxmlformats-officedocument.wordprocessingml.document":
60+
[], // ".docx"
61+
"application/vnd.oasis.opendocument.text": [], // ".odt"
62+
},
5663
multiple: false,
5764
maxSize: maxSize * 1024 * 1024, // 30 MB
5865
onDropAccepted: (acceptedFiles) => {
@@ -151,7 +158,9 @@ export default function DocumentUpload({
151158
<p className="text-xs leading-5 text-gray-500">
152159
{currentFile
153160
? "Replace file?"
154-
: `Only *.xls, *.xlsx, *.csv, *.ods, *.pdf & ${maxSize} MB limit`}
161+
: isFreePlan && !isTrial
162+
? `Only *.pdf, *.xls, *.xlsx, *.csv, *.ods & ${maxSize} MB limit`
163+
: `Only *.pdf, *.pptx, *.docx, *.xlsx, *.xls, *.csv, *.ods, *.ppt, *.odp, *.doc, *.odt & ${maxSize} MB limit`}
155164
</p>
156165
</div>
157166
</div>

components/upload-zone.tsx

Lines changed: 32 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,6 @@ interface FileWithPath extends File {
2121
path?: string;
2222
}
2323

24-
const fileSizeLimits: { [key: string]: number } = {
25-
"application/vnd.ms-excel": 100, // 30 MB
26-
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": 30, // 30 MB
27-
"text/csv": 30, // 30 MB
28-
"application/vnd.oasis.opendocument.spreadsheet": 30, // 30 MB
29-
};
30-
3124
export default function UploadZone({
3225
children,
3326
onUploadStart,
@@ -60,10 +53,12 @@ export default function UploadZone({
6053
dataroomId?: string;
6154
}) {
6255
const analytics = useAnalytics();
63-
const { plan, loading } = usePlan();
56+
const { plan, trial } = usePlan();
6457
const router = useRouter();
6558
const teamInfo = useTeam();
6659
const { data: session } = useSession();
60+
const isFreePlan = plan === "free";
61+
const isTrial = !!trial;
6762
const maxSize = plan === "business" || plan === "datarooms" ? 250 : 30;
6863
const maxNumPages = plan === "business" || plan === "datarooms" ? 500 : 100;
6964

@@ -237,21 +232,32 @@ export default function UploadZone({
237232
);
238233

239234
const { getRootProps, getInputProps, isDragActive } = useDropzone({
240-
accept: {
241-
"application/pdf": [], // ".pdf"
242-
"application/vnd.ms-excel": [], // ".xls"
243-
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": [], // ".xlsx"
244-
"text/csv": [], // ".csv"
245-
"application/vnd.oasis.opendocument.spreadsheet": [], // ".ods"
246-
"application/vnd.openxmlformats-officedocument.wordprocessingml.document":
247-
[], // ".docx"
248-
"application/vnd.openxmlformats-officedocument.presentationml.presentation":
249-
[], // ".pptx"
250-
"application/vnd.ms-powerpoint": [], // ".ppt"
251-
"application/msword": [], // ".doc"
252-
"application/vnd.oasis.opendocument.text": [], // ".odt"
253-
"application/vnd.oasis.opendocument.presentation": [], // ".odp"
254-
},
235+
accept:
236+
isFreePlan && !isTrial
237+
? {
238+
"application/pdf": [], // ".pdf"
239+
"application/vnd.ms-excel": [], // ".xls"
240+
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":
241+
[], // ".xlsx"
242+
"text/csv": [], // ".csv"
243+
"application/vnd.oasis.opendocument.spreadsheet": [], // ".ods"
244+
}
245+
: {
246+
"application/pdf": [], // ".pdf"
247+
"application/vnd.ms-excel": [], // ".xls"
248+
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":
249+
[], // ".xlsx"
250+
"text/csv": [], // ".csv"
251+
"application/vnd.oasis.opendocument.spreadsheet": [], // ".ods"
252+
"application/vnd.openxmlformats-officedocument.wordprocessingml.document":
253+
[], // ".docx"
254+
"application/vnd.openxmlformats-officedocument.presentationml.presentation":
255+
[], // ".pptx"
256+
"application/vnd.ms-powerpoint": [], // ".ppt"
257+
"application/msword": [], // ".doc"
258+
"application/vnd.oasis.opendocument.text": [], // ".odt"
259+
"application/vnd.oasis.opendocument.presentation": [], // ".odp"
260+
},
255261
multiple: true,
256262
maxSize: maxSize * 1024 * 1024, // 30 MB
257263
onDrop,
@@ -285,7 +291,9 @@ export default function UploadZone({
285291
<div className="mt-4 flex flex-col text-sm leading-6 text-gray-800">
286292
<span className="mx-auto">Drop your file(s) to upload here</span>
287293
<p className="text-xs leading-5 text-gray-800">
288-
{`Only *.pdf, *.xls, *.xlsx, *.csv, *.ods & ${maxSize} MB limit`}
294+
{isFreePlan && !isTrial
295+
? `Only *.pdf, *.xls, *.xlsx, *.csv, *.ods & ${maxSize} MB limit`
296+
: `Only *.pdf, *.pptx, *.docx, *.xlsx, *.xls, *.csv, *.ods, *.ppt, *.odp, *.doc, *.odt & ${maxSize} MB limit`}
289297
</p>
290298
</div>
291299
</div>

0 commit comments

Comments
 (0)