Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions apps/api/app/services/notifications/customer_requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def acknowledgement_text(*, name, reference, postcode, service, area, total, bre
"ready_to_book": "We've received your booking request. Our team will contact you to agree the final details and arrange a suitable date.",
"callback_requested": "We've received your request for a call. Our team will contact you to discuss your estimate and next steps.",
"flexible_booking": "We've received your flexible booking request. We'll contact you to discuss dates when we're working in your area and agree any additional saving.",
"repair_review_requested": "We've received your repair quotation request. We'll discuss the damage with you and may request photographs before confirming a fixed quotation.",
"repair_review_requested": "We've received your repair review request. Your quotation already includes a repair allowance. We'll review photographs and confirm whether any additional repair costs are necessary.",
"estimate_requested": "Thank you for requesting your SurfaceCoat estimate. Here is a copy for your records.",
}[intention]
photo_guidance = []
Expand All @@ -27,10 +27,10 @@ def acknowledgement_text(*, name, reference, postcode, service, area, total, bre
f"Area discount: {discount['percent']}% (saving £{Decimal(str(discount.get('saving_gbp', 0))):,.2f})",
f"Discounted restoration: £{Decimal(str(discount['final_gbp'])):,.2f}"]
if Decimal(str(repair.get("provisional_gbp", 0))) > 0:
lines += [f"Provisional repair allowance: £{Decimal(str(repair['provisional_gbp'])):,.2f}"]
lines += [f"Total estimated price: £{Decimal(str(total)):,.2f}", "",
lines += [f"Included repair allowance (subject to review): £{Decimal(str(repair['provisional_gbp'])):,.2f}"]
lines += [f"Total quotation: £{Decimal(str(total)):,.2f}", "",
"This email acknowledges your request. It is not a confirmed appointment or a fixed repair quotation.",
"Any repairs, changes to the work and final price will be agreed with you before booking. Coating dates depend on suitable weather and surface conditions.",
"Any additional repair costs will be discussed and agreed with you before booking. Coating dates depend on suitable weather and surface conditions.",
"", "You can reply to this email with any questions.", "", "SurfaceCoat Ltd", "Restore. Protect. Transform."]
lines[-3:-3] = photo_guidance
return "\n".join(lines)
Expand Down
4 changes: 2 additions & 2 deletions apps/api/app/services/quote_conversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def customer_next_steps(
) -> str:
del windows, photos_attached, repair_review
if enquiry.intention == REPAIR_REVIEW_REQUESTED:
return "Thank you for your enquiry. If you are happy with your estimated price, our team will contact you to discuss any repairs and may request photographs. We will confirm your final quotation before arranging a booking."
return "Thank you for your enquiry. Your quotation includes a repair allowance. We will review photographs and confirm whether any additional repair costs are necessary."
if enquiry.intention == FLEXIBLE_BOOKING:
return "We have received your flexible booking request. Our team will contact you to agree your discounted price and dates when we are working in your area."
if enquiry.intention == READY_TO_BOOK:
Expand All @@ -124,7 +124,7 @@ def confirmation_steps(enquiry: Enquiry) -> list[str]:
return [
"We review your enquiry and contact you personally.",
"We may request photographs to assess any damage.",
"We agree your final repair price before arranging a booking.",
"We confirm whether any additional repair costs are necessary.",
]
if enquiry.intention == FLEXIBLE_BOOKING:
return ["We check dates when we are working in your area.", "We contact you to agree your discounted price and dates.", "Nothing is booked until we confirm it with you."]
Expand Down
6 changes: 3 additions & 3 deletions apps/web/e2e/public-quote-real.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ test("undamaged tarmac retains the existing booking request journey without phot
const heading = page.getByRole("heading", { name: "Thank you for choosing SurfaceCoat" });
await expect(heading.or(problem)).toBeVisible({ timeout: 30_000 });
if (await problem.isVisible()) throw new Error(await problem.innerText());
await expect(page.getByText(/This is a booking request/)).toBeVisible();
await expect(page.getByText(/No appointment is confirmed/)).toBeVisible();
await expect(page.getByRole("link", { name: "Add photographs later" })).toHaveCount(0);
});

