Replace USAC email instructions with confirmation button + add API endpoint

- Intake email now has "I've completed the delegation →" button
  instead of "reply to this email"
- Button links to order success page with action=usac_delegation
- New API: POST /api/v1/compliance-orders/:id/usac-delegation
  Records confirmation timestamp in intake_data and logs it
- Removed "reply to this email" from intake email

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
justin 2026-04-27 21:20:22 -05:00
parent 1a27fd7913
commit 86205c309c
2 changed files with 57 additions and 4 deletions

View file

@ -1752,6 +1752,9 @@ async function sendComplianceIntakeEmail(
((o.service_name as string) || "").toLowerCase().includes("499"), ((o.service_name as string) || "").toLowerCase().includes("499"),
); );
const SITE_DOMAIN = process.env.DOMAIN ? `https://${process.env.DOMAIN}` : "https://performancewest.net";
const confirmUrl = `${SITE_DOMAIN}/order/success?action=usac_delegation&order_id=${orderId}`;
const usacSection = has499 ? ` const usacSection = has499 ? `
<div style="background:#fef3c7;border:1px solid #fcd34d;border-radius:8px;padding:16px 20px;margin:20px 0;"> <div style="background:#fef3c7;border:1px solid #fcd34d;border-radius:8px;padding:16px 20px;margin:20px 0;">
<p style="margin:0 0 8px;font-size:14px;font-weight:700;color:#92400e;">Action Required: USAC E-File Delegation</p> <p style="margin:0 0 8px;font-size:14px;font-weight:700;color:#92400e;">Action Required: USAC E-File Delegation</p>
@ -1764,9 +1767,16 @@ async function sendComplianceIntakeEmail(
<li>Go to <strong>Account Settings Delegate Access</strong></li> <li>Go to <strong>Account Settings Delegate Access</strong></li>
<li>Add delegate email: <strong>filings@performancewest.net</strong></li> <li>Add delegate email: <strong>filings@performancewest.net</strong></li>
<li>Grant <strong>read and file</strong> permissions</li> <li>Grant <strong>read and file</strong> permissions</li>
<li>Reply to this email to confirm delegation is complete</li>
</ol> </ol>
<p style="margin:0;font-size:12px;color:#92400e;"> <p style="margin:12px 0;text-align:center;">
<a href="${confirmUrl}" style="display:inline-block;background:#1a2744;color:#ffffff;font-weight:700;padding:12px 28px;border-radius:8px;text-decoration:none;font-size:14px;">
I've completed the delegation &rarr;
</a>
</p>
<p style="margin:8px 0 0;font-size:12px;color:#92400e;text-align:center;">
Clicking this button notifies our team that delegation is complete so we can begin your filing.
</p>
<p style="margin:8px 0 0;font-size:12px;color:#92400e;">
If you have multiple years of missed filings, each year must be filed separately. If you have multiple years of missed filings, each year must be filed separately.
We will review your history and contact you with pricing for any additional years. We will review your history and contact you with pricing for any additional years.
</p> </p>
@ -1812,10 +1822,10 @@ async function sendComplianceIntakeEmail(
<p style="margin:0 0 4px;font-size:14px;color:#374151;"><span style="color:#1e3a5f;font-weight:600;">1.</span> We will review your compliance status within 1 business day.</p> <p style="margin:0 0 4px;font-size:14px;color:#374151;"><span style="color:#1e3a5f;font-weight:600;">1.</span> We will review your compliance status within 1 business day.</p>
<p style="margin:0 0 4px;font-size:14px;color:#374151;"><span style="color:#1e3a5f;font-weight:600;">2.</span> If we need any additional information, we will email you.</p> <p style="margin:0 0 4px;font-size:14px;color:#374151;"><span style="color:#1e3a5f;font-weight:600;">2.</span> If we need any additional information, we will email you.</p>
<p style="margin:0 0 4px;font-size:14px;color:#374151;"><span style="color:#1e3a5f;font-weight:600;">3.</span> You will receive a confirmation for each filing as it is completed.</p> <p style="margin:0 0 4px;font-size:14px;color:#374151;"><span style="color:#1e3a5f;font-weight:600;">3.</span> You will receive a confirmation for each filing as it is completed.</p>
${has499 ? `<p style="margin:0 0 4px;font-size:14px;color:#374151;"><span style="color:#1e3a5f;font-weight:600;">4.</span> For 499-A filings, please complete the USAC delegation above so we can begin.</p>` : ""} ${has499 ? `<p style="margin:0 0 4px;font-size:14px;color:#374151;"><span style="color:#1e3a5f;font-weight:600;">4.</span> For 499-A filings, complete the USAC delegation above and click the confirmation button.</p>` : ""}
<p style="margin:20px 0 0;font-size:13px;color:#9ca3af;"> <p style="margin:20px 0 0;font-size:13px;color:#9ca3af;">
Questions? Reply to this email or contact us at Questions? Contact us at
<a href="mailto:info@performancewest.net" style="color:#1e40af;">info@performancewest.net</a> <a href="mailto:info@performancewest.net" style="color:#1e40af;">info@performancewest.net</a>
or <a href="tel:+18884110383" style="color:#1e40af;">1-888-411-0383</a>. or <a href="tel:+18884110383" style="color:#1e40af;">1-888-411-0383</a>.
</p> </p>

View file

@ -1453,5 +1453,48 @@ router.post(
}, },
); );
/**
* POST /api/v1/compliance-orders/:id/usac-delegation
* Customer confirms they've completed USAC E-File delegation.
* Updates order status and notifies the team to begin filing.
*/
router.post("/api/v1/compliance-orders/:id/usac-delegation", async (req, res) => {
const id = req.params.id;
try {
// Support both batch ID (CB-) and order number (CO-)
const whereCol = id.startsWith("CB-") ? "batch_id" : "order_number";
const result = await pool.query(
`UPDATE compliance_orders
SET intake_data = jsonb_set(
COALESCE(intake_data, '{}'::jsonb),
'{usac_delegation_confirmed}',
to_jsonb(now()::text)
),
updated_at = NOW()
WHERE ${whereCol} = $1
AND service_slug IN ('fcc-499a', 'fcc-499a-499q')
RETURNING order_number, service_slug, customer_email`,
[id],
);
if (result.rows.length === 0) {
res.status(404).json({ error: "No 499-A order found for this ID." });
return;
}
console.log(`[compliance-orders] USAC delegation confirmed for ${id} (${result.rows.length} orders)`);
res.json({
success: true,
message: "Thank you! We've been notified that delegation is complete and will begin your filing within 1 business day.",
orders_updated: result.rows.length,
});
} catch (err) {
console.error("[compliance-orders] USAC delegation error:", err);
res.status(500).json({ error: "Could not record delegation confirmation." });
}
});
export { COMPLIANCE_SERVICES, REQUIRED_FIELDS }; export { COMPLIANCE_SERVICES, REQUIRED_FIELDS };
export default router; export default router;