from Schemas import Applications, Application2Employee, Employees


def init_applications_for_super_user(super_user: Employees, db_session=None) -> None:
    list_of_created_apps = [
        dict(
            name="Dashboard1",
            application_code="app000001",
            site_url="/dashboard",
            application_type="info",
            description="Dashboard Page",
        ),
        dict(
            name="Individual",
            application_code="app000003",
            site_url="/individual",
            application_type="Dash",
            description="Individual Page for people",
        ),
        dict(
            name="User",
            application_code="app000004",
            site_url="/user",
            application_type="Dash",
            description="Individual Page for user",
        ),
        dict(
            name="Build",
            application_code="app000005",
            site_url="/build",
            application_type="Dash",
            description="Individual Page for build",
        ),
        dict(
            name="BuildParts",
            application_code="app000006",
            site_url="/build/parts",
            application_type="Dash",
            description="Individual Page for build parts",
        ),
        dict(
            name="BuildArea",
            application_code="app000007",
            site_url="/build/area",
            application_type="Dash",
            description="Individual Page for build area",
        ),
        dict(
            name="ManagementAccounting",
            application_code="app000008",
            site_url="/management/accounting",
            application_type="Dash",
            description="Individual Page for management accounting",
        ),
        dict(
            name="ManagementBudget",
            application_code="app000009",
            site_url="/management/budget",
            application_type="Dash",
            description="Individual Page for management accounting2",
        ),
        dict(
            name="ManagementMeetingClose",
            application_code="app000010",
            site_url="/annual/meeting/close",
            application_type="Dash",
            description="Individual Page for management accounting3",
        ),
        dict(
            name="EmergencyMeeting",
            application_code="app000011",
            site_url="/emergency/meeting",
            application_type="Dash",
            description="Individual Page for management accounting4",
        ),
        dict(
            name="EmergencyMeetingClose",
            application_code="app000012",
            site_url="/emergency/meeting/close",
            application_type="Dash",
            description="Individual Page for management accounting5",
        ),
        dict(
            name="MeetingParticipation",
            application_code="app000013",
            site_url="/meeting/participation",
            application_type="Dash",
            description="Individual Page for management accounting6",
        ),
    ]
    for list_of_created_app in list_of_created_apps:
        created_page = Applications.find_or_create(
            **list_of_created_app,
            db=db_session,
            is_confirmed=True,
        )
        if created_page.meta_data.created:
            created_page.save(db=db_session)

        application_employee_created = Application2Employee.find_or_create(
            employee_id=super_user.id,
            employee_uu_id=str(super_user.uu_id),
            site_url=created_page.site_url,
            application_code=created_page.application_code,
            application_id=created_page.id,
            application_uu_id=str(created_page.uu_id),
            is_confirmed=True,
            db=db_session,
        )
        if application_employee_created.meta_data.created:
            application_employee_created.save(db=db_session)
