from pydantic import BaseModel
from typing import Optional, List
from datetime import datetime


class CustomerCreate(BaseModel):
    name: str
    nickname: Optional[str] = None
    phone: Optional[str] = None
    email: Optional[str] = None
    notes: Optional[str] = None


class CustomerUpdate(BaseModel):
    name: Optional[str] = None
    nickname: Optional[str] = None
    phone: Optional[str] = None
    email: Optional[str] = None
    notes: Optional[str] = None
    is_active: Optional[bool] = None


class CustomerOut(BaseModel):
    id: int
    name: str
    nickname: Optional[str] = None
    phone: Optional[str] = None
    email: Optional[str] = None
    notes: Optional[str] = None
    is_active: bool
    created_at: datetime
    created_by_id: int
    # computed stats (set by router)
    visit_count: int = 0
    total_spent: float = 0.0

    model_config = {"from_attributes": True}


class AssignCustomerRequest(BaseModel):
    customer_id: Optional[int] = None  # null = unassign
