from datetime import date, datetime, timezone

from sqlalchemy.orm import Session

from app.models import Lead
from app.services import build_follow_ups


SEED_NOTES = """Hi Velurax,

I completely understand that $400 felt like a lot when you're just starting out. We're running a Halloween Special for new store owners who are just getting started, and I'd love for you to take advantage of it..

🎃 Halloween Starter Package: $[299] (regular $400), and you can split it into 2 easy payments of $[150].

You'll still get a professional, launch-ready store with [setup, design, product pages and payment integration], so your shop looks great and is ready to sell from day one.

That's a saving of $[101], and it's built for businesses at your stage, so you can start strong without overstretching your budget.

This offer is only valid until October 31st, and we have limited slots available.

If you'd like to lock it in, just reply "YES" and I'll take care of the rest.

Best regards,
Blair S"""


def seed_if_empty(db: Session) -> None:
    if db.query(Lead).count() > 0:
        return

    date_added = date(2025, 9, 16)
    lead = Lead(
        lead_code="L-001",
        contact_name="Blair S",
        client_email="veluraxoffice@gmail.com",
        our_email="machinedeveloper6@gmail.com",
        website="https://velurax.com/",
        date_added=date_added,
        stage="Warm lead",
        deal_value=299,
        notes=SEED_NOTES,
        call_scheduled=False,
        sort_order=0,
    )
    follow_ups = build_follow_ups(date_added)
    now = datetime.now(timezone.utc)
    for fu in follow_ups:
        fu.status = "done"
        fu.completed_at = now
    lead.follow_ups = follow_ups
    db.add(lead)
    db.commit()
