from datetime import datetime

from pydantic import BaseModel

from src.db.models.admin import Profile


class ProfileResponse(BaseModel):
    id: str
    created_date: datetime
    last_modified_date: datetime
    version: int
    first_name: str
    last_name: str
    user_name: str
    email: str
    password: str
    enabled: bool

def to_response(profile: Profile) -> ProfileResponse:
    response: ProfileResponse = ProfileResponse(
        id=profile.id,
        created_date=profile.created_date,
        last_modified_date=profile.last_modified_date,
        version=profile.version,
        first_name=profile.first_name,
        last_name=profile.last_name,
        user_name=profile.user_name,
        email=profile.email,
        password=profile.password,
        enabled=profile.enabled        
    )
    return response

class ProfileModel(BaseModel):
    username: str
    email: str
    first_name: str
    last_name: str
    active: bool

def to_model(profile: Profile) -> ProfileModel:
    model: ProfileModel = ProfileModel(
        username=profile.user_name,
        email=profile.email,
        first_name=profile.first_name,
        last_name=profile.last_name,
        active=profile.enabled,
    )
    return model
