fix: remove redundant recipients field — signers system handles all email dispatch
This commit is contained in:
@@ -33,10 +33,6 @@ interface PreparePanelProps {
|
||||
onUnassignedFieldIdsChange?: (ids: Set<string>) => void;
|
||||
}
|
||||
|
||||
function parseEmails(raw: string | undefined): string[] {
|
||||
return (raw ?? '').split(/[\n,]+/).map((e) => e.trim()).filter(Boolean);
|
||||
}
|
||||
|
||||
function isValidEmail(email: string): boolean {
|
||||
return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email);
|
||||
}
|
||||
@@ -52,11 +48,6 @@ export function PreparePanel({
|
||||
onUnassignedFieldIdsChange,
|
||||
}: PreparePanelProps) {
|
||||
const router = useRouter();
|
||||
const [recipients, setRecipients] = useState(defaultEmail ?? '');
|
||||
// Sync if defaultEmail arrives after initial render (streaming / hydration timing)
|
||||
useEffect(() => {
|
||||
if (defaultEmail) setRecipients(defaultEmail);
|
||||
}, [defaultEmail]);
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [aiLoading, setAiLoading] = useState(false);
|
||||
const [result, setResult] = useState<{ ok: boolean; message: string } | null>(null);
|
||||
@@ -190,21 +181,6 @@ export function PreparePanel({
|
||||
setLoading(true);
|
||||
setResult(null);
|
||||
|
||||
const emailAddresses = parseEmails(recipients);
|
||||
|
||||
if (emailAddresses.length === 0) {
|
||||
setResult({ ok: false, message: 'Enter at least one recipient email.' });
|
||||
setLoading(false);
|
||||
return;
|
||||
}
|
||||
|
||||
const invalid = emailAddresses.filter((e) => !isValidEmail(e));
|
||||
if (invalid.length > 0) {
|
||||
setResult({ ok: false, message: `Invalid email(s): ${invalid.join(', ')}` });
|
||||
setLoading(false);
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
// Send-block validation: fetch current fields and check for unassigned client-visible fields
|
||||
const fieldsRes = await fetch(`/api/documents/${docId}/fields`);
|
||||
@@ -231,7 +207,7 @@ export function PreparePanel({
|
||||
const prepareRes = await fetch(`/api/documents/${docId}/prepare`, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ textFillData, emailAddresses, signers }),
|
||||
body: JSON.stringify({ textFillData, signers }),
|
||||
});
|
||||
if (!prepareRes.ok) {
|
||||
const err = await prepareRes.json().catch(() => ({ error: 'Unknown error' }));
|
||||
@@ -257,21 +233,6 @@ export function PreparePanel({
|
||||
<div className="rounded-lg border border-gray-200 bg-gray-100 p-4 space-y-4">
|
||||
<h2 className="font-semibold text-gray-900">Prepare Document</h2>
|
||||
|
||||
<div>
|
||||
<label className="block text-sm font-medium text-gray-700 mb-1">
|
||||
Recipients
|
||||
</label>
|
||||
<textarea
|
||||
value={recipients}
|
||||
onChange={(e) => setRecipients(e.target.value)}
|
||||
rows={2}
|
||||
className="w-full border rounded px-2 py-1.5 text-sm resize-none"
|
||||
placeholder="email@example.com"
|
||||
/>
|
||||
<p className="text-xs text-gray-400 mt-0.5">
|
||||
To add more recipients, separate each email with a comma
|
||||
</p>
|
||||
</div>
|
||||
|
||||
{/* Quick-fill panel — only shown when a text field is selected */}
|
||||
<div>
|
||||
@@ -386,7 +347,7 @@ export function PreparePanel({
|
||||
|
||||
<button
|
||||
onClick={handlePrepare}
|
||||
disabled={loading || previewToken === null || parseEmails(recipients).length === 0}
|
||||
disabled={loading || previewToken === null}
|
||||
className="w-full py-2 px-4 bg-blue-600 text-white rounded hover:bg-blue-700 disabled:opacity-50 disabled:cursor-not-allowed text-sm font-medium"
|
||||
type="button"
|
||||
>
|
||||
|
||||
Reference in New Issue
Block a user