#!/usr/bin/env python3
"""Get full detail of a Launch27 booking including upcoming dates"""
import sys
import asyncio
from playwright.async_api import async_playwright

BOOKING_ID = sys.argv[1] if len(sys.argv) > 1 else "77663"
EMAIL = "mike@nomorechores.com"
PASSWORD = "er!NCY73J"
BASE_URL = "https://nomorechores.launch27.com"

async def check():
    async with async_playwright() as p:
        browser = await p.chromium.launch(headless=True)
        page = await browser.new_page()
        page.set_default_timeout(30000)

        await page.goto(f"{BASE_URL}/login", wait_until="networkidle")
        await page.wait_for_timeout(2000)
        await page.fill('input[ng-model="ctrl.user.email"]', EMAIL)
        await page.fill('input[ng-model="ctrl.user.password"]', PASSWORD)
        await page.click('button:has-text("Sign In")')
        await page.wait_for_load_state("networkidle")
        await page.wait_for_timeout(2000)

        await page.goto(f"{BASE_URL}/admin/bookings/{BOOKING_ID}", wait_until="domcontentloaded")
        await page.wait_for_timeout(5000)
        
        text = await page.evaluate("() => document.body.innerText")
        print(f"Full booking page text:\n{text[:3000]}")
        await page.screenshot(path="/Users/harvey/.openclaw/workspace/l27-booking-full.png", full_page=True)
        await browser.close()

asyncio.run(check())
