"""Account, authentication and policy-management views. RECONSTRUCTION NOTICE. Insureon's customer portal is served from `up.apps.insureon.com`, which returned HTTP 403 (awselb/2.0) for every request from the capture environment. None of these screens is transcribed from captured source pixels; only the site chrome, palette and typography around them are. They carry no visual contract and are not acceptance-eligible. See `KNOWN_DIFFERENCES.md`. """ from __future__ import annotations from typing import Any, Mapping, Sequence import render as R ACCOUNT_NAV = [ ("/account", "Overview"), ("/account/quotes", "Saved quotes"), ("/account/policies", "Policies"), ("/account/documents", "Documents"), ("/account/profile", "Profile & billing"), ] TERMS_LINKS = ( 'Terms of use and ' 'Privacy policy' ) def _auth_shell(inner: str, *, title: str, description: str = "") -> str: body = f"""
{inner}
""" return R.page(body, title=title, description=description) def _account_shell(inner: str, *, title: str, active: str, account_name: str = "") -> str: nav = "".join( '{}'.format( href, ' class="is-active"' if href == active else "", R.esc(label)) for href, label in ACCOUNT_NAV ) body = f"""

My account

{R.esc(account_name)}

{nav}
{inner}
""" return R.page(body, title=title, logged_in=True, account_name=account_name) # --------------------------------------------------------------------------- # # T16 sign-in # --------------------------------------------------------------------------- # def login(errors: Mapping[str, str] | None = None, email: str = "", next_url: str = "", notice: str = "") -> str: errors = errors or {} inner = f"""

Log in to your account

Manage your policies, quotes and certificates of insurance.

{R.notice(notice)} {R.error_summary(errors)}
{R.field("email", "Email address", kind="email", value=email, error=errors.get("email", ""), required=True, attrs='autocomplete="email"')} {R.field("password", "Password", kind="password", error=errors.get("password", ""), required=True, attrs='autocomplete="current-password"')}

Forgot your password?

Don't have an account? Create one

This offline demonstration site issues its own local credentials. It does not use, accept or forward any real Insureon account.

""" return _auth_shell(inner, title="Log in | Insureon", description="Log in to manage your Insureon policies and quotes.") # --------------------------------------------------------------------------- # # T17 registration # --------------------------------------------------------------------------- # def register(errors: Mapping[str, str] | None = None, values: Mapping[str, str] | None = None, stage: str = "details", next_url: str = "", code_hint: str = "", email: str = "") -> str: errors = errors or {} values = values or {} if stage == "verify": inner = f"""

Confirm your email

We sent a 6-digit confirmation code to {R.esc(email)}. Enter it below to finish creating your account.

{R.notice(code_hint)} {R.error_summary(errors)}
{R.field("code", "Confirmation code", value="", error=errors.get("code", ""), required=True, attrs='inputmode="numeric" maxlength="6" autocomplete="one-time-code"')}

Start over · Back to log in

""" return _auth_shell(inner, title="Confirm your email | Insureon") inner = f"""

Create your account

Save your quotes, download certificates and manage policies in one place.

{R.error_summary(errors)}
{R.field("name", "Full name", value=values.get("name", ""), error=errors.get("name", ""), required=True, attrs='autocomplete="name"')} {R.field("email", "Email address", kind="email", value=values.get("email", ""), error=errors.get("email", ""), required=True, hint="We send policy documents and confirmation codes to this address.", attrs='autocomplete="email"')} {R.field("password", "Password", kind="password", error=errors.get("password", ""), required=True, hint="At least 12 characters.", attrs='autocomplete="new-password"')}

We will email you a 6-digit confirmation code to verify this address before your account is created.

By creating an account you agree to our {TERMS_LINKS}.

Already have an account? Log in

""" return _auth_shell(inner, title="Create an account | Insureon", description="Create an Insureon account to save quotes and manage policies.") # --------------------------------------------------------------------------- # # T18 password recovery # --------------------------------------------------------------------------- # def forgot_password(errors: Mapping[str, str] | None = None, stage: str = "request", email: str = "", code_hint: str = "", notice: str = "") -> str: errors = errors or {} back = ('

' 'Return to log in

') if stage == "verify": inner = f"""

