from __future__ import annotations
from typing import Optional
from sqlalchemy import Boolean, String, Text
from sqlalchemy.dialects.postgresql import JSONB
from src.database.base import TenantSoftDeleteModel
from sqlalchemy.orm import Mapped, mapped_column


class EmailTemplate(TenantSoftDeleteModel):
    __tablename__ = "email_templates"

    template_key: Mapped[Optional[str]] = mapped_column(String(100), nullable=True)
    is_system: Mapped[bool] = mapped_column(Boolean, nullable=False, default=False)
    name: Mapped[str] = mapped_column(String(100), nullable=False)
    description: Mapped[Optional[str]] = mapped_column(String(255), nullable=True)
    subject: Mapped[str] = mapped_column(String(200), nullable=False)
    body: Mapped[str] = mapped_column(Text, nullable=False, default="")
    status: Mapped[str] = mapped_column(String(20), nullable=False, default="active")
    merge_fields: Mapped[Optional[list]] = mapped_column(JSONB, nullable=True)
