from datetime import datetime
from typing import Optional
import uuid
from sqlalchemy import JSON, Column, DateTime, ForeignKey, String
from sqlmodel import Field, SQLModel
from utils.datetime_utils import get_current_utc_datetime


class BrandConfigModel(SQLModel, table=True):
    __tablename__ = "brand_configs"

    id: uuid.UUID = Field(primary_key=True, default_factory=uuid.uuid4)
    client_id: uuid.UUID = Field(
        sa_column=Column(ForeignKey("clients.id"), unique=True)
    )
    primary_colors: Optional[list] = Field(sa_column=Column(JSON), default=None)
    secondary_colors: Optional[list] = Field(sa_column=Column(JSON), default=None)
    fonts: Optional[dict] = Field(sa_column=Column(JSON), default=None)
    logo_paths: Optional[list] = Field(sa_column=Column(JSON), default=None)
    voice_rules: Optional[str] = Field(
        sa_column=Column(String, nullable=True), default=None
    )
    voice_examples: Optional[list] = Field(sa_column=Column(JSON), default=None)
    guideline_doc_path: Optional[str] = Field(
        sa_column=Column(String, nullable=True), default=None
    )
    created_at: datetime = Field(
        sa_column=Column(
            DateTime(timezone=True), nullable=False, default=get_current_utc_datetime
        ),
    )
    updated_at: datetime = Field(
        sa_column=Column(
            DateTime(timezone=True),
            nullable=False,
            default=get_current_utc_datetime,
            onupdate=get_current_utc_datetime,
        ),
    )
