Skip to content

Papermark is the open-source DocSend alternative and secure data rooms with built-in analytics and custom domains.

feat: Add character limit and counter for agreement content

Cursor Agenta800b8106603
diff --git a/components/links/link-sheet/agreement-panel/index.tsx b/components/links/link-sheet/agreement-panel/index.tsx
index bb6651b8..23f47599 100644
--- a/components/links/link-sheet/agreement-panel/index.tsx
+++ b/components/links/link-sheet/agreement-panel/index.tsx
@@ -407,10 +407,16 @@ export default function AgreementSheet({
}
disabled={isOnlyView}
rows={6}
+ maxLength={1500}
/>
- <p className="text-xs text-muted-foreground">
- This text will be displayed to users as a compliance agreement before they can access the content.
- </p>
+ <div className="flex justify-between text-xs">
+ <p className="text-muted-foreground">
+ This text will be displayed to users as a compliance agreement before they can access the content.
+ </p>
+ <p className={`${data.textContent.length > 1400 ? 'text-orange-500' : 'text-muted-foreground'} ${data.textContent.length >= 1500 ? 'text-red-500 font-semibold' : ''}`}>
+ {data.textContent.length}/1500
+ </p>
+ </div>
</div>
)}
</div>
diff --git a/pages/api/teams/[teamId]/agreements/index.ts b/pages/api/teams/[teamId]/agreements/index.ts
index f11bd7c3..e65971ea 100644
--- a/pages/api/teams/[teamId]/agreements/index.ts
+++ b/pages/api/teams/[teamId]/agreements/index.ts
@@ -17,7 +17,7 @@ const createAgreementSchema = z.object({
.string()
.min(1, "Name is required")
.max(150, "Name must be less than 150 characters"),
- content: z.string().min(1, "Content is required"),
+ content: z.string().min(1, "Content is required").max(1500, "Content must be less than 1500 characters"),
contentType: z.enum(["LINK", "TEXT"]).default("LINK"),
requireName: z.boolean().default(false),
});