Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

Add .zip support

Tim Wilsonf7f080c4e4c5
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/programs/[programId]/resources/add-file-modal.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/programs/[programId]/resources/add-file-modal.tsx
index dad0b3a708..841354826c 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/programs/[programId]/resources/add-file-modal.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/programs/[programId]/resources/add-file-modal.tsx
@@ -119,7 +119,7 @@ function AddFileModalInner({ setShowAddFileModal }: AddFileModalProps) {
rules={{ required: "File is required" }}
render={({ field }) => (
<FileUpload
- accept="documents"
+ accept="programResourceFiles"
className={cn(
"aspect-[4.2] w-full rounded-md border border-neutral-300",
errors.file && "border-red-300 ring-1 ring-red-500",
@@ -146,7 +146,7 @@ function AddFileModalInner({ setShowAddFileModal }: AddFileModalProps) {
content={
field.value
? truncate(fileName, 25)
- : "Any document file format, max size of 10MB"
+ : "Any document or zip file, max size of 10MB"
}
maxFileSizeMB={10}
/>
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/programs/[programId]/resources/page-client.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/programs/[programId]/resources/page-client.tsx
index 616b21b501..ffa5dece5e 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/programs/[programId]/resources/page-client.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/programs/[programId]/resources/page-client.tsx
@@ -115,7 +115,7 @@ export function ProgramResourcesPageClient() {
<ResourceSection
resource="file"
title="Additional files"
- description="Any document file format, max size 10 MB"
+ description="Any document or zip file, max size 10 MB"
isLoading={isLoading}
isValidating={isValidating}
onAdd={() => setShowAddFileModal(true)}
diff --git a/packages/ui/src/file-upload.tsx b/packages/ui/src/file-upload.tsx
index 237a30c36b..da387c2e1b 100644
--- a/packages/ui/src/file-upload.tsx
+++ b/packages/ui/src/file-upload.tsx
@@ -4,7 +4,22 @@ import { DragEvent, ReactNode, useState } from "react";
import { toast } from "sonner";
import { CloudUpload, Icon, LoadingCircle } from "./icons";
-type AcceptedFileFormats = "any" | "images" | "csv" | "documents";
+type AcceptedFileFormats =
+ | "any"
+ | "images"
+ | "csv"
+ | "documents"
+ | "programResourceFiles";
+
+const documentTypes = [
+ "application/pdf", // .pdf
+ "text/plain", // .txt
+ "application/msword", // .doc
+ "application/vnd.openxmlformats-officedocument.wordprocessingml.document", // .docx
+ "application/vnd.ms-excel", // .xls
+ "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", // .xlsx
+ "text/csv", // .csv
+];
const acceptFileTypes: Record<
AcceptedFileFormats,
@@ -20,17 +35,15 @@ const acceptFileTypes: Record<
errorMessage: "File type not supported (.csv only)",
},
documents: {
- types: [
- "application/pdf", // .pdf
- "text/plain", // .txt
- "application/msword", // .doc
- "application/vnd.openxmlformats-officedocument.wordprocessingml.document", // .docx
- "application/vnd.ms-excel", // .xls
- "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", // .xlsx
- "text/csv", // .csv
- ],
+ types: documentTypes,
errorMessage: "File type not supported (document files only)",
},
+
+ // TODO: allow custom `accept` prop so we don't need specific options here
+ programResourceFiles: {
+ types: [...documentTypes, "application/zip"],
+ errorMessage: "File type not supported (document or zip files only)",
+ },
};
const imageUploadVariants = cva(