from django.shortcuts import render, redirect
from .models import Profile

def home(request):
    """Render the SnapStyle landing page."""
    return render(request, "core/index.html")

def profile_setup(request):
    """Handle profile creation and updates."""
    if request.method == 'POST':
        # In a real implementation, use a Django Form for validation
        Profile.objects.create(
            full_name=request.POST.get('full_name'),
            display_name=request.POST.get('display_name'),
            country=request.POST.get('country'),
            height_cm=request.POST.get('height_cm'),
            weight_kg=request.POST.get('weight_kg'),
            top_size=request.POST.get('top_size'),
            bottom_size=request.POST.get('bottom_size'),
            favorite_colors=request.POST.getlist('favorite_colors'),
            favorite_categories=request.POST.getlist('favorite_categories'),
            budget_level=request.POST.get('budget_level'),
        )
        # For now, redirect back to the home page after submission
        return redirect('home')
        
    return render(request, "core/profile_setup.html")

