from django.shortcuts import render, redirect
from django.contrib.auth import login
from .forms import CompanySignUpForm, InfluencerSignUpForm

def index(request):
    return render(request, 'core/index.html')

def pricing(request):
    return render(request, 'core/pricing.html')

def login(request):
    return render(request, 'core/login.html')

def signup(request):
    if request.method == 'POST':
        if request.POST.get('role') == 'company':
            form = CompanySignUpForm(request.POST)
        else:
            form = InfluencerSignUpForm(request.POST)
        if form.is_valid():
            user = form.save()
            login(request, user)
            return redirect('index')
    else:
        form = InfluencerSignUpForm()
    return render(request, 'core/signup.html', {'form': form})