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 TenantModel
from sqlalchemy.orm import Mapped, mapped_column


class EmailTemplate(TenantModel):
    __tablename__ = "email_templates"

    name: Mapped[str] = mapped_column(String(255), nullable=False)
    trigger: Mapped[Optional[str]] = mapped_column(String(255), nullable=True)
    subject: Mapped[str] = mapped_column(String(500), nullable=False)
    body: Mapped[str] = mapped_column(Text, nullable=False, default="")
    is_enabled: Mapped[bool] = mapped_column(Boolean, nullable=False, default=True)
    variables: Mapped[Optional[list]] = mapped_column(JSONB, nullable=True)
