Skip to content

Commit

Permalink
Merge pull request #602 from mfts/feat/show-types
Browse files Browse the repository at this point in the history
feat: add filetypes to upload
  • Loading branch information
mfts authored Sep 18, 2024
2 parents b16215f + 0a82ce9 commit f939ad3
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 51 deletions.
63 changes: 36 additions & 27 deletions components/document-upload.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,10 @@ import { fileIcon } from "@/lib/utils/get-file-icon";
import { getPagesCount } from "@/lib/utils/get-page-number-count";

const fileSizeLimits: { [key: string]: number } = {
"application/vnd.ms-excel": 30, // 30 MB
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": 30, // 30 MB
"application/vnd.oasis.opendocument.spreadsheet": 30, // 30 MB
"application/vnd.ms-powerpoint": 30, // 30 MB
"application/vnd.openxmlformats-officedocument.presentationml.presentation": 30, // 30 MB
"application/vnd.oasis.opendocument.presentation": 30, // 30 MB
"application/msword": 30, // 30 MB
"application/vnd.openxmlformats-officedocument.wordprocessingml.document": 30, // 30 MB
"application/vnd.oasis.opendocument.text": 30, // 30 MB
"text/csv": 30, // 30 MB
"application/vnd.ms-excel": 40, // 40 MB
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": 40, // 40 MB
"application/vnd.oasis.opendocument.spreadsheet": 40, // 40 MB
"text/csv": 40, // 40 MB
};

