# app/ai/utils/draft_html_generator.py # Generate beautiful HTML UI for listing drafts def generate_draft_html(draft: dict) -> str: """ Generate a beautiful HTML UI for the listing draft. This HTML is returned to frontend and displayed directly. Args: draft: Dictionary with listing data Returns: Complete HTML string for the draft preview """ # Extract data title = draft.get("title", "Untitled") description = draft.get("description", "No description") location = draft.get("location", "N/A") bedrooms = draft.get("bedrooms", "?") bathrooms = draft.get("bathrooms", "?") price = draft.get("price", "?") currency = draft.get("currency", "N/A") price_type = draft.get("price_type", "N/A") amenities = draft.get("amenities", []) requirements = draft.get("requirements", "") images = draft.get("images", []) # Format amenities with icons amenity_icons = { "wifi": "๐Ÿ“ถ", "parking": "๐Ÿ…ฟ๏ธ", "furnished": "๐Ÿ›‹๏ธ", "washing machine": "๐Ÿงผ", "dryer": "๐Ÿ”„", "balcony": "๐ŸŒ†", "pool": "๐ŸŠ", "gym": "๐Ÿ’ช", "garden": "๐ŸŒฟ", "air conditioning": "โ„๏ธ", "kitchen": "๐Ÿณ", "ac": "โ„๏ธ", "washer": "๐Ÿงผ", } amenities_html = "" if amenities: amenities_html = '
' for amenity in amenities: icon = amenity_icons.get(amenity.lower(), "โœ“") amenities_html += f'{icon} {amenity}' amenities_html += '
' # Format images images_html = "" if images: images_html = '' # Requirements section requirements_html = "" if requirements: requirements_html = f'''

๐Ÿ“ Requirements

{requirements}

''' # Complete HTML html = f''' {title} - Lojiz

{title}

๐Ÿ“‹ Draft Preview

{description}

๐Ÿ“

Location

{location}

๐Ÿ›๏ธ

Bedrooms

{bedrooms}

๐Ÿšฟ

Bathrooms

{bathrooms}

๐Ÿ 

Type

{draft.get('listing_type', 'N/A').title()}

{amenities_html} {images_html} {requirements_html}
๐Ÿ’ฐ Price
{currency} {price}
per {price_type}
''' return html