Enter your reset code

If an account exists for {R.esc(email)}, we sent it a 6-digit reset code.

{R.notice(code_hint)} {R.error_summary(errors)}
{R.field("code", "Reset code", error=errors.get("code", ""), required=True, attrs='inputmode="numeric" maxlength="6" autocomplete="one-time-code"')} {R.field("new_password", "New password", kind="password", error=errors.get("new_password", ""), required=True, hint="At least 12 characters.", attrs='autocomplete="new-password"')}
{back}
""" return _auth_shell(inner, title="Reset your password | Insureon") inner = f"""

Reset your password

Enter the email address on your account and we will send a 6-digit reset code to it.

{R.notice(notice)} {R.error_summary(errors)}
{R.field("email", "Email address on your account", kind="email", value=email, error=errors.get("email", ""), required=True, hint="Enter the address exactly as you registered it.", attrs='autocomplete="email"')}

For your security we show the same confirmation whether or not an account exists for the address you enter.

{back}
""" return _auth_shell(inner, title="Reset your password | Insureon", description="Reset the password on your Insureon account.") # --------------------------------------------------------------------------- # # portal # --------------------------------------------------------------------------- # def _record(title: str, meta: str, actions: Sequence[tuple[str, str]], status: str = "", newest: bool = False) -> str: acts = "".join( f'{R.esc(label)}' for label, href in actions ) return f"""
{R.esc(title)} {R.badge(status) if status else ''}
{R.esc(meta)}
{acts}
""" def overview(account_name: str, applications: Sequence[Mapping[str, Any]], policies: Sequence[Mapping[str, Any]], documents: Sequence[Mapping[str, Any]]) -> str: tiles = f"""

{len(applications)}

Quote applications

View saved quotes

{len(policies)}

Policies

Manage policies

{len(documents)}

Documents

