-
Notifications
You must be signed in to change notification settings - Fork 1k
Update link agreement to show compliance text #1850
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
98b79ca
638da21
825536c
74771b6
5c75f85
6240cd3
7b56525
3105753
a6259c6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -31,6 +31,8 @@ import { | |||||||||||||||||||||||||||||||||||||||||||||
SheetHeader, | ||||||||||||||||||||||||||||||||||||||||||||||
SheetTitle, | ||||||||||||||||||||||||||||||||||||||||||||||
} from "@/components/ui/sheet"; | ||||||||||||||||||||||||||||||||||||||||||||||
import { Textarea } from "@/components/ui/textarea"; | ||||||||||||||||||||||||||||||||||||||||||||||
import { RadioGroup, RadioGroupItem } from "@/components/ui/radio-group"; | ||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
import LinkItem from "../link-item"; | ||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
|
@@ -50,15 +52,21 @@ export default function AgreementSheet({ | |||||||||||||||||||||||||||||||||||||||||||||
isOnlyView = false, | ||||||||||||||||||||||||||||||||||||||||||||||
onClose, | ||||||||||||||||||||||||||||||||||||||||||||||
}: { | ||||||||||||||||||||||||||||||||||||||||||||||
defaultData?: { name: string; link: string; requireName: boolean } | null; | ||||||||||||||||||||||||||||||||||||||||||||||
defaultData?: { name: string; link: string; requireName: boolean; contentType?: string; textContent?: string } | null; | ||||||||||||||||||||||||||||||||||||||||||||||
isOpen: boolean; | ||||||||||||||||||||||||||||||||||||||||||||||
setIsOpen: Dispatch<SetStateAction<boolean>>; | ||||||||||||||||||||||||||||||||||||||||||||||
isOnlyView?: boolean; | ||||||||||||||||||||||||||||||||||||||||||||||
onClose?: () => void; | ||||||||||||||||||||||||||||||||||||||||||||||
}) { | ||||||||||||||||||||||||||||||||||||||||||||||
const teamInfo = useTeam(); | ||||||||||||||||||||||||||||||||||||||||||||||
const teamId = teamInfo?.currentTeam?.id; | ||||||||||||||||||||||||||||||||||||||||||||||
const [data, setData] = useState({ name: "", link: "", requireName: true }); | ||||||||||||||||||||||||||||||||||||||||||||||
const [data, setData] = useState({ | ||||||||||||||||||||||||||||||||||||||||||||||
name: "", | ||||||||||||||||||||||||||||||||||||||||||||||
link: "", | ||||||||||||||||||||||||||||||||||||||||||||||
textContent: "", | ||||||||||||||||||||||||||||||||||||||||||||||
contentType: "LINK", | ||||||||||||||||||||||||||||||||||||||||||||||
requireName: true | ||||||||||||||||||||||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||||||||||||||||||||||
const [isLoading, setIsLoading] = useState<boolean>(false); | ||||||||||||||||||||||||||||||||||||||||||||||
const [currentFile, setCurrentFile] = useState<File | null>(null); | ||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
|
@@ -71,14 +79,22 @@ export default function AgreementSheet({ | |||||||||||||||||||||||||||||||||||||||||||||
setData({ | ||||||||||||||||||||||||||||||||||||||||||||||
name: defaultData?.name || "", | ||||||||||||||||||||||||||||||||||||||||||||||
link: defaultData?.link || "", | ||||||||||||||||||||||||||||||||||||||||||||||
textContent: defaultData?.textContent || "", | ||||||||||||||||||||||||||||||||||||||||||||||
contentType: defaultData?.contentType || "LINK", | ||||||||||||||||||||||||||||||||||||||||||||||
requireName: defaultData?.requireName || true, | ||||||||||||||||||||||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
84
to
85
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Boolean defaulting bug: false gets coerced to true.
- requireName: defaultData?.requireName || true,
+ requireName: defaultData?.requireName ?? true, 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents
|
||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||
}, [defaultData]); | ||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
const handleClose = (open: boolean) => { | ||||||||||||||||||||||||||||||||||||||||||||||
setIsOpen(open); | ||||||||||||||||||||||||||||||||||||||||||||||
setData({ name: "", link: "", requireName: true }); | ||||||||||||||||||||||||||||||||||||||||||||||
setData({ | ||||||||||||||||||||||||||||||||||||||||||||||
name: "", | ||||||||||||||||||||||||||||||||||||||||||||||
link: "", | ||||||||||||||||||||||||||||||||||||||||||||||
textContent: "", | ||||||||||||||||||||||||||||||||||||||||||||||
contentType: "LINK", | ||||||||||||||||||||||||||||||||||||||||||||||
requireName: true | ||||||||||||||||||||||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||||||||||||||||||||||
setCurrentFile(null); | ||||||||||||||||||||||||||||||||||||||||||||||
setIsLoading(false); | ||||||||||||||||||||||||||||||||||||||||||||||
if (onClose) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
@@ -184,28 +200,42 @@ export default function AgreementSheet({ | |||||||||||||||||||||||||||||||||||||||||||||
return; | ||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
// Validate URL before submitting | ||||||||||||||||||||||||||||||||||||||||||||||
try { | ||||||||||||||||||||||||||||||||||||||||||||||
agreementUrlSchema.parse(data.link); | ||||||||||||||||||||||||||||||||||||||||||||||
} catch (error) { | ||||||||||||||||||||||||||||||||||||||||||||||
if (error instanceof z.ZodError) { | ||||||||||||||||||||||||||||||||||||||||||||||
const firstError = error.errors[0]; | ||||||||||||||||||||||||||||||||||||||||||||||
toast.error(firstError?.message || "Please enter a valid URL"); | ||||||||||||||||||||||||||||||||||||||||||||||
// Validate based on content type | ||||||||||||||||||||||||||||||||||||||||||||||
if (data.contentType === "LINK") { | ||||||||||||||||||||||||||||||||||||||||||||||
// Validate URL | ||||||||||||||||||||||||||||||||||||||||||||||
try { | ||||||||||||||||||||||||||||||||||||||||||||||
agreementUrlSchema.parse(data.link); | ||||||||||||||||||||||||||||||||||||||||||||||
} catch (error) { | ||||||||||||||||||||||||||||||||||||||||||||||
if (error instanceof z.ZodError) { | ||||||||||||||||||||||||||||||||||||||||||||||
const firstError = error.errors[0]; | ||||||||||||||||||||||||||||||||||||||||||||||
toast.error(firstError?.message || "Please enter a valid URL"); | ||||||||||||||||||||||||||||||||||||||||||||||
return; | ||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||
} else if (data.contentType === "TEXT") { | ||||||||||||||||||||||||||||||||||||||||||||||
// Validate text content | ||||||||||||||||||||||||||||||||||||||||||||||
if (!data.textContent.trim()) { | ||||||||||||||||||||||||||||||||||||||||||||||
toast.error("Please enter agreement text content"); | ||||||||||||||||||||||||||||||||||||||||||||||
return; | ||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
setIsLoading(true); | ||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
try { | ||||||||||||||||||||||||||||||||||||||||||||||
const submitData = { | ||||||||||||||||||||||||||||||||||||||||||||||
name: data.name, | ||||||||||||||||||||||||||||||||||||||||||||||
contentType: data.contentType, | ||||||||||||||||||||||||||||||||||||||||||||||
content: data.contentType === "LINK" ? data.link : data.textContent, | ||||||||||||||||||||||||||||||||||||||||||||||
requireName: data.requireName, | ||||||||||||||||||||||||||||||||||||||||||||||
}; | ||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
const response = await fetch(`/api/teams/${teamId}/agreements`, { | ||||||||||||||||||||||||||||||||||||||||||||||
method: "POST", | ||||||||||||||||||||||||||||||||||||||||||||||
headers: { | ||||||||||||||||||||||||||||||||||||||||||||||
"Content-Type": "application/json", | ||||||||||||||||||||||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||||||||||||||||||||||
body: JSON.stringify({ | ||||||||||||||||||||||||||||||||||||||||||||||
...data, | ||||||||||||||||||||||||||||||||||||||||||||||
}), | ||||||||||||||||||||||||||||||||||||||||||||||
body: JSON.stringify(submitData), | ||||||||||||||||||||||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
233
to
239
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Verification agent 🧩 Analysis chainGuard POST against missing teamId. Same concern as upload flow. Add before fetch: + if (!teamId) {
+ toast.error("No active team found.");
+ return;
+ } Run to confirm no other 🏁 Script executed: #!/bin/bash
rg -nP --type tsx -C1 '\bteamId!?\b' Length of output: 27 🏁 Script executed: #!/bin/bash
# Search for non-null assertions on teamId in .ts and .tsx files
rg -nP '\bteamId\s*!' -g '*.ts' -g '*.tsx' Length of output: 4058 Add guard for missing teamId in agreement-panel In components/links/link-sheet/agreement-panel/index.tsx you still have non-null assertions on teamId at lines 137, 151 and the fetch at 233. Add before each usage: + if (!teamId) {
+ toast.error("No active team found.");
+ return;
+ } 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents
|
||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
if (!response.ok) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
@@ -220,7 +250,13 @@ export default function AgreementSheet({ | |||||||||||||||||||||||||||||||||||||||||||||
} finally { | ||||||||||||||||||||||||||||||||||||||||||||||
setIsLoading(false); | ||||||||||||||||||||||||||||||||||||||||||||||
setIsOpen(false); | ||||||||||||||||||||||||||||||||||||||||||||||
setData({ name: "", link: "", requireName: true }); | ||||||||||||||||||||||||||||||||||||||||||||||
setData({ | ||||||||||||||||||||||||||||||||||||||||||||||
name: "", | ||||||||||||||||||||||||||||||||||||||||||||||
link: "", | ||||||||||||||||||||||||||||||||||||||||||||||
textContent: "", | ||||||||||||||||||||||||||||||||||||||||||||||
contentType: "LINK", | ||||||||||||||||||||||||||||||||||||||||||||||
requireName: true | ||||||||||||||||||||||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||
}; | ||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
|
@@ -281,56 +317,102 @@ export default function AgreementSheet({ | |||||||||||||||||||||||||||||||||||||||||||||
</div> | ||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
<div className="space-y-4"> | ||||||||||||||||||||||||||||||||||||||||||||||
{/* Content Type Selection */} | ||||||||||||||||||||||||||||||||||||||||||||||
<div className="w-full space-y-2"> | ||||||||||||||||||||||||||||||||||||||||||||||
<Label htmlFor="link">Link to an agreement</Label> | ||||||||||||||||||||||||||||||||||||||||||||||
<Input | ||||||||||||||||||||||||||||||||||||||||||||||
className={`flex w-full rounded-md border-0 bg-background py-1.5 text-foreground shadow-sm ring-1 ring-inset placeholder:text-muted-foreground focus:ring-2 focus:ring-inset sm:text-sm sm:leading-6 ${ | ||||||||||||||||||||||||||||||||||||||||||||||
!isUrlValid | ||||||||||||||||||||||||||||||||||||||||||||||
? "ring-red-500 focus:ring-red-500" | ||||||||||||||||||||||||||||||||||||||||||||||
: "ring-input focus:ring-gray-400" | ||||||||||||||||||||||||||||||||||||||||||||||
}`} | ||||||||||||||||||||||||||||||||||||||||||||||
id="link" | ||||||||||||||||||||||||||||||||||||||||||||||
type="text" // Changed from "url" to avoid browser validation conflicts | ||||||||||||||||||||||||||||||||||||||||||||||
name="link" | ||||||||||||||||||||||||||||||||||||||||||||||
required | ||||||||||||||||||||||||||||||||||||||||||||||
autoComplete="off" | ||||||||||||||||||||||||||||||||||||||||||||||
data-1p-ignore | ||||||||||||||||||||||||||||||||||||||||||||||
placeholder="https://www.papermark.com/nda" | ||||||||||||||||||||||||||||||||||||||||||||||
value={data.link || ""} | ||||||||||||||||||||||||||||||||||||||||||||||
onChange={(e) => { | ||||||||||||||||||||||||||||||||||||||||||||||
const newValue = e.target.value; | ||||||||||||||||||||||||||||||||||||||||||||||
setData({ | ||||||||||||||||||||||||||||||||||||||||||||||
...data, | ||||||||||||||||||||||||||||||||||||||||||||||
link: newValue, | ||||||||||||||||||||||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||||||||||||||||||||||
// Validate on change with debouncing | ||||||||||||||||||||||||||||||||||||||||||||||
validateUrl(newValue); | ||||||||||||||||||||||||||||||||||||||||||||||
}} | ||||||||||||||||||||||||||||||||||||||||||||||
onBlur={(e) => { | ||||||||||||||||||||||||||||||||||||||||||||||
// Validate on blur for immediate feedback | ||||||||||||||||||||||||||||||||||||||||||||||
validateUrl(e.target.value); | ||||||||||||||||||||||||||||||||||||||||||||||
}} | ||||||||||||||||||||||||||||||||||||||||||||||
<Label>Agreement Content Type</Label> | ||||||||||||||||||||||||||||||||||||||||||||||
<RadioGroup | ||||||||||||||||||||||||||||||||||||||||||||||
value={data.contentType} | ||||||||||||||||||||||||||||||||||||||||||||||
onValueChange={(value) => setData({...data, contentType: value})} | ||||||||||||||||||||||||||||||||||||||||||||||
disabled={isOnlyView} | ||||||||||||||||||||||||||||||||||||||||||||||
/> | ||||||||||||||||||||||||||||||||||||||||||||||
{/* Display validation error */} | ||||||||||||||||||||||||||||||||||||||||||||||
{urlError && ( | ||||||||||||||||||||||||||||||||||||||||||||||
<p className="mt-1 text-sm text-red-500">{urlError}</p> | ||||||||||||||||||||||||||||||||||||||||||||||
)} | ||||||||||||||||||||||||||||||||||||||||||||||
className="flex flex-col space-y-2" | ||||||||||||||||||||||||||||||||||||||||||||||
> | ||||||||||||||||||||||||||||||||||||||||||||||
<div className="flex items-center space-x-2"> | ||||||||||||||||||||||||||||||||||||||||||||||
<RadioGroupItem value="LINK" id="link-type" /> | ||||||||||||||||||||||||||||||||||||||||||||||
<Label htmlFor="link-type">Link to agreement document</Label> | ||||||||||||||||||||||||||||||||||||||||||||||
</div> | ||||||||||||||||||||||||||||||||||||||||||||||
<div className="flex items-center space-x-2"> | ||||||||||||||||||||||||||||||||||||||||||||||
<RadioGroupItem value="TEXT" id="text-type" /> | ||||||||||||||||||||||||||||||||||||||||||||||
<Label htmlFor="text-type">Text content</Label> | ||||||||||||||||||||||||||||||||||||||||||||||
</div> | ||||||||||||||||||||||||||||||||||||||||||||||
</RadioGroup> | ||||||||||||||||||||||||||||||||||||||||||||||
</div> | ||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
{!isOnlyView ? ( | ||||||||||||||||||||||||||||||||||||||||||||||
<div className="space-y-12"> | ||||||||||||||||||||||||||||||||||||||||||||||
<div className="space-y-2 pb-6"> | ||||||||||||||||||||||||||||||||||||||||||||||
<Label>Or upload an agreement</Label> | ||||||||||||||||||||||||||||||||||||||||||||||
<div className="grid grid-cols-1 gap-x-6 gap-y-8 sm:grid-cols-6"> | ||||||||||||||||||||||||||||||||||||||||||||||
<DocumentUpload | ||||||||||||||||||||||||||||||||||||||||||||||
currentFile={currentFile} | ||||||||||||||||||||||||||||||||||||||||||||||
setCurrentFile={setCurrentFile} | ||||||||||||||||||||||||||||||||||||||||||||||
/> | ||||||||||||||||||||||||||||||||||||||||||||||
{/* Link Content */} | ||||||||||||||||||||||||||||||||||||||||||||||
{data.contentType === "LINK" && ( | ||||||||||||||||||||||||||||||||||||||||||||||
<div className="w-full space-y-2"> | ||||||||||||||||||||||||||||||||||||||||||||||
<Label htmlFor="link">Link to an agreement</Label> | ||||||||||||||||||||||||||||||||||||||||||||||
<Input | ||||||||||||||||||||||||||||||||||||||||||||||
className={`flex w-full rounded-md border-0 bg-background py-1.5 text-foreground shadow-sm ring-1 ring-inset placeholder:text-muted-foreground focus:ring-2 focus:ring-inset sm:text-sm sm:leading-6 ${ | ||||||||||||||||||||||||||||||||||||||||||||||
!isUrlValid | ||||||||||||||||||||||||||||||||||||||||||||||
? "ring-red-500 focus:ring-red-500" | ||||||||||||||||||||||||||||||||||||||||||||||
: "ring-input focus:ring-gray-400" | ||||||||||||||||||||||||||||||||||||||||||||||
}`} | ||||||||||||||||||||||||||||||||||||||||||||||
id="link" | ||||||||||||||||||||||||||||||||||||||||||||||
type="text" | ||||||||||||||||||||||||||||||||||||||||||||||
name="link" | ||||||||||||||||||||||||||||||||||||||||||||||
required={data.contentType === "LINK"} | ||||||||||||||||||||||||||||||||||||||||||||||
autoComplete="off" | ||||||||||||||||||||||||||||||||||||||||||||||
data-1p-ignore | ||||||||||||||||||||||||||||||||||||||||||||||
placeholder="https://www.papermark.com/nda" | ||||||||||||||||||||||||||||||||||||||||||||||
value={data.link || ""} | ||||||||||||||||||||||||||||||||||||||||||||||
onChange={(e) => { | ||||||||||||||||||||||||||||||||||||||||||||||
const newValue = e.target.value; | ||||||||||||||||||||||||||||||||||||||||||||||
setData({ | ||||||||||||||||||||||||||||||||||||||||||||||
...data, | ||||||||||||||||||||||||||||||||||||||||||||||
link: newValue, | ||||||||||||||||||||||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||||||||||||||||||||||
validateUrl(newValue); | ||||||||||||||||||||||||||||||||||||||||||||||
}} | ||||||||||||||||||||||||||||||||||||||||||||||
onBlur={(e) => { | ||||||||||||||||||||||||||||||||||||||||||||||
validateUrl(e.target.value); | ||||||||||||||||||||||||||||||||||||||||||||||
}} | ||||||||||||||||||||||||||||||||||||||||||||||
disabled={isOnlyView} | ||||||||||||||||||||||||||||||||||||||||||||||
/> | ||||||||||||||||||||||||||||||||||||||||||||||
{urlError && ( | ||||||||||||||||||||||||||||||||||||||||||||||
<p className="mt-1 text-sm text-red-500">{urlError}</p> | ||||||||||||||||||||||||||||||||||||||||||||||
)} | ||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
{!isOnlyView && ( | ||||||||||||||||||||||||||||||||||||||||||||||
<div className="space-y-12"> | ||||||||||||||||||||||||||||||||||||||||||||||
<div className="space-y-2 pb-6"> | ||||||||||||||||||||||||||||||||||||||||||||||
<Label>Or upload an agreement</Label> | ||||||||||||||||||||||||||||||||||||||||||||||
<div className="grid grid-cols-1 gap-x-6 gap-y-8 sm:grid-cols-6"> | ||||||||||||||||||||||||||||||||||||||||||||||
<DocumentUpload | ||||||||||||||||||||||||||||||||||||||||||||||
currentFile={currentFile} | ||||||||||||||||||||||||||||||||||||||||||||||
setCurrentFile={setCurrentFile} | ||||||||||||||||||||||||||||||||||||||||||||||
/> | ||||||||||||||||||||||||||||||||||||||||||||||
</div> | ||||||||||||||||||||||||||||||||||||||||||||||
</div> | ||||||||||||||||||||||||||||||||||||||||||||||
</div> | ||||||||||||||||||||||||||||||||||||||||||||||
</div> | ||||||||||||||||||||||||||||||||||||||||||||||
)} | ||||||||||||||||||||||||||||||||||||||||||||||
</div> | ||||||||||||||||||||||||||||||||||||||||||||||
) : null} | ||||||||||||||||||||||||||||||||||||||||||||||
)} | ||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
{/* Text Content */} | ||||||||||||||||||||||||||||||||||||||||||||||
{data.contentType === "TEXT" && ( | ||||||||||||||||||||||||||||||||||||||||||||||
<div className="w-full space-y-2"> | ||||||||||||||||||||||||||||||||||||||||||||||
<Label htmlFor="textContent">Agreement Text</Label> | ||||||||||||||||||||||||||||||||||||||||||||||
<Textarea | ||||||||||||||||||||||||||||||||||||||||||||||
className="flex w-full rounded-md border-0 bg-background py-1.5 text-foreground shadow-sm ring-1 ring-inset ring-input placeholder:text-muted-foreground focus:ring-2 focus:ring-inset focus:ring-gray-400 sm:text-sm sm:leading-6" | ||||||||||||||||||||||||||||||||||||||||||||||
id="textContent" | ||||||||||||||||||||||||||||||||||||||||||||||
name="textContent" | ||||||||||||||||||||||||||||||||||||||||||||||
required={data.contentType === "TEXT"} | ||||||||||||||||||||||||||||||||||||||||||||||
placeholder="By accessing this document, you agree to maintain confidentiality of all information contained herein and not to share, copy, or distribute any content without prior written consent..." | ||||||||||||||||||||||||||||||||||||||||||||||
value={data.textContent || ""} | ||||||||||||||||||||||||||||||||||||||||||||||
onChange={(e) => | ||||||||||||||||||||||||||||||||||||||||||||||
setData({ | ||||||||||||||||||||||||||||||||||||||||||||||
...data, | ||||||||||||||||||||||||||||||||||||||||||||||
textContent: e.target.value, | ||||||||||||||||||||||||||||||||||||||||||||||
}) | ||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||
disabled={isOnlyView} | ||||||||||||||||||||||||||||||||||||||||||||||
rows={6} | ||||||||||||||||||||||||||||||||||||||||||||||
/> | ||||||||||||||||||||||||||||||||||||||||||||||
<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> | ||||||||||||||||||||||||||||||||||||||||||||||
)} | ||||||||||||||||||||||||||||||||||||||||||||||
</div> | ||||||||||||||||||||||||||||||||||||||||||||||
</div> | ||||||||||||||||||||||||||||||||||||||||||||||
<SheetFooter | ||||||||||||||||||||||||||||||||||||||||||||||
|
@@ -345,7 +427,10 @@ export default function AgreementSheet({ | |||||||||||||||||||||||||||||||||||||||||||||
<Button | ||||||||||||||||||||||||||||||||||||||||||||||
type="submit" | ||||||||||||||||||||||||||||||||||||||||||||||
loading={isLoading} | ||||||||||||||||||||||||||||||||||||||||||||||
disabled={!isUrlValid && data.link.trim() !== ""} | ||||||||||||||||||||||||||||||||||||||||||||||
disabled={ | ||||||||||||||||||||||||||||||||||||||||||||||
(data.contentType === "LINK" && !isUrlValid && data.link.trim() !== "") || | ||||||||||||||||||||||||||||||||||||||||||||||
(data.contentType === "TEXT" && !data.textContent.trim()) | ||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||
> | ||||||||||||||||||||||||||||||||||||||||||||||
Create Agreement | ||||||||||||||||||||||||||||||||||||||||||||||
</Button> | ||||||||||||||||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Strongly type contentType ('LINK' | 'TEXT') to prevent typos.
Use a literal union instead of string for safety across the app.
📝 Committable suggestion
🤖 Prompt for AI Agents