#user_schemas.py
from pydantic import BaseModel, EmailStr
from typing import Optional, Union

# Request Schema: User Registration
class UserCreate(BaseModel):
    name: str
    email: EmailStr # Ensures valid email format
    password: str
    role: Optional[str] = "customer"  # Default role set to "customer"


# User Response Schema
class UserResponse(BaseModel):
    name: str
    email: EmailStr
    role: str  

    class Config:
        from_attributes = True  # Allow ORM mode for SQLAlchemy models

# General Response Wrapper Schema
class APIResponse(BaseModel):
    status: bool
    code: int
    message: str
    data: Union[UserResponse, dict]  # Can hold either user data or an empty dict