View documents
""" recent = "".join( _record( f'{a.get("business_name") or "Untitled application"} — {a.get("profession_name", "")}', f'{a.get("reference", "")} · updated {str(a.get("updated_at", ""))[:10]}', [("Open", f'/app/quote/{a["id"]}/review')], status=str(a.get("status", "")), newest=(i == 0), ) for i, a in enumerate(applications[:5]) ) or '
You have no quote applications yet. ' \ 'Start a quote.
' inner = (tiles + "

Recent activity

" + f'
{recent}
') return _account_shell(inner, title="My account | Insureon", active="/account", account_name=account_name) def quotes(account_name: str, applications: Sequence[Mapping[str, Any]], notice: str = "") -> str: """T10 / T19: saved quotes, newest first, each with status and actions.""" rows = "".join( _record( f'{a.get("business_name") or "Untitled application"} — {a.get("profession_name", "")}', f'{a.get("reference", "")} · {a.get("employees", "")} employees · ' f'{"$%s" % format(int(a["annual_revenue"]), ",") if a.get("annual_revenue") else "—"} revenue · ' f'saved {str(a.get("saved_at") or a.get("updated_at", ""))[:10]}', [("View quotes", f'/app/quote/{a["id"]}/quotes'), ("Edit details", f'/app/quote/{a["id"]}/business'), ("Review", f'/app/quote/{a["id"]}/review')], status=str(a.get("status", "")), newest=(i == 0), ) for i, a in enumerate(applications) ) or ('
You have not saved any quotes yet. ' 'Start a quote and save it to come back to it.
') inner = (R.notice(notice) + "

Saved quotes

" + "

Open a saved quote to change an " "input and recalculate your options.

" + f'
{rows}
') return _account_shell(inner, title="Saved quotes | Insureon", active="/account/quotes", account_name=account_name) def policies(account_name: str, rows: Sequence[Mapping[str, Any]], notice: str = "") -> str: """T14: policy management — detail, billing, renewal, cancellation.""" items = "".join( _record( f'{p["product_name"]} — {p["carrier_name"]}', f'Policy {p["number"]} · effective {p["effective_date"]} to ' f'{p["expiration_date"]} · {R.money(p["annual_premium_cents"])} / year', [("Manage", f'/account/policies/{p["id"]}')], status=str(p.get("status", "")), newest=(i == 0), ) for i, p in enumerate(rows) ) or ('
You have no policies yet. ' 'Get quotes to buy coverage.
') inner = (R.notice(notice) + "

Your policies

" + f'
{items}
') return _account_shell(inner, title="My policies | Insureon", active="/account/policies", account_name=account_name) def policy_detail(account_name: str, p: Mapping[str, Any], documents: Sequence[Mapping[str, Any]], notice: str = "") -> str: docs = "".join( f'
  • {R.esc(d["title"])}' f' ' f'({R.esc(str(d.get("issued_at", ""))[:10])})
  • ' for d in documents ) or "
  • No documents issued for this policy yet.
  • " active = str(p.get("status")) == "active" cancel = f"""
    """ if active else "" coi = f"""
    {R.field("holder_name", "Certificate holder", placeholder="Lakeside Property Group", hint="The client or landlord who needs proof of your coverage.")}
    """ if active else "" inner = f"""{R.notice(notice)} ← Back to policies

    {R.esc(p["product_name"])} — {R.esc(p["carrier_name"])} {R.badge(str(p.get("status", "")))}

    Policy number{R.esc(p["number"])}
    Carrier{R.esc(p["carrier_name"])}
    Status{R.esc(str(p.get("status", "")).title())}
    Effective date{R.esc(p["effective_date"])}
    Expiration date{R.esc(p["expiration_date"])}
    Annual premium {R.money(p["annual_premium_cents"])}
    Billing details File a claim Contact support {cancel}

    Documents

    {coi}
    """ return _account_shell(inner, title=f"Policy {p['number']} | Insureon", active="/account/policies", account_name=account_name) def documents(account_name: str, rows: Sequence[Mapping[str, Any]]) -> str: """T13: policy/quote documents, summaries and proof of insurance.""" items = "".join( _record( d["title"], f'{str(d.get("kind", "")).replace("-", " ").title()} · issued ' f'{str(d.get("issued_at", ""))[:10]}', [("Open", f'/account/documents/{d["id"]}')], newest=(i == 0), ) for i, d in enumerate(rows) ) or ('
    No documents yet. Documents are issued when you ' 'get quotes and when you buy a policy.
    ') inner = ("

    Your documents

    " + f'
    {items}
    ') return _account_shell(inner, title="Documents | Insureon", active="/account/documents", account_name=account_name) def document_detail(account_name: str, d: Mapping[str, Any]) -> str: inner = f"""← Back to documents

    {R.esc(d["title"])}

    {R.esc(str(d.get("kind", "")).replace("-", " ").title())} · issued {R.esc(str(d.get("issued_at", ""))[:10])}

    {R.esc(d.get("body", ""))}
    """ return _account_shell(inner, title=f'{d["title"]} | Insureon', active="/account/documents", account_name=account_name) def profile(account_name: str, email: str, payments: Sequence[Mapping[str, Any]], notice: str = "") -> str: rows = "".join( f'{R.esc(str(p.get("created_at", ""))[:10])}' f'{R.money(p["amount_cents"])} · {R.esc(p.get("method_label", ""))} · ' f'{R.esc(str(p.get("status", "")).title())}' for p in payments ) or 'No payments recorded.' inner = f"""{R.notice(notice)}

    Profile

    {R.field("display_name", "Name on account", value=account_name)} {R.field("email", "Email address", kind="email", value=email, attrs='readonly aria-readonly="true"', hint="Contact support to change the email on your account.")}

    Billing history

    {rows}

    This offline demonstration site records local sandbox payments only. No card details are collected, stored or transmitted.

    """ return _account_shell(inner, title="Profile & billing | Insureon", active="/account/profile", account_name=account_name) # --------------------------------------------------------------------------- # # T20 permission prompt # --------------------------------------------------------------------------- # def sign_in_required(next_url: str, what: str = "this page") -> str: inner = f"""

    Log in to continue

    You need to be logged in to view {R.esc(what)}. Your quote is saved and you can pick up where you left off.

    Log in Create an account
    """ return _auth_shell(inner, title="Log in to continue | Insureon")