from fastapi import FastAPI, Form
from fastapi import APIRouter,HTTPException
from pydantic import BaseModel, validator
from app.schemas.customer import CustomerData
router = APIRouter()



@router.post("/customer-details",tags=['Customer endpoint'])

async def customer_info(data: CustomerData):
    if '' in [data.firstName, data.lastName, data.email, data.phone, data.address,
              data.city, data.state, data.zipcode, data.country]:
        raise HTTPException(status_code=400, detail="Fields cannot be empty")
    
    if not data.phone.isdigit() or len(data.phone) != 10:
        raise HTTPException(status_code=400, detail="Invalid phone number")
    
    print(data)