import pandas as pd
from utils.s3 import save_csv_to_s3

PORTFOLIO_ID = 115
USER_ID = 8


def app():
    """
    Used to set up the remote assessments for Warwick
    """

    asset_list = [
        {
            "uprn": 10033604792,
            "address": "Flat 2, 3 Green Street",
            "postcode": "W1K 6RN"
        },
        {
            "uprn": 10033604794,
            "address": "Flat 4, 3 Green Street",
            "postcode": "W1K 6RN"
        },
        {
            "uprn": 10033615515,
            "address": "Apartment 4, 52 Green Street",
            "postcode": "W1K 6RS"
        }
    ]
    asset_list = pd.DataFrame(asset_list)

    # Store the asset list in s3
    filename = f"{USER_ID}/{PORTFOLIO_ID}/asset_list.csv"
    save_csv_to_s3(
        dataframe=asset_list,
        bucket_name="retrofit-plan-inputs-dev",
        file_name=filename
    )

    non_invasive_recommendations = [
        {
            "uprn": 10033604792,
            "recommendations": [
                {
                    "type": "internal_wall_insulation",
                    "sap_points": 16,
                    "survey": True
                }
            ]
        },
        {
            "uprn": 10033604794,
            "recommendations": [
                {
                    "type": "internal_wall_insulation",
                    "sap_points": 14,
                    "survey": True
                }
            ]
        },
        {
            "uprn": 10033615515,
            "recommendations": [
                {
                    "type": "room_roof_insulation",
                    "sap_points": 12,
                    "survey": True
                },
                {
                    "type": "internal_wall_insulation",
                    "sap_points": 2,
                    "survey": True
                }
            ]
        }
    ]

    # Store non-invasive recommendations in S3
    non_invasive_recommendations_filename = f"{USER_ID}/{PORTFOLIO_ID}/non_invasive_recommendations.csv"
    save_csv_to_s3(
        dataframe=pd.DataFrame(non_invasive_recommendations),
        bucket_name="retrofit-plan-inputs-dev",
        file_name=non_invasive_recommendations_filename
    )

    valuation_data = [
        {
            "uprn": 10033604792,
            "value": 3_692_000
        },
        {
            "uprn": 10033604794,
            "value": 3_789_000
        },
        {
            "uprn": 10033615515,
            "value": 3_499_000
        }
    ]

    # Store valuation data to s3
    valuation_filename = f"{USER_ID}/{PORTFOLIO_ID}/valuation.csv"
    save_csv_to_s3(
        dataframe=pd.DataFrame(valuation_data),
        bucket_name="retrofit-plan-inputs-dev",
        file_name=valuation_filename
    )

    body = {
        "portfolio_id": str(PORTFOLIO_ID),
        "housing_type": "Private",
        "goal": "Increasing EPC",
        "goal_value": "C",
        "trigger_file_path": filename,
        "already_installed_file_path": "",
        "patches_file_path": "",
        "non_invasive_recommendations_file_path": non_invasive_recommendations_filename,
        "valuation_file_path": valuation_filename,
        "scenario_name": "Full package remote assessment",
        "multi_plan": True,
        "budget": None,
    }
    print(body)
