import uuid from datetime import datetime from typing import Optional from pydantic import BaseModel, Field class Token(BaseModel): access_token: str token_type: str role: str class TokenData(BaseModel): phone: Optional[str] = None class UserLogin(BaseModel): phone: str = Field(..., min_length=10, max_length=10, pattern=r"^\d{10}$") otp: str = Field(..., min_length=6, max_length=6) role: str = Field(..., pattern="^(customer|worker|mediator|admin)$") class UserRegister(BaseModel): phone: str = Field(..., min_length=10, max_length=10, pattern=r"^\d{10}$") name: str = Field(..., min_length=2) role: str = Field(..., pattern="^(customer|worker|mediator|admin)$") city: str = Field("Jaipur", min_length=2) password: Optional[str] = None # Worker-specific fields (optional during registration, required if role is worker) skill: Optional[str] = None rate: Optional[int] = None class WorkerProfileResponse(BaseModel): skill: str rate: int rating: float distance: float online: bool verified: bool completed_jobs: int completion_rate: int map_x: int map_y: int class Config: from_attributes = True class CustomerProfileResponse(BaseModel): wallet_balance: int class Config: from_attributes = True class UserResponse(BaseModel): id: uuid.UUID phone: str name: str role: str city: str is_active: bool created_at: datetime worker_profile: Optional[WorkerProfileResponse] = None customer_profile: Optional[CustomerProfileResponse] = None class Config: from_attributes = True class WorkerSearchResult(BaseModel): id: uuid.UUID name: str phone: str city: str skill: str rate: int rating: float distance: float online: bool verified: bool completed_jobs: int completion_rate: int map_x: int map_y: int ai_score: int