Capture ROI calculator submissions as enquiries for admin review
CI / build (push) Canceled after 0s
CI / build (push) Canceled after 0s
Visitors can now send their ROI results with name/email/company, which records the full inputs and savings breakdown through the existing leads API so admins can review them in the Enquiries tab. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -64,7 +64,9 @@ export default function LeadsPanel() {
|
|||||||
{lead.phone ? ` · ${lead.phone}` : ''}
|
{lead.phone ? ` · ${lead.phone}` : ''}
|
||||||
</span>
|
</span>
|
||||||
{lead.message ? (
|
{lead.message ? (
|
||||||
<span style={{ display: 'block', marginTop: 6, fontSize: 12, color: 'var(--cms-mut)', lineHeight: 1.6 }}>
|
<span
|
||||||
|
style={{ display: 'block', marginTop: 6, fontSize: 12, color: 'var(--cms-mut)', lineHeight: 1.6, whiteSpace: 'pre-line' }}
|
||||||
|
>
|
||||||
{lead.message}
|
{lead.message}
|
||||||
</span>
|
</span>
|
||||||
) : null}
|
) : null}
|
||||||
|
|||||||
@@ -9,8 +9,10 @@ import {
|
|||||||
INPUTS_KEY,
|
INPUTS_KEY,
|
||||||
loadInputs,
|
loadInputs,
|
||||||
REGIONS,
|
REGIONS,
|
||||||
|
regionLabel,
|
||||||
} from './calc.js'
|
} from './calc.js'
|
||||||
import RoiSlide from './RoiSlide'
|
import RoiSlide from './RoiSlide'
|
||||||
|
import { submitLead } from '../../cms/api'
|
||||||
|
|
||||||
const Icon = {
|
const Icon = {
|
||||||
globe: (
|
globe: (
|
||||||
@@ -79,10 +81,35 @@ function CardHeader({
|
|||||||
|
|
||||||
const rangePct = (val: number, min: number, max: number) => `${(((val - min) / (max - min)) * 100).toFixed(1)}%`
|
const rangePct = (val: number, min: number, max: number) => `${(((val - min) / (max - min)) * 100).toFixed(1)}%`
|
||||||
|
|
||||||
|
/** Plain-text summary of a visitor's inputs and results, stored as the enquiry's message. */
|
||||||
|
function buildRoiSummary(i: Record<string, any>, r: ReturnType<typeof calculate>) {
|
||||||
|
return [
|
||||||
|
`Active subscribers: ${i.subs ? Number(i.subs).toLocaleString('en-US') : '—'}`,
|
||||||
|
`Region: ${i.region === 'custom' ? `Custom ($${i.customPrice || 0}/GB)` : regionLabel(i.region)}`,
|
||||||
|
`Bandwidth scenario: ${i.scenario}`,
|
||||||
|
`Support calls per 1,000 subs/month: ${i.callsPer1000}`,
|
||||||
|
`Average cost per call: $${i.callCost}`,
|
||||||
|
`Security-related calls: ${i.securityPct}%`,
|
||||||
|
`Monthly ARPU: ${i.arpu ? `$${i.arpu}` : '—'}`,
|
||||||
|
`Annual churn rate: ${i.churn ? `${i.churn}%` : '—'}`,
|
||||||
|
`Annual network infrastructure OpEx: ${i.netOpex ? `$${Number(i.netOpex).toLocaleString('en-US')}` : '—'}`,
|
||||||
|
`DDoS incidents per year: ${i.ddos || 0}`,
|
||||||
|
'',
|
||||||
|
`Total estimated annual savings: ${fmtRange(r.total.lo, r.total.hi) || '—'}`,
|
||||||
|
` Bandwidth savings: ${fmtRange(r.bw.lo, r.bw.hi) || '—'}`,
|
||||||
|
` Support call reduction: ${fmtRange(r.calls.lo, r.calls.hi) || '—'}`,
|
||||||
|
` Churn reduction: ${fmtRange(r.churn.lo, r.churn.hi) || '—'}`,
|
||||||
|
` Network equipment: ${fmtRange(r.equip.lo, r.equip.hi) || '—'}`,
|
||||||
|
` DDoS avoided costs: ${fmtRange(r.ddos.lo, r.ddos.hi) || '—'}`,
|
||||||
|
].join('\n')
|
||||||
|
}
|
||||||
|
|
||||||
export default function RoiCalculator() {
|
export default function RoiCalculator() {
|
||||||
const [i, setI] = useState(loadInputs)
|
const [i, setI] = useState(loadInputs)
|
||||||
const [showAssump, setShowAssump] = useState(false)
|
const [showAssump, setShowAssump] = useState(false)
|
||||||
const [showSlide, setShowSlide] = useState(false)
|
const [showSlide, setShowSlide] = useState(false)
|
||||||
|
const [lead, setLead] = useState({ name: '', email: '', company: '' })
|
||||||
|
const [leadState, setLeadState] = useState<'idle' | 'sending' | 'sent' | 'error'>('idle')
|
||||||
|
|
||||||
const update = (patch: Record<string, unknown>) => {
|
const update = (patch: Record<string, unknown>) => {
|
||||||
setI((s: typeof i) => ({ ...s, ...patch }))
|
setI((s: typeof i) => ({ ...s, ...patch }))
|
||||||
@@ -92,6 +119,25 @@ export default function RoiCalculator() {
|
|||||||
|
|
||||||
const r = useMemo(() => calculate(i), [i])
|
const r = useMemo(() => calculate(i), [i])
|
||||||
|
|
||||||
|
const submitRoiLead = async (e: React.FormEvent) => {
|
||||||
|
e.preventDefault()
|
||||||
|
if (!lead.email.trim() || leadState === 'sending') return
|
||||||
|
setLeadState('sending')
|
||||||
|
try {
|
||||||
|
await submitLead({
|
||||||
|
form: 'roi-calculator',
|
||||||
|
name: lead.name.trim(),
|
||||||
|
email: lead.email.trim(),
|
||||||
|
company: lead.company.trim(),
|
||||||
|
page: '/roi-calculator',
|
||||||
|
message: buildRoiSummary(i, r),
|
||||||
|
})
|
||||||
|
setLeadState('sent')
|
||||||
|
} catch {
|
||||||
|
setLeadState('error')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Remember inputs for this visitor (survives refresh)
|
// Remember inputs for this visitor (survives refresh)
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
try {
|
try {
|
||||||
@@ -417,6 +463,43 @@ export default function RoiCalculator() {
|
|||||||
depend on network architecture, traffic mix, subscriber behaviour, and existing security controls.
|
depend on network architecture, traffic mix, subscriber behaviour, and existing security controls.
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{r.complete && (
|
||||||
|
<div className="lp-report-bar" style={{ marginTop: 24 }}>
|
||||||
|
<div className="lp-report-bar-text">
|
||||||
|
<h4>Send these results to your team</h4>
|
||||||
|
{leadState === 'sent' ? (
|
||||||
|
<p>Thanks — your results have been recorded. We'll follow up shortly.</p>
|
||||||
|
) : (
|
||||||
|
<form className="roi-lead-form" onSubmit={submitRoiLead}>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
placeholder="Name"
|
||||||
|
value={lead.name}
|
||||||
|
onChange={(e) => setLead((s) => ({ ...s, name: e.target.value }))}
|
||||||
|
/>
|
||||||
|
<input
|
||||||
|
type="email"
|
||||||
|
placeholder="Work email"
|
||||||
|
required
|
||||||
|
value={lead.email}
|
||||||
|
onChange={(e) => setLead((s) => ({ ...s, email: e.target.value }))}
|
||||||
|
/>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
placeholder="Company (optional)"
|
||||||
|
value={lead.company}
|
||||||
|
onChange={(e) => setLead((s) => ({ ...s, company: e.target.value }))}
|
||||||
|
/>
|
||||||
|
<button className="report-dl-btn" type="submit" disabled={leadState === 'sending'}>
|
||||||
|
{leadState === 'sending' ? 'Sending…' : 'Submit my results'}
|
||||||
|
</button>
|
||||||
|
</form>
|
||||||
|
)}
|
||||||
|
{leadState === 'error' && <p className="report-note" style={{ color: '#c0392b' }}>Something went wrong — please try again.</p>}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
<div className="lp-report-bar">
|
<div className="lp-report-bar">
|
||||||
<div className="lp-report-bar-text">
|
<div className="lp-report-bar-text">
|
||||||
<h4>Your personalised ROI slide</h4>
|
<h4>Your personalised ROI slide</h4>
|
||||||
|
|||||||
@@ -573,6 +573,33 @@
|
|||||||
color: #889;
|
color: #889;
|
||||||
margin-top: 8px;
|
margin-top: 8px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Lead capture form */
|
||||||
|
.roi-calc .roi-lead-form {
|
||||||
|
display: flex;
|
||||||
|
gap: 10px;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
margin-top: 12px;
|
||||||
|
}
|
||||||
|
.roi-calc .roi-lead-form input {
|
||||||
|
flex: 1 1 160px;
|
||||||
|
padding: 10px 13px;
|
||||||
|
border: 1.5px solid #c8dde3;
|
||||||
|
border-radius: 8px;
|
||||||
|
font-family: 'Ubuntu', sans-serif;
|
||||||
|
font-size: 13px;
|
||||||
|
color: var(--roi-text);
|
||||||
|
background: var(--roi-white);
|
||||||
|
outline: none;
|
||||||
|
transition: border-color 0.2s, box-shadow 0.2s;
|
||||||
|
}
|
||||||
|
.roi-calc .roi-lead-form input:focus {
|
||||||
|
border-color: var(--roi-green);
|
||||||
|
box-shadow: 0 0 0 3px rgba(53, 184, 136, 0.15);
|
||||||
|
}
|
||||||
|
.roi-calc .roi-lead-form .report-dl-btn {
|
||||||
|
flex: 0 0 auto;
|
||||||
|
}
|
||||||
@media (max-width: 960px) {
|
@media (max-width: 960px) {
|
||||||
.roi-calc .main {
|
.roi-calc .main {
|
||||||
grid-template-columns: 1fr;
|
grid-template-columns: 1fr;
|
||||||
|
|||||||
Reference in New Issue
Block a user