Expand All @@ -59,7 +59,7 @@ test("minor tarmac damage receives separate provisional repair estimate and huma
const heading = page.getByRole("heading", { name: "Thank you for choosing SurfaceCoat" });
await expect(heading.or(problem)).toBeVisible({ timeout: 30_000 });
if (await problem.isVisible()) throw new Error(await problem.innerText());
await expect(page.getByText(/We may request photographs to assess any damage/i)).toBeVisible();
await expect(page.getByText(/agree your final repair price/i)).toBeVisible();
await expect(page.getByText(/We review your photographs/i)).toBeVisible();
await expect(page.getByText(/confirm whether any additional repair costs are necessary/i)).toBeVisible();
await expect(page.getByRole("link", { name: "Add photographs later" })).toHaveCount(0);
});
103 changes: 39 additions & 64 deletions apps/web/src/components/quote/quote-wizard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -367,11 +367,12 @@ export function QuoteWizard() {
await calculateProvisional();
}

useEffect(() => { if (saved) window.scrollTo({ top: 0, behavior: "instant" }); }, [saved]);
if (measuringVisit) return <MeasuringVisitForm state={state} onBack={() => setMeasuringVisit(false)} />;
return (
<div className="quote-journey bg-brand-paper pb-16">
<div className="site-container py-8 md:py-14">
<p className="section-eyebrow">Instant estimate</p>
{!saved && <><p className="section-eyebrow">Instant quotation</p>
<h1 className="mt-2 font-display text-3xl font-medium text-brand-ink md:text-4xl">Your instant estimate</h1>
<p className="mt-3 max-w-xl text-sm leading-relaxed text-brand-ink/70">
Get an instant provisional price. If repairs are needed, we'll confirm the final price with you before booking.
Expand Down Expand Up @@ -401,7 +402,8 @@ export function QuoteWizard() {
</ol>
</div>

<div className="mt-6 border border-brand-line bg-white p-5 md:p-10">
</>}
<div className="mt-6 border border-brand-line bg-white p-4 md:p-10">
{step === 0 && (
<StepLocation
state={state}
Expand Down Expand Up @@ -744,7 +746,7 @@ function QuoteResultCard({
</dl>}
<div className="rounded-md bg-brand-paper p-3 text-sm">
<p className="font-semibold">{repairs ? "Let's confirm your repairs" : "Ready to transform your driveway?"}</p>
<p className="mt-1">{repairs ? "Your quotation includes a repair allowance. Send us your details and photographs so we can confirm your final price." : "Send us your details and we'll be in touch to arrange your restoration."}</p>
<p className="mt-1">{repairs ? "Your quotation includes a repair allowance. Send us your details and photographs so we can confirm whether any additional repair costs are necessary." : "Send us your details and we'll be in touch to arrange your restoration."}</p>
{result.requires_review && !repairs && <p className="mt-1">Our team will review your quotation before confirming your booking.</p>}
</div>
<button type="button" onClick={() => onChoose(repairs ? "repair_review_requested" : "ready_to_book")} className="w-full rounded-md bg-brand-gold px-4 py-4 font-semibold">{repairs ? "Confirm my repair costs" : "Happy with my price"}</button>
Expand Down Expand Up @@ -804,57 +806,30 @@ function StepContact({
(state.intention !== "callback_requested" || state.callback_preferred_time.trim().length >= 2);

if (saved) {
const steps =
saved.next_step_items && saved.next_step_items.length > 0
? saved.next_step_items
: [
"Our team reviews your enquiry and may request photographs of any damage.",
"We contact you to agree a visit.",
"Nothing is booked until we confirm it with you.",
];
const repairs = Number(saved.repair_allowance_gbp ?? 0) > 0;
const photoHandoff = ["ready_to_book", "repair_review_requested", "flexible_booking"].includes(state.intention);
return (
<div className="border border-brand-line bg-brand-paper p-5 sm:p-8">
<p className="text-xs font-semibold uppercase tracking-[0.18em] text-brand-ink/70">SurfaceCoat</p>
<h2 className="mt-3 font-display text-3xl font-medium leading-tight text-brand-ink">
{saved.confirmation_heading || "Thank you for choosing SurfaceCoat"}
</h2>
<p className="mt-4 text-base leading-relaxed text-brand-ink/80">{saved.next_steps}</p>
<dl className="mt-6 grid gap-3 border-y border-brand-line py-4 sm:grid-cols-2">
<div>
<dt className="text-xs font-semibold uppercase tracking-[0.14em] text-brand-ink/60">Estimated price</dt>
{Number(saved.discount_percent ?? 0) > 0 && (
<div className="mt-1 text-sm text-brand-ink/60 line-through">£{Number(saved.original_total_gbp).toFixed(2)}</div>
)}
<dd className="mt-1 font-display text-2xl text-brand-ink">£{Number(saved.total_gbp).toFixed(2)}</dd>
{Number(saved.discount_percent ?? 0) > 0 && (
<p className="mt-1 text-sm font-semibold text-restore-dark">{Number(saved.discount_percent)}% volume discount · You saved £{Number(saved.discount_saving_gbp).toFixed(2)}</p>
)}
</div>
<div>
<dt className="text-xs font-semibold uppercase tracking-[0.14em] text-brand-ink/60">Quotation reference</dt>
<dd className="mt-1 font-semibold text-brand-ink">{saved.reference}</dd>
</div>
</dl>
{["ready_to_book", "repair_review_requested", "flexible_booking"].includes(state.intention) && (
<MessagingHandoff reference={saved.reference} total={saved.total_gbp} />
)}
<h3 className="mt-6 text-sm font-semibold uppercase tracking-[0.14em] text-brand-ink">What happens next</h3>
<ol className="mt-3 space-y-2">
{steps.map((item, index) => (
<li key={item} className="flex gap-3 text-sm leading-relaxed text-brand-ink/80">
<span className="mt-0.5 inline-flex h-6 w-6 shrink-0 items-center justify-center bg-brand-gold text-xs font-semibold text-brand-ink">
{index + 1}
</span>
{item}
</li>
))}
</ol>
<p className="mt-6 text-sm text-brand-ink/75">
<p className="mt-3 text-sm">{saved.email_status === "sent" ? "We've emailed your request details to you." : saved.email_status === "queued" ? "An email with your estimate and next steps is queued for delivery. Your request is saved." : "Your request is saved. If an email does not arrive, our team can check it for you."}</p>
{state.intention === "repair_review_requested"
? "This is an estimated quotation request, not a confirmed booking. We'll agree your final price before arranging any visit."
: "This is a booking request. Your visit is not booked until we agree it with you."}
</p>
<div className="mx-auto max-w-md space-y-4 text-brand-ink">
<div className="text-center">
<span aria-hidden className="mx-auto flex h-10 w-10 items-center justify-center rounded-full border border-brand-gold text-2xl">✓</span>
<h2 className="mt-2 font-display text-2xl font-semibold">Thank you for choosing SurfaceCoat</h2>
<p className="mt-1 text-sm">Your request has been received.</p>
<p className="mt-3 font-display text-4xl">£{Number(saved.total_gbp).toFixed(2)}</p>
<p className="text-sm">{repairs ? "Quotation including repair allowance" : "Your restoration quotation"}{saved.vat_applied ? " including VAT" : ""}</p>
{Number(saved.discount_percent ?? 0) > 0 && <p className="text-sm font-semibold text-restore-dark">{Number(saved.discount_percent)}% volume discount · You saved £{Number(saved.discount_saving_gbp).toFixed(2)}</p>}
<p className="mt-2 text-xs">Reference: {saved.reference}</p>
</div>
{photoHandoff && <MessagingHandoff reference={saved.reference} total={saved.total_gbp} repairs={repairs} />}
<div className="text-sm">
<h3 className="font-semibold">What happens next?</h3>
{state.intention === "estimate_requested" ? <p className="mt-2">Keep your quotation for your records and contact us when you are ready.</p> : state.intention === "callback_requested" ? <p className="mt-2">Our team will contact you to discuss your quotation.</p> : <ol className="mt-2 list-decimal space-y-1 pl-5">
{repairs && <><li>We review your photographs.</li><li>We confirm whether any additional repair costs are necessary.</li></>}
{state.intention === "flexible_booking" && <li>We discuss available dates and any additional saving.</li>}
<li>We contact you to arrange your restoration.</li>
</ol>}
</div>
<p className="text-xs text-brand-ink/75">{saved.email_status === "sent" ? "Your quotation has been emailed to you." : saved.email_status === "queued" ? "Your quotation will also be sent by email." : "Our team can help if you need a copy of your quotation."}</p>
{state.intention !== "estimate_requested" && <p className="text-xs text-brand-ink/75">No appointment is confirmed until we agree a date with you.</p>}
</div>
);
}
Expand All @@ -879,7 +854,7 @@ function StepContact({
{[state.address_line1, state.town, state.postcode].filter(Boolean).join(", ") || state.postcode}
</p>
{state.intention === "repair_review_requested" && (
<p className="mt-4 rounded-md border border-brand-gold bg-brand-paper p-4 text-sm">Our team will review your enquiry, discuss any repairs and may ask for photographs to confirm your final price. No booking or fixed price is confirmed yet.</p>
<p className="mt-4 rounded-md border border-brand-gold bg-brand-paper p-4 text-sm">Your quotation includes a repair allowance. We will review photographs to confirm whether any additional repair costs are necessary.</p>
)}
<div className="mt-6 grid gap-4">
<label className="text-sm font-medium">
Expand Down Expand Up @@ -973,22 +948,22 @@ function StepContact({
);
}

function MessagingHandoff({ reference, total }: { reference: string; total: string | number }) {
function MessagingHandoff({ reference, total, repairs }: { reference: string; total: string | number; repairs: boolean }) {
const rawPhone = (process.env.NEXT_PUBLIC_BUSINESS_MOBILE ?? "").replace(/[\s()-]/g, "");
const phone = rawPhone.startsWith("07") ? "+44" + rawPhone.slice(1) : rawPhone;
const valid = /^\+447\d{9}$/.test(phone);
const message = "Hi SurfaceCoat, I'd like to discuss my estimated quotation. Reference: " + reference +
". Estimated price: £" + Number(total).toFixed(2) +
const message = "Hi SurfaceCoat, I'd like to discuss my quotation. Reference: " + reference +
". Quotation: £" + Number(total).toFixed(2) +
". I'd like to discuss booking and send photos of my driveway.";
return <section className="mt-6 rounded-md border border-brand-gold bg-white p-4">
<h3 className="font-display text-xl font-semibold">Send us your driveway photos</h3>
<p className="mt-2 text-sm">Please include a photo of the whole surface and close-ups of any cracks, potholes or other damage. We will review them and confirm your final price before booking.</p>
return <section className="rounded-md border border-brand-gold bg-white p-3">
<h3 className="font-display text-xl font-semibold">{repairs ? "Let’s confirm your repairs" : "Send us your driveway photos"}</h3>
<p className="mt-2 text-sm">{repairs ? "Your quotation already includes an allowance for repairs. Please send a photo of the whole driveway and close-ups of any damage." : "Please send a photo of your whole driveway so we can prepare for your restoration."}</p>
{valid ? <div className="mt-4 grid gap-3">
<a className="rounded-md bg-green-700 px-4 py-3 text-center font-semibold text-white" href={"https://wa.me/" + phone.slice(1) + "?text=" + encodeURIComponent(message)}>Continue on WhatsApp</a>
<a className="rounded-md bg-blue-700 px-4 py-3 text-center font-semibold text-white" href={"sms:" + phone + "?body=" + encodeURIComponent(message)}>Continue in Messages</a>
<a className="rounded-md bg-green-700 px-4 py-3 text-center font-semibold text-white" href={"https://wa.me/" + phone.slice(1) + "?text=" + encodeURIComponent(message)}>Send photos via WhatsApp</a>
<a className="rounded-md bg-blue-700 px-4 py-3 text-center font-semibold text-white" href={"sms:" + phone + "?body=" + encodeURIComponent(message)}>Send photos via text message</a>
<p className="text-xs">If your messaging app does not prefill the message, include reference {reference}. Attach your photos before sending.</p>
</div> : <p className="mt-3 text-sm">Your enquiry is saved. Our team will contact you to arrange photo review.</p>}
<p className="mt-3 text-xs">No payment or booking is confirmed at this stage.</p>
</div> : <p className="mt-3 text-sm">Our team will contact you to arrange photo review.</p>}

</section>;
}

Expand Down
Loading