export default function DocumentUpload({
Expand All @@ -33,26 +27,39 @@ export default function DocumentUpload({
const { theme, systemTheme } = useTheme();
const isLight =
theme === "light" || (theme === "system" && systemTheme === "light");
const { plan } = usePlan();
const { plan, trial } = usePlan();
const isFreePlan = plan === "free";
const isTrial = !!trial;
const maxSize = plan === "business" || plan === "datarooms" ? 100 : 30;
const maxNumPages = plan === "business" || plan === "datarooms" ? 500 : 100;

const { getRootProps, getInputProps } = useDropzone({
accept: {
"application/pdf": [], // ".pdf"
"application/vnd.ms-excel": [], // ".xls"
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": [], // ".xlsx"
"text/csv": [], // ".csv"
"application/vnd.oasis.opendocument.spreadsheet": [], // ".ods"
"application/vnd.ms-powerpoint": [], // ".ppt"
"application/vnd.openxmlformats-officedocument.presentationml.presentation":
[], // ".pptx"
"application/vnd.oasis.opendocument.presentation": [], // ".odp"
"application/msword": [], // ".doc"
"application/vnd.openxmlformats-officedocument.wordprocessingml.document":
[], // ".docx"
"application/vnd.oasis.opendocument.text": [], // ".odt"
},
accept:
isFreePlan && !isTrial
? {
"application/pdf": [], // ".pdf"
"application/vnd.ms-excel": [], // ".xls"
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":
[], // ".xlsx"
"text/csv": [], // ".csv"
"application/vnd.oasis.opendocument.spreadsheet": [], // ".ods"
}
: {
"application/pdf": [], // ".pdf"
"application/vnd.ms-excel": [], // ".xls"
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":
[], // ".xlsx"
"text/csv": [], // ".csv"
"application/vnd.oasis.opendocument.spreadsheet": [], // ".ods"
"application/vnd.ms-powerpoint": [], // ".ppt"
"application/vnd.openxmlformats-officedocument.presentationml.presentation":
[], // ".pptx"
"application/vnd.oasis.opendocument.presentation": [], // ".odp"
"application/msword": [], // ".doc"
"application/vnd.openxmlformats-officedocument.wordprocessingml.document":
[], // ".docx"
"application/vnd.oasis.opendocument.text": [], // ".odt"
},
multiple: false,
maxSize: maxSize * 1024 * 1024, // 30 MB
onDropAccepted: (acceptedFiles) => {
Expand Down Expand Up @@ -151,7 +158,9 @@ export default function DocumentUpload({
<p className="text-xs leading-5 text-gray-500">
{currentFile
? "Replace file?"
: `Only *.xls, *.xlsx, *.csv, *.ods, *.pdf & ${maxSize} MB limit`}
: isFreePlan && !isTrial
? `Only *.pdf, *.xls, *.xlsx, *.csv, *.ods & ${maxSize} MB limit`
: `Only *.pdf, *.pptx, *.docx, *.xlsx, *.xls, *.csv, *.ods, *.ppt, *.odp, *.doc, *.odt & ${maxSize} MB limit`}
</p>
</div>
</div>
Expand Down
56 changes: 32 additions & 24 deletions components/upload-zone.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,6 @@ interface FileWithPath extends File {
path?: string;
}

const fileSizeLimits: { [key: string]: number } = {
"application/vnd.ms-excel": 100, // 30 MB
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": 30, // 30 MB
"text/csv": 30, // 30 MB
"application/vnd.oasis.opendocument.spreadsheet": 30, // 30 MB
};

export default function UploadZone({
children,
onUploadStart,
Expand Down Expand Up @@ -60,10 +53,12 @@ export default function UploadZone({
dataroomId?: string;
}) {
const analytics = useAnalytics();
const { plan, loading } = usePlan();
const { plan, trial } = usePlan();
const router = useRouter();
const teamInfo = useTeam();
const { data: session } = useSession();
const isFreePlan = plan === "free";
const isTrial = !!trial;
const maxSize = plan === "business" || plan === "datarooms" ? 250 : 30;
const maxNumPages = plan === "business" || plan === "datarooms" ? 500 : 100;

Expand Down Expand Up @@ -237,21 +232,32 @@ export default function UploadZone({
);

const { getRootProps, getInputProps, isDragActive } = useDropzone({
accept: {
"application/pdf": [], // ".pdf"
"application/vnd.ms-excel": [], // ".xls"
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": [], // ".xlsx"
"text/csv": [], // ".csv"
"application/vnd.oasis.opendocument.spreadsheet": [], // ".ods"
"application/vnd.openxmlformats-officedocument.wordprocessingml.document":
[], // ".docx"
"application/vnd.openxmlformats-officedocument.presentationml.presentation":
[], // ".pptx"
"application/vnd.ms-powerpoint": [], // ".ppt"
"application/msword": [], // ".doc"
"application/vnd.oasis.opendocument.text": [], // ".odt"
"application/vnd.oasis.opendocument.presentation": [], // ".odp"
},
accept:
isFreePlan && !isTrial
? {
"application/pdf": [], // ".pdf"
"application/vnd.ms-excel": [], // ".xls"
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":
[], // ".xlsx"
"text/csv": [], // ".csv"
"application/vnd.oasis.opendocument.spreadsheet": [], // ".ods"
}
: {
"application/pdf": [], // ".pdf"
"application/vnd.ms-excel": [], // ".xls"
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":
[], // ".xlsx"
"text/csv": [], // ".csv"
"application/vnd.oasis.opendocument.spreadsheet": [], // ".ods"
"application/vnd.openxmlformats-officedocument.wordprocessingml.document":
[], // ".docx"
"application/vnd.openxmlformats-officedocument.presentationml.presentation":
[], // ".pptx"
"application/vnd.ms-powerpoint": [], // ".ppt"
"application/msword": [], // ".doc"
"application/vnd.oasis.opendocument.text": [], // ".odt"
"application/vnd.oasis.opendocument.presentation": [], // ".odp"
},
multiple: true,
maxSize: maxSize * 1024 * 1024, // 30 MB
onDrop,
Expand Down Expand Up @@ -285,7 +291,9 @@ export default function UploadZone({
<div className="mt-4 flex flex-col text-sm leading-6 text-gray-800">
<span className="mx-auto">Drop your file(s) to upload here</span>
<p className="text-xs leading-5 text-gray-800">
{`Only *.pdf, *.xls, *.xlsx, *.csv, *.ods & ${maxSize} MB limit`}
{isFreePlan && !isTrial
? `Only *.pdf, *.xls, *.xlsx, *.csv, *.ods & ${maxSize} MB limit`
: `Only *.pdf, *.pptx, *.docx, *.xlsx, *.xls, *.csv, *.ods, *.ppt, *.odp, *.doc, *.odt & ${maxSize} MB limit`}
</p>
</div>
</div>
Expand Down

0 comments on commit f939ad3

Please sign in to